Spaces:
Runtime error
Runtime error
Aguilar Elizondo commited on
Commit ·
ed8c1f8
1
Parent(s): 5c463fb
Add custom prompt field for user input
Browse files
app.py
CHANGED
|
@@ -34,6 +34,7 @@ def enhance_image_simple(
|
|
| 34 |
input_image: Image.Image,
|
| 35 |
strength: float,
|
| 36 |
guidance_scale: float,
|
|
|
|
| 37 |
use_upscaler: bool,
|
| 38 |
use_postprocess: bool,
|
| 39 |
progress=gr.Progress()
|
|
@@ -53,6 +54,13 @@ def enhance_image_simple(
|
|
| 53 |
logger.error(f"Model initialization failed: {e}", exc_info=True)
|
| 54 |
raise ValueError(f"Failed to load AI models: {str(e)}")
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Step 1: AI Enhancement
|
| 57 |
progress(0.3, desc="Applying AI enhancement (this may take several minutes on CPU)...")
|
| 58 |
try:
|
|
@@ -64,7 +72,7 @@ def enhance_image_simple(
|
|
| 64 |
|
| 65 |
enhanced = pipeline_manager.enhance(
|
| 66 |
image=input_image,
|
| 67 |
-
prompt=
|
| 68 |
negative_prompt="blurry, low quality, distorted, ugly, bad architecture",
|
| 69 |
strength=strength,
|
| 70 |
guidance_scale=guidance_scale,
|
|
@@ -113,9 +121,15 @@ iface = gr.Interface(
|
|
| 113 |
fn=enhance_image_simple,
|
| 114 |
inputs=[
|
| 115 |
gr.Image(label="Input Image", type="pil"),
|
| 116 |
-
gr.Slider(0.1, 0.8, value=0.3, step=0.05, label="Strength"),
|
| 117 |
-
gr.Slider(1.0, 15.0, value=5.5, step=0.5, label="Guidance Scale"),
|
| 118 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
gr.Checkbox(label="Enable Post-Processing", value=True)
|
| 120 |
],
|
| 121 |
outputs=gr.Image(label="Enhanced Image", type="pil"),
|
|
|
|
| 34 |
input_image: Image.Image,
|
| 35 |
strength: float,
|
| 36 |
guidance_scale: float,
|
| 37 |
+
custom_prompt: str,
|
| 38 |
use_upscaler: bool,
|
| 39 |
use_postprocess: bool,
|
| 40 |
progress=gr.Progress()
|
|
|
|
| 54 |
logger.error(f"Model initialization failed: {e}", exc_info=True)
|
| 55 |
raise ValueError(f"Failed to load AI models: {str(e)}")
|
| 56 |
|
| 57 |
+
# Build prompt
|
| 58 |
+
base_prompt = "professional architectural photography, highly detailed, 8k, photorealistic"
|
| 59 |
+
if custom_prompt and custom_prompt.strip():
|
| 60 |
+
final_prompt = f"{base_prompt}, {custom_prompt.strip()}"
|
| 61 |
+
else:
|
| 62 |
+
final_prompt = base_prompt
|
| 63 |
+
|
| 64 |
# Step 1: AI Enhancement
|
| 65 |
progress(0.3, desc="Applying AI enhancement (this may take several minutes on CPU)...")
|
| 66 |
try:
|
|
|
|
| 72 |
|
| 73 |
enhanced = pipeline_manager.enhance(
|
| 74 |
image=input_image,
|
| 75 |
+
prompt=final_prompt,
|
| 76 |
negative_prompt="blurry, low quality, distorted, ugly, bad architecture",
|
| 77 |
strength=strength,
|
| 78 |
guidance_scale=guidance_scale,
|
|
|
|
| 121 |
fn=enhance_image_simple,
|
| 122 |
inputs=[
|
| 123 |
gr.Image(label="Input Image", type="pil"),
|
| 124 |
+
gr.Slider(0.1, 0.8, value=0.3, step=0.05, label="Strength", info="Lower = more faithful to input, Higher = more creative"),
|
| 125 |
+
gr.Slider(1.0, 15.0, value=5.5, step=0.5, label="Guidance Scale", info="How closely to follow the prompt"),
|
| 126 |
+
gr.Textbox(
|
| 127 |
+
label="Additional Prompt (Optional)",
|
| 128 |
+
placeholder="e.g., modern minimalist, glass facade, sunset lighting...",
|
| 129 |
+
lines=2,
|
| 130 |
+
info="Add custom details to enhance specific aspects"
|
| 131 |
+
),
|
| 132 |
+
gr.Checkbox(label="Enable Upscaling (2x)", value=True),
|
| 133 |
gr.Checkbox(label="Enable Post-Processing", value=True)
|
| 134 |
],
|
| 135 |
outputs=gr.Image(label="Enhanced Image", type="pil"),
|