CiaraRowles commited on
Commit
0812180
·
verified ·
1 Parent(s): 010024b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
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
6
 
7
  from huggingface_hub import hf_hub_download
8
  import gradio as gr
@@ -21,7 +21,7 @@ device = "cuda"
21
  cv2.setNumThreads(1)
22
 
23
  @spaces.GPU(enable_queue=True)
24
- def generate_image(images, prompt, negative_prompt, scale, nfaa_negative_prompt, progress=gr.Progress(track_tqdm=True)):
25
 
26
 
27
 
@@ -38,6 +38,10 @@ def generate_image(images, prompt, negative_prompt, scale, nfaa_negative_prompt,
38
 
39
  yield image
40
 
 
 
 
 
41
 
42
 
43
  def swap_to_gallery(images):
@@ -65,15 +69,16 @@ with gr.Blocks(css=css) as demo:
65
  placeholder="A photo of a [man/woman/person]...")
66
 
67
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
68
- submit = gr.Button("Submit")
69
- with gr.Accordion(open=False, label="Advanced Options"):
70
- nfaa_negative_prompts = gr.Textbox(label="Appended Negative Prompts", info="Negative prompts to steer generations towards safe for all audiences outputs", value="naked, bikini, skimpy, scanty, bare skin, lingerie, swimsuit, exposed, see-through")
71
- scale = gr.Slider(label="Scale", value=0.8, step=0.1, minimum=0, maximum=2)
72
  with gr.Column():
73
  gallery = gr.Gallery(label="Generated Images")
 
 
74
 
75
  submit.click(fn=generate_image,
76
- inputs=[files, prompt, negative_prompt, scale, nfaa_negative_prompts],
77
  outputs=gallery)
78
 
79
  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,process_single_image
6
 
7
  from huggingface_hub import hf_hub_download
8
  import gradio as gr
 
21
  cv2.setNumThreads(1)
22
 
23
  @spaces.GPU(enable_queue=True)
24
+ def generate_image(images, prompt, negative_prompt, progress=gr.Progress(track_tqdm=True)):
25
 
26
 
27
 
 
38
 
39
  yield image
40
 
41
+ @spaces.GPU(enable_queue=True)
42
+ def make_stylecode (images):
43
+ code = make_stylecode(ip_ckpt,images)
44
+ return code
45
 
46
 
47
  def swap_to_gallery(images):
 
69
  placeholder="A photo of a [man/woman/person]...")
70
 
71
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
72
+ stylecode_gen = gr.Button("Make stylecode")
73
+ stylecode = gr.Textbox(label="stylecode")
74
+ submit = gr.Button("Use stylecode")
 
75
  with gr.Column():
76
  gallery = gr.Gallery(label="Generated Images")
77
+
78
+ stylecode_gen.click(fn=make_stylecode,inputs=[files],outputs=stylecode)
79
 
80
  submit.click(fn=generate_image,
81
+ inputs=[files, prompt, negative_prompt],
82
  outputs=gallery)
83
 
84
  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.")