progress bar fix
Browse files
app.py
CHANGED
|
@@ -203,9 +203,18 @@ def generate_image(
|
|
| 203 |
|
| 204 |
print(f"Starting generation with {num_inference_steps} steps...")
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
# Generate image
|
| 207 |
with torch.inference_mode():
|
| 208 |
-
result = pipeline(
|
|
|
|
|
|
|
|
|
|
| 209 |
image = result.images[0]
|
| 210 |
|
| 211 |
print("Generation complete!")
|
|
@@ -260,7 +269,7 @@ with gr.Blocks(
|
|
| 260 |
label="Prompt",
|
| 261 |
placeholder="Describe the image you want to generate...",
|
| 262 |
lines=4,
|
| 263 |
-
value="
|
| 264 |
)
|
| 265 |
|
| 266 |
image_input = gr.Image(
|
|
|
|
| 203 |
|
| 204 |
print(f"Starting generation with {num_inference_steps} steps...")
|
| 205 |
|
| 206 |
+
# Custom callback for progress updates
|
| 207 |
+
def progress_callback(pipe, step, timestep, callback_kwargs):
|
| 208 |
+
progress((0.2 + (step / num_inference_steps) * 0.75),
|
| 209 |
+
desc=f"Generating... Step {step}/{num_inference_steps}")
|
| 210 |
+
return callback_kwargs
|
| 211 |
+
|
| 212 |
# Generate image
|
| 213 |
with torch.inference_mode():
|
| 214 |
+
result = pipeline(
|
| 215 |
+
**pipe_kwargs,
|
| 216 |
+
callback_on_step_end=progress_callback,
|
| 217 |
+
)
|
| 218 |
image = result.images[0]
|
| 219 |
|
| 220 |
print("Generation complete!")
|
|
|
|
| 269 |
label="Prompt",
|
| 270 |
placeholder="Describe the image you want to generate...",
|
| 271 |
lines=4,
|
| 272 |
+
value="A cozy coffee shop scene on a rainy afternoon, warm lighting streaming through large windows with raindrops, a steaming cup of coffee on a wooden table with latte art, blurred background showing bookshelves and soft bokeh lights, photorealistic, cinematic composition, shallow depth of field"
|
| 273 |
)
|
| 274 |
|
| 275 |
image_input = gr.Image(
|