nielsgl commited on
Commit
0843b06
·
1 Parent(s): ab4b6c4

update app

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -28,9 +28,14 @@ prompt = f"A photo of {unique_id} {class_label} in a bucket"
28
 
29
  # generate images
30
  def infer(prompt, negative_prompt, guidance_scale=10, num_inference_steps=50):
31
- generated_images = pipeline(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps, num_images_per_prompt=2)
32
-
33
- return generated_images.images
 
 
 
 
 
34
 
35
  output = gr.Gallery(label="Outputs").style(grid=(1,2))
36
 
 
28
 
29
  # generate images
30
  def infer(prompt, negative_prompt, guidance_scale=10, num_inference_steps=50):
31
+ neg = negative_prompt if negative_prompt else None
32
+ imgs = []
33
+ while len(imgs) < 2:
34
+ next_prompt = pipeline(prompt, negative_prompt=neg, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps, num_images_per_prompt=2)
35
+ if not next_prompt.nsfw_content_detected[0]:
36
+ imgs.append(next_prompt.images[0])
37
+
38
+ return imgs
39
 
40
  output = gr.Gallery(label="Outputs").style(grid=(1,2))
41