Spaces:
Running
Running
jocoandonob
commited on
Commit
·
a9e2c2b
1
Parent(s):
2a6c924
issue fix
Browse files
app.py
CHANGED
|
@@ -129,7 +129,6 @@ def generate_community_image(prompt, model_name, seed, num_steps, guidance_scale
|
|
| 129 |
base_model_id,
|
| 130 |
torch_dtype=dtype,
|
| 131 |
use_safetensors=True,
|
| 132 |
-
variant="fp16" if device == "cuda" else None
|
| 133 |
).to(device)
|
| 134 |
|
| 135 |
pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
|
|
@@ -297,17 +296,15 @@ def inpaint_image(prompt, init_image, mask_image, seed, num_steps, guidance_scal
|
|
| 297 |
generator=generator,
|
| 298 |
).images[0]
|
| 299 |
|
| 300 |
-
# Create a grid of the original image, mask, and result
|
| 301 |
-
grid = make_image_grid([init_image, mask_image, image], rows=1, cols=3)
|
| 302 |
-
|
| 303 |
# Cleanup
|
| 304 |
del pipe
|
| 305 |
cleanup_memory()
|
| 306 |
|
| 307 |
-
|
|
|
|
| 308 |
except Exception as e:
|
| 309 |
cleanup_memory()
|
| 310 |
-
return None, f"Error generating image: {str(e)}"
|
| 311 |
|
| 312 |
def generate_animation(prompt, seed, num_steps, guidance_scale, eta, num_frames, motion_scale):
|
| 313 |
try:
|
|
@@ -418,9 +415,13 @@ with gr.Blocks(title="TCD-SDXL Image Generator") as demo:
|
|
| 418 |
inpaint_eta = gr.Slider(minimum=0, maximum=1, value=0.3, label="Eta")
|
| 419 |
inpaint_strength = gr.Slider(minimum=0, maximum=1, value=0.99, label="Strength")
|
| 420 |
inpaint_button = gr.Button("Inpaint")
|
| 421 |
-
with gr.Column():
|
| 422 |
-
inpaint_output = gr.Image(label="Result (Original | Mask | Generated)")
|
| 423 |
inpaint_status = gr.Textbox(label="Status", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
|
| 425 |
inpaint_button.click(
|
| 426 |
fn=inpaint_image,
|
|
@@ -428,7 +429,8 @@ with gr.Blocks(title="TCD-SDXL Image Generator") as demo:
|
|
| 428 |
inpaint_prompt, init_image, mask_image, inpaint_seed,
|
| 429 |
inpaint_steps, inpaint_guidance, inpaint_eta, inpaint_strength
|
| 430 |
],
|
| 431 |
-
outputs
|
|
|
|
| 432 |
)
|
| 433 |
|
| 434 |
with gr.TabItem("Community Models"):
|
|
|
|
| 129 |
base_model_id,
|
| 130 |
torch_dtype=dtype,
|
| 131 |
use_safetensors=True,
|
|
|
|
| 132 |
).to(device)
|
| 133 |
|
| 134 |
pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
|
|
|
|
| 296 |
generator=generator,
|
| 297 |
).images[0]
|
| 298 |
|
|
|
|
|
|
|
|
|
|
| 299 |
# Cleanup
|
| 300 |
del pipe
|
| 301 |
cleanup_memory()
|
| 302 |
|
| 303 |
+
# Return individual images instead of a grid
|
| 304 |
+
return init_image, mask_image, image, "Image generated successfully!"
|
| 305 |
except Exception as e:
|
| 306 |
cleanup_memory()
|
| 307 |
+
return None, None, None, f"Error generating image: {str(e)}"
|
| 308 |
|
| 309 |
def generate_animation(prompt, seed, num_steps, guidance_scale, eta, num_frames, motion_scale):
|
| 310 |
try:
|
|
|
|
| 415 |
inpaint_eta = gr.Slider(minimum=0, maximum=1, value=0.3, label="Eta")
|
| 416 |
inpaint_strength = gr.Slider(minimum=0, maximum=1, value=0.99, label="Strength")
|
| 417 |
inpaint_button = gr.Button("Inpaint")
|
|
|
|
|
|
|
| 418 |
inpaint_status = gr.Textbox(label="Status", interactive=False)
|
| 419 |
+
with gr.Column():
|
| 420 |
+
# Display individual images in a row
|
| 421 |
+
with gr.Row():
|
| 422 |
+
inpaint_output_original = gr.Image(label="Original")
|
| 423 |
+
inpaint_output_mask = gr.Image(label="Mask")
|
| 424 |
+
inpaint_output_generated = gr.Image(label="Generated")
|
| 425 |
|
| 426 |
inpaint_button.click(
|
| 427 |
fn=inpaint_image,
|
|
|
|
| 429 |
inpaint_prompt, init_image, mask_image, inpaint_seed,
|
| 430 |
inpaint_steps, inpaint_guidance, inpaint_eta, inpaint_strength
|
| 431 |
],
|
| 432 |
+
# Map function outputs to individual image components and status
|
| 433 |
+
outputs=[inpaint_output_original, inpaint_output_mask, inpaint_output_generated, inpaint_status]
|
| 434 |
)
|
| 435 |
|
| 436 |
with gr.TabItem("Community Models"):
|