Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ Hugging Face Spaces Script for Basic Stable Diffusion 1.5 Gradio App
|
|
| 4 |
Adapted from user's local script and HF Spaces template.
|
| 5 |
Supports Hub models and CPU/GPU selection based on available hardware.
|
| 6 |
Includes Attention Slicing optimization toggle.
|
|
|
|
| 7 |
"""
|
| 8 |
|
| 9 |
import gradio as gr
|
|
@@ -40,9 +41,8 @@ DEFAULT_HUB_MODELS = [
|
|
| 40 |
"runwayml/stable-diffusion-v1-5",
|
| 41 |
"SG161222/Realistic_Vision_V6.0_B1_noVAE", # Example popular 1.5 model
|
| 42 |
"nitrosocke/Ghibli-Diffusion",
|
| 43 |
-
"
|
| 44 |
-
"
|
| 45 |
-
"Yntec/RevAnimatedV2Rebirth"
|
| 46 |
# "CompVis/stable-diffusion-v1-4", # Example SD 1.4 model (might behave slightly differently)
|
| 47 |
# Add other diffusers-compatible SD1.5 models here
|
| 48 |
]
|
|
@@ -165,8 +165,7 @@ def infer(
|
|
| 165 |
seed, # From seed_input (now a Slider)
|
| 166 |
randomize_seed, # From randomize_seed_checkbox
|
| 167 |
enable_attention_slicing, # New input for the optimization toggle
|
| 168 |
-
#
|
| 169 |
-
progress=gr.Progress(), # <-- Corrected Progress initialization
|
| 170 |
):
|
| 171 |
"""Generates an image using the selected model and parameters on the chosen device."""
|
| 172 |
global current_pipeline, current_model_id, current_device_loaded, SCHEDULER_MAP, MAX_SEED
|
|
@@ -428,7 +427,8 @@ def infer(
|
|
| 428 |
generator=generator, # Pass the generator (which might be None)
|
| 429 |
# Pass progress object for tqdm tracking in Gradio
|
| 430 |
callback_steps=max(1, num_inference_steps_int // 20), # Update progress bar periodically
|
| 431 |
-
|
|
|
|
| 432 |
|
| 433 |
# Add VAE usage here if needed for specific models that require it
|
| 434 |
# vae=...
|
|
@@ -450,6 +450,7 @@ def infer(
|
|
| 450 |
except ValueError as ve:
|
| 451 |
# Handle specific value errors like invalid parameters
|
| 452 |
print(f"Parameter Error: {ve}")
|
|
|
|
| 453 |
raise gr.Error(f"Invalid Parameter: {ve}")
|
| 454 |
except Exception as e:
|
| 455 |
# Catch any other unexpected errors during generation
|
|
|
|
| 4 |
Adapted from user's local script and HF Spaces template.
|
| 5 |
Supports Hub models and CPU/GPU selection based on available hardware.
|
| 6 |
Includes Attention Slicing optimization toggle.
|
| 7 |
+
Corrected progress callback format.
|
| 8 |
"""
|
| 9 |
|
| 10 |
import gradio as gr
|
|
|
|
| 41 |
"runwayml/stable-diffusion-v1-5",
|
| 42 |
"SG161222/Realistic_Vision_V6.0_B1_noVAE", # Example popular 1.5 model
|
| 43 |
"nitrosocke/Ghibli-Diffusion",
|
| 44 |
+
"danyloylo/sd1.5-ghibli-style-05",
|
| 45 |
+
"Bilal326/SD_1.5_DragonWarriorV2"
|
|
|
|
| 46 |
# "CompVis/stable-diffusion-v1-4", # Example SD 1.4 model (might behave slightly differently)
|
| 47 |
# Add other diffusers-compatible SD1.5 models here
|
| 48 |
]
|
|
|
|
| 165 |
seed, # From seed_input (now a Slider)
|
| 166 |
randomize_seed, # From randomize_seed_checkbox
|
| 167 |
enable_attention_slicing, # New input for the optimization toggle
|
| 168 |
+
progress=gr.Progress(), # Corrected Progress initialization (removed track_tqdm=True)
|
|
|
|
| 169 |
):
|
| 170 |
"""Generates an image using the selected model and parameters on the chosen device."""
|
| 171 |
global current_pipeline, current_model_id, current_device_loaded, SCHEDULER_MAP, MAX_SEED
|
|
|
|
| 427 |
generator=generator, # Pass the generator (which might be None)
|
| 428 |
# Pass progress object for tqdm tracking in Gradio
|
| 429 |
callback_steps=max(1, num_inference_steps_int // 20), # Update progress bar periodically
|
| 430 |
+
# --- CORRECTED CALLBACK FORMAT ---
|
| 431 |
+
callback=lambda step, timestep, latents: progress((step, num_inference_steps_int), desc=f"Step {step}/{num_inference_steps_int}"),
|
| 432 |
|
| 433 |
# Add VAE usage here if needed for specific models that require it
|
| 434 |
# vae=...
|
|
|
|
| 450 |
except ValueError as ve:
|
| 451 |
# Handle specific value errors like invalid parameters
|
| 452 |
print(f"Parameter Error: {ve}")
|
| 453 |
+
# This is the line that was re-raising the error, it remains here.
|
| 454 |
raise gr.Error(f"Invalid Parameter: {ve}")
|
| 455 |
except Exception as e:
|
| 456 |
# Catch any other unexpected errors during generation
|