Update app.py
Browse files
app.py
CHANGED
@@ -20,20 +20,31 @@ def generate_image(prompt: str,negative_prompt:str , inference_steps: int = 25,
|
|
20 |
num_samples = 1
|
21 |
prompt_ids = pipeline.prepare_inputs([prompt] * num_samples)
|
22 |
prompt_ids = shard(prompt_ids)
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
images = images.reshape((num_samples,) + images.shape[-3:])
|
39 |
images = pipeline.numpy_to_pil(images)
|
|
|
20 |
num_samples = 1
|
21 |
prompt_ids = pipeline.prepare_inputs([prompt] * num_samples)
|
22 |
prompt_ids = shard(prompt_ids)
|
23 |
+
if negative_prompt == "":
|
24 |
+
images = pipeline(
|
25 |
+
prompt_ids=prompt_ids,
|
26 |
+
params=p_params,
|
27 |
+
prng_seed=rng,
|
28 |
+
height=128,
|
29 |
+
width=128,
|
30 |
+
num_inference_steps=int(inference_steps),
|
31 |
+
guidance_scale =float(guidance_scale),
|
32 |
+
jit=True,
|
33 |
+
).images
|
34 |
+
else:
|
35 |
+
neg_prompt_ids = pipeline.prepare_inputs([negative_prompt] * num_samples)
|
36 |
+
neg_prompt_ids = shard(neg_prompt_ids)
|
37 |
+
images = pipeline(
|
38 |
+
prompt_ids=prompt_ids,
|
39 |
+
params=p_params,
|
40 |
+
prng_seed=rng,
|
41 |
+
height=128,
|
42 |
+
width=128,
|
43 |
+
num_inference_steps=int(inference_steps),
|
44 |
+
neg_prompt_ids=neg_prompt_ids,
|
45 |
+
guidance_scale =float(guidance_scale),
|
46 |
+
jit=True,
|
47 |
+
).images
|
48 |
|
49 |
images = images.reshape((num_samples,) + images.shape[-3:])
|
50 |
images = pipeline.numpy_to_pil(images)
|