Spaces:
Build error
Build error
add negative prompt
#1
by
kfahn
- opened
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 |
-
|
20 |
-
|
21 |
-
)
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|