CiaraRowles commited on
Commit
111d52a
·
verified ·
1 Parent(s): 67bad40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -2,7 +2,7 @@ import torch
2
  import spaces
3
  from diffusers import StableDiffusionPipeline, DDIMScheduler, AutoencoderKL
4
  from transformers import AutoFeatureExtractor
5
- from controlnet.callable_functions import process_single_image_both_ways,make_stylecode,process_single_image
6
 
7
  from huggingface_hub import hf_hub_download
8
  import gradio as gr
@@ -18,10 +18,10 @@ device = "cuda"
18
  cv2.setNumThreads(1)
19
 
20
  @spaces.GPU(enable_queue=True)
21
- def generate_image(images, prompt, negative_prompt,stylecode,strength, progress=gr.Progress(track_tqdm=True)):
22
 
23
 
24
-
25
 
26
  image = images
27
  yield None
@@ -31,7 +31,7 @@ def generate_image(images, prompt, negative_prompt,stylecode,strength, progress
31
  # Calculate new width and height
32
 
33
 
34
- image = process_single_image(ip_ckpt,image_path="",prompt=prompt,num_inference_steps=20,image=image,stylecode=stylecode)
35
 
36
  yield image
37
 
@@ -72,7 +72,8 @@ with gr.Blocks(css=css) as demo:
72
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
73
 
74
  with gr.Accordion(open=False, label="Advanced Options"):
75
- strength = gr.Slider(label="strength", value=0.8, step=0.05, minimum=0, maximum=1)
 
76
 
77
 
78
 
@@ -83,7 +84,7 @@ with gr.Blocks(css=css) as demo:
83
  stylecode_gen.click(fn=make_stylecode_gui,inputs=[files],outputs=stylecode)
84
 
85
  submit.click(fn=generate_image,
86
- inputs=[files, prompt, negative_prompt,stylecode,strength],
87
  outputs=gallery)
88
 
89
  gr.Markdown("This demo includes extra features to mitigate the implicit bias of the model and prevent explicit usage of it to generate content with faces of people, including third parties, that is not safe for all audiences, including naked or semi-naked people.")
 
2
  import spaces
3
  from diffusers import StableDiffusionPipeline, DDIMScheduler, AutoencoderKL
4
  from transformers import AutoFeatureExtractor
5
+ from controlnet.callable_functions import process_single_image_both_ways,make_stylecode,use_stylecode
6
 
7
  from huggingface_hub import hf_hub_download
8
  import gradio as gr
 
18
  cv2.setNumThreads(1)
19
 
20
  @spaces.GPU(enable_queue=True)
21
+ def generate_image(images, prompt, negative_prompt,stylecode,strength,additional_prompt, progress=gr.Progress(track_tqdm=True)):
22
 
23
 
24
+ full_prompt=prompt + additional_prompt
25
 
26
  image = images
27
  yield None
 
31
  # Calculate new width and height
32
 
33
 
34
+ image = use_stylecode(ip_ckpt,image_path="",prompt=prompt,num_inference_steps=20,image=image,stylecode=stylecode)
35
 
36
  yield image
37
 
 
72
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
73
 
74
  with gr.Accordion(open=False, label="Advanced Options"):
75
+ strength = gr.Slider(label="strength", value=0.9, step=0.05, minimum=0, maximum=1)
76
+ additional_prompt = gr.Textbox(label="additional prompt",placeholder ="highly detailed ,simple background")
77
 
78
 
79
 
 
84
  stylecode_gen.click(fn=make_stylecode_gui,inputs=[files],outputs=stylecode)
85
 
86
  submit.click(fn=generate_image,
87
+ inputs=[files, prompt, negative_prompt,stylecode,strength,additional_prompt],
88
  outputs=gallery)
89
 
90
  gr.Markdown("This demo includes extra features to mitigate the implicit bias of the model and prevent explicit usage of it to generate content with faces of people, including third parties, that is not safe for all audiences, including naked or semi-naked people.")