Spaces:
Runtime error
Runtime error
Aguilar Elizondo commited on
Commit ·
4c43ee2
1
Parent(s): 5c2a4fb
Remove all gr.Progress() to fix JSON schema bug
Browse files
app.py
CHANGED
|
@@ -39,8 +39,7 @@ def enhance_image_gradio(
|
|
| 39 |
guidance_scale: float = 5.5,
|
| 40 |
custom_prompt: str = "",
|
| 41 |
use_upscaler: bool = True,
|
| 42 |
-
use_postprocess: bool = True
|
| 43 |
-
progress=gr.Progress()
|
| 44 |
) -> Image.Image:
|
| 45 |
"""
|
| 46 |
Enhance architectural image using AI pipeline
|
|
@@ -52,22 +51,21 @@ def enhance_image_gradio(
|
|
| 52 |
custom_prompt: Optional custom prompt
|
| 53 |
use_upscaler: Apply upscaling
|
| 54 |
use_postprocess: Apply post-processing
|
| 55 |
-
progress: Gradio progress tracker
|
| 56 |
|
| 57 |
Returns:
|
| 58 |
Enhanced PIL Image
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
# Initialize models
|
| 62 |
-
|
| 63 |
initialize_models()
|
| 64 |
|
| 65 |
# Step 1: AI Enhancement
|
| 66 |
-
|
| 67 |
|
| 68 |
prompt = custom_prompt if custom_prompt else settings.DEFAULT_PROMPT
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
enhanced = pipeline_manager.run_inference(
|
| 73 |
image=input_image,
|
|
@@ -78,37 +76,26 @@ def enhance_image_gradio(
|
|
| 78 |
num_inference_steps=30
|
| 79 |
)
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
# Step 2: Optional Upscaling
|
| 84 |
if use_upscaler:
|
| 85 |
-
|
| 86 |
enhanced = upscale_image(enhanced, scale=2)
|
| 87 |
-
|
| 88 |
|
| 89 |
# Step 3: Optional Post-processing
|
| 90 |
if use_postprocess:
|
| 91 |
-
|
| 92 |
enhanced = postprocess_image(
|
| 93 |
enhanced,
|
| 94 |
clahe=True,
|
| 95 |
sharpen=1.0,
|
| 96 |
color_enhance=1.1
|
| 97 |
)
|
| 98 |
-
|
| 99 |
|
| 100 |
-
|
| 101 |
-
if use_postprocess:
|
| 102 |
-
progress(0.9, desc="Applying final touches...")
|
| 103 |
-
enhanced = postprocess_image(
|
| 104 |
-
enhanced,
|
| 105 |
-
clahe=True,
|
| 106 |
-
sharpen=1.0,
|
| 107 |
-
color_enhance=1.1
|
| 108 |
-
)
|
| 109 |
-
progress(0.95, desc="Post-processing complete!")
|
| 110 |
-
|
| 111 |
-
progress(1.0, desc="Done!")
|
| 112 |
return enhanced
|
| 113 |
|
| 114 |
except Exception as e:
|
|
|
|
| 39 |
guidance_scale: float = 5.5,
|
| 40 |
custom_prompt: str = "",
|
| 41 |
use_upscaler: bool = True,
|
| 42 |
+
use_postprocess: bool = True
|
|
|
|
| 43 |
) -> Image.Image:
|
| 44 |
"""
|
| 45 |
Enhance architectural image using AI pipeline
|
|
|
|
| 51 |
custom_prompt: Optional custom prompt
|
| 52 |
use_upscaler: Apply upscaling
|
| 53 |
use_postprocess: Apply post-processing
|
|
|
|
| 54 |
|
| 55 |
Returns:
|
| 56 |
Enhanced PIL Image
|
| 57 |
"""
|
| 58 |
try:
|
| 59 |
# Initialize models
|
| 60 |
+
logger.info("Loading models...")
|
| 61 |
initialize_models()
|
| 62 |
|
| 63 |
# Step 1: AI Enhancement
|
| 64 |
+
logger.info("Preprocessing image...")
|
| 65 |
|
| 66 |
prompt = custom_prompt if custom_prompt else settings.DEFAULT_PROMPT
|
| 67 |
|
| 68 |
+
logger.info("Enhancing with AI (this may take a few minutes)...")
|
| 69 |
|
| 70 |
enhanced = pipeline_manager.run_inference(
|
| 71 |
image=input_image,
|
|
|
|
| 76 |
num_inference_steps=30
|
| 77 |
)
|
| 78 |
|
| 79 |
+
logger.info("AI enhancement complete!")
|
| 80 |
|
| 81 |
# Step 2: Optional Upscaling
|
| 82 |
if use_upscaler:
|
| 83 |
+
logger.info("Upscaling image...")
|
| 84 |
enhanced = upscale_image(enhanced, scale=2)
|
| 85 |
+
logger.info("Upscaling complete!")
|
| 86 |
|
| 87 |
# Step 3: Optional Post-processing
|
| 88 |
if use_postprocess:
|
| 89 |
+
logger.info("Applying final touches...")
|
| 90 |
enhanced = postprocess_image(
|
| 91 |
enhanced,
|
| 92 |
clahe=True,
|
| 93 |
sharpen=1.0,
|
| 94 |
color_enhance=1.1
|
| 95 |
)
|
| 96 |
+
logger.info("Post-processing complete!")
|
| 97 |
|
| 98 |
+
logger.info("Enhancement process complete!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
return enhanced
|
| 100 |
|
| 101 |
except Exception as e:
|