works hopefully
Browse files
app.py
CHANGED
|
@@ -40,6 +40,9 @@ compel = Compel(
|
|
| 40 |
MAX_SEED = np.iinfo(np.int32).max
|
| 41 |
MAX_IMAGE_SIZE = 900
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# 追加: Simple long prompt processing function
|
| 44 |
def process_long_prompt(prompt, negative_prompt=""):
|
| 45 |
"""Simple long prompt processing using Compel"""
|
|
@@ -78,8 +81,20 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 78 |
height=height,
|
| 79 |
generator=generator
|
| 80 |
).images[0]
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
# Fall back to standard processing
|
| 84 |
output_image = pipe(
|
| 85 |
prompt=prompt,
|
|
@@ -90,8 +105,18 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 90 |
height=height,
|
| 91 |
generator=generator
|
| 92 |
).images[0]
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
except RuntimeError as e:
|
| 96 |
print(f"Error during generation: {e}")
|
| 97 |
# Return a blank image with error message
|
|
@@ -182,7 +207,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 182 |
run_button.click(
|
| 183 |
fn=infer,
|
| 184 |
inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 185 |
-
outputs=[result],
|
| 186 |
|
| 187 |
)
|
| 188 |
|
|
|
|
| 40 |
MAX_SEED = np.iinfo(np.int32).max
|
| 41 |
MAX_IMAGE_SIZE = 900
|
| 42 |
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
# 追加: Simple long prompt processing function
|
| 47 |
def process_long_prompt(prompt, negative_prompt=""):
|
| 48 |
"""Simple long prompt processing using Compel"""
|
|
|
|
| 81 |
height=height,
|
| 82 |
generator=generator
|
| 83 |
).images[0]
|
| 84 |
+
seed = seed - 1
|
| 85 |
+
output_image2 = pipe(
|
| 86 |
+
prompt_embeds=conditioning[0:1],
|
| 87 |
+
pooled_prompt_embeds=pooled[0:1],
|
| 88 |
+
negative_prompt_embeds=conditioning[1:2],
|
| 89 |
+
negative_pooled_prompt_embeds=pooled[1:2],
|
| 90 |
+
guidance_scale=guidance_scale,
|
| 91 |
+
num_inference_steps=num_inference_steps,
|
| 92 |
+
width=width,
|
| 93 |
+
height=height,
|
| 94 |
+
generator=generator
|
| 95 |
+
).images[0]
|
| 96 |
+
return output_image, output_image2
|
| 97 |
+
|
| 98 |
# Fall back to standard processing
|
| 99 |
output_image = pipe(
|
| 100 |
prompt=prompt,
|
|
|
|
| 105 |
height=height,
|
| 106 |
generator=generator
|
| 107 |
).images[0]
|
| 108 |
+
seed = seed - 1
|
| 109 |
+
output_image2 = pipe(
|
| 110 |
+
prompt=prompt,
|
| 111 |
+
negative_prompt=negative_prompt,
|
| 112 |
+
guidance_scale=guidance_scale,
|
| 113 |
+
num_inference_steps=num_inference_steps,
|
| 114 |
+
width=width,
|
| 115 |
+
height=height,
|
| 116 |
+
generator=generator
|
| 117 |
+
).images[0]
|
| 118 |
+
return output_image, output_image2
|
| 119 |
+
|
| 120 |
except RuntimeError as e:
|
| 121 |
print(f"Error during generation: {e}")
|
| 122 |
# Return a blank image with error message
|
|
|
|
| 207 |
run_button.click(
|
| 208 |
fn=infer,
|
| 209 |
inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 210 |
+
outputs=[result, result2],
|
| 211 |
|
| 212 |
)
|
| 213 |
|