CiaraRowles commited on
Commit
abe9006
·
verified ·
1 Parent(s): 00d5ce9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -47,7 +47,7 @@ ip_model = IPAdapterInstruct(pipe, image_encoder_path, ip_ckpt, device,dtypein=t
47
  cv2.setNumThreads(1)
48
 
49
  @spaces.GPU(enable_queue=True)
50
- def generate_image(images, prompt, negative_prompt, preserve_face_structure, face_strength, scale, nfaa_negative_prompt, progress=gr.Progress(track_tqdm=True)):
51
  faceid_all_embeds = []
52
  first_iteration = True
53
  image = images[0]
@@ -59,7 +59,7 @@ def generate_image(images, prompt, negative_prompt, preserve_face_structure, fac
59
  print("Generating normal")
60
  image = ip_model.generate(
61
  prompt=prompt, negative_prompt=total_negative_prompt, pil_image=image,
62
- scale=scale, width=512, height=512, num_inference_steps=30
63
  )
64
 
65
  print(image)
@@ -95,22 +95,15 @@ with gr.Blocks(css=css) as demo:
95
  info="Try something like 'a photo of a man/woman/person'",
96
  placeholder="A photo of a [man/woman/person]...")
97
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
98
- style = gr.Radio(label="Generation type", info="For stylized try prompts like 'a watercolor painting of a woman'", choices=["Photorealistic", "Stylized"], value="Photorealistic")
99
  submit = gr.Button("Submit")
100
  with gr.Accordion(open=False, label="Advanced Options"):
101
- preserve = gr.Checkbox(label="Preserve Face Structure", info="Higher quality, less versatility (the face structure of your first photo will be preserved). Unchecking this will use the v1 model.", value=True)
102
- face_strength = gr.Slider(label="Face Structure strength", info="Only applied if preserve face structure is checked", value=1.3, step=0.1, minimum=0, maximum=3)
103
- scale = gr.Slider(label="Scale", value=1.0, step=0.1, minimum=0, maximum=5)
104
  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")
105
  with gr.Column():
106
  gallery = gr.Gallery(label="Generated Images")
107
- style.change(fn=change_style,
108
- inputs=style,
109
- outputs=[preserve, face_strength, scale])
110
  files.upload(fn=swap_to_gallery, inputs=files, outputs=[uploaded_files, clear_button, files])
111
  remove_and_reupload.click(fn=remove_back_to_files, outputs=[uploaded_files, clear_button, files])
112
  submit.click(fn=generate_image,
113
- inputs=[files,prompt,negative_prompt,preserve, face_strength, scale, nfaa_negative_prompts],
114
  outputs=gallery)
115
 
116
  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.")
 
47
  cv2.setNumThreads(1)
48
 
49
  @spaces.GPU(enable_queue=True)
50
+ def generate_image(images, prompt, negative_prompt, scale, nfaa_negative_prompt, progress=gr.Progress(track_tqdm=True)):
51
  faceid_all_embeds = []
52
  first_iteration = True
53
  image = images[0]
 
59
  print("Generating normal")
60
  image = ip_model.generate(
61
  prompt=prompt, negative_prompt=total_negative_prompt, pil_image=image,
62
+ scale=scale, width=512, height=512, num_inference_steps=30,query="use everything from the image"
63
  )
64
 
65
  print(image)
 
95
  info="Try something like 'a photo of a man/woman/person'",
96
  placeholder="A photo of a [man/woman/person]...")
97
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality")
 
98
  submit = gr.Button("Submit")
99
  with gr.Accordion(open=False, label="Advanced Options"):
 
 
 
100
  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")
101
  with gr.Column():
102
  gallery = gr.Gallery(label="Generated Images")
 
 
 
103
  files.upload(fn=swap_to_gallery, inputs=files, outputs=[uploaded_files, clear_button, files])
104
  remove_and_reupload.click(fn=remove_back_to_files, outputs=[uploaded_files, clear_button, files])
105
  submit.click(fn=generate_image,
106
+ inputs=[files,prompt,negative_prompt, scale, nfaa_negative_prompts],
107
  outputs=gallery)
108
 
109
  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.")