kfahn commited on
Commit
7f72a8e
1 Parent(s): a869c16

add negative prompt

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -15,11 +15,18 @@ db_diffusion_model = from_pretrained_keras("kfahn/dreambooth-mandelbulb")
15
  sd_dreambooth_model._diffusion_model = db_diffusion_model
16
 
17
  # generate images
18
- def infer(prompt):
19
- generated_images = sd_dreambooth_model.text_to_image(
20
- prompt, batch_size=2
21
- )
22
- return generated_images
 
 
 
 
 
 
 
23
 
24
  output = gr.Gallery(label="Outputs").style(grid=(1,2))
25
 
 
15
  sd_dreambooth_model._diffusion_model = db_diffusion_model
16
 
17
  # generate images
18
+ def infer(prompt, negative_prompt, guidance_scale=10, num_inference_steps=50):
19
+ neg = negative_prompt if negative_prompt else None
20
+ imgs = []
21
+ while len(imgs) != 2:
22
+ next_prompt = pipeline(prompt, negative_prompt=neg, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps, num_images_per_prompt=5)
23
+ for img, is_neg in zip(next_prompt.images, next_prompt.nsfw_content_detected):
24
+ if not is_neg:
25
+ imgs.append(img)
26
+ if len(imgs) == 2:
27
+ break
28
+
29
+ return imgs
30
 
31
  output = gr.Gallery(label="Outputs").style(grid=(1,2))
32