Spaces:
Running
Running
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -155,9 +155,9 @@ def mock_update_live_preview(image, bbox_x1, bbox_y1, bbox_x2, bbox_y2, mode):
|
|
| 155 |
return create_preview_image(image, bbox_coords, mode)
|
| 156 |
|
| 157 |
def mock_process_image_upload(image):
|
| 158 |
-
"""Mock für Bild-Upload: Setzt BBox in der Mitte
|
| 159 |
if not image:
|
| 160 |
-
return None, 100,
|
| 161 |
|
| 162 |
w, h = image.size
|
| 163 |
bbox_size = min(w, h) * 0.3
|
|
@@ -168,9 +168,8 @@ def mock_process_image_upload(image):
|
|
| 168 |
|
| 169 |
print(f"📐 Bildgröße erkannt: {w}x{h} -> BBox: {int(x1)}-{int(x2)}, {int(y1)}-{int(y2)}")
|
| 170 |
|
| 171 |
-
|
| 172 |
-
preview
|
| 173 |
-
return preview, int(x1), int(x2), int(y1), int(y2) # x1, x2, y1, y2
|
| 174 |
|
| 175 |
def mock_update_slider_for_image(image):
|
| 176 |
"""KORRIGIERT: Slider-Update mit getrennten Maxima für Breite und Höhe"""
|
|
@@ -183,17 +182,16 @@ def mock_update_slider_for_image(image):
|
|
| 183 |
)
|
| 184 |
|
| 185 |
w, h = image.size
|
| 186 |
-
# JEDER Slider bekommt sein eigenes Maximum
|
| 187 |
max_x = min(w, MAX_IMAGE_SIZE)
|
| 188 |
max_y = min(h, MAX_IMAGE_SIZE)
|
| 189 |
|
| 190 |
print(f"📐 Slider-Maxima gesetzt: X={max_x}, Y={max_y} (Bild: {w}x{h})")
|
| 191 |
|
| 192 |
return (
|
| 193 |
-
gr.update(maximum=max_x), # bbox_x1
|
| 194 |
-
gr.update(maximum=max_y), # bbox_y1
|
| 195 |
-
gr.update(maximum=max_x), # bbox_x2
|
| 196 |
-
gr.update(maximum=max_y), # bbox_y2
|
| 197 |
)
|
| 198 |
|
| 199 |
def mock_update_model_settings(model_id):
|
|
@@ -233,21 +231,21 @@ def main_ui():
|
|
| 233 |
/* ===== INFO-BOXEN MIT GRÖßEREM TEXT ===== */
|
| 234 |
.info-box {
|
| 235 |
background: #f8fafc !important;
|
| 236 |
-
padding: 6px 10px !important;
|
| 237 |
border-radius: 4px !important;
|
| 238 |
border: 1px solid #e2e8f0 !important;
|
| 239 |
margin-bottom: 3px !important;
|
| 240 |
-
font-size: 12px !important;
|
| 241 |
line-height: 1.3 !important;
|
| 242 |
-
height: auto !important;
|
| 243 |
-
min-height: 40px !important;
|
| 244 |
-
color: #475569 !important;
|
| 245 |
display: block !important;
|
| 246 |
text-align: left !important;
|
| 247 |
font-family: 'Segoe UI', 'Monaco', monospace !important;
|
| 248 |
-
overflow: visible !important;
|
| 249 |
-
white-space: normal !important;
|
| 250 |
-
word-wrap: break-word !important;
|
| 251 |
}
|
| 252 |
|
| 253 |
/* Code in Info-Boxen größer */
|
|
@@ -255,9 +253,9 @@ def main_ui():
|
|
| 255 |
background: #ffffff !important;
|
| 256 |
padding: 2px 4px !important;
|
| 257 |
border-radius: 3px !important;
|
| 258 |
-
font-size: 11px !important;
|
| 259 |
border: 1px solid #e2e8f0 !important;
|
| 260 |
-
color: #334155 !important;
|
| 261 |
font-weight: 500 !important;
|
| 262 |
}
|
| 263 |
|
|
@@ -283,13 +281,11 @@ def main_ui():
|
|
| 283 |
|
| 284 |
/* ===== VISUELLE HIERARCHIE ===== */
|
| 285 |
.gr-column:first-child .info-box {
|
| 286 |
-
|
| 287 |
-
background: #f0f9ff !important;
|
| 288 |
}
|
| 289 |
|
| 290 |
.gr-column:last-child .info-box {
|
| 291 |
-
|
| 292 |
-
background: #fef2f2 !important;
|
| 293 |
}
|
| 294 |
|
| 295 |
.model-info-box {
|
|
@@ -440,7 +436,11 @@ def main_ui():
|
|
| 440 |
with gr.Row():
|
| 441 |
gr.Markdown("### 📐 Bildelementbereich anpassen")
|
| 442 |
|
| 443 |
-
# SLIDER
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
with gr.Row():
|
| 445 |
with gr.Column():
|
| 446 |
bbox_x1 = gr.Slider(
|
|
@@ -479,7 +479,6 @@ def main_ui():
|
|
| 479 |
placeholder="photorealistic coastal beach, keep person unchanged...",
|
| 480 |
lines=2,
|
| 481 |
label="🎯 Transformations-Prompt",
|
| 482 |
-
#value="change background to beach",
|
| 483 |
elem_classes=["prompt-box"]
|
| 484 |
)
|
| 485 |
with gr.Column():
|
|
@@ -491,7 +490,6 @@ def main_ui():
|
|
| 491 |
placeholder="blurry face, deformed anatomy...",
|
| 492 |
lines=2,
|
| 493 |
label="🚫 Negativ-Prompt",
|
| 494 |
-
#value="blurry, ugly",
|
| 495 |
elem_classes=["prompt-box"]
|
| 496 |
)
|
| 497 |
|
|
@@ -512,10 +510,8 @@ def main_ui():
|
|
| 512 |
label="🎛️ Prompt-Stärke (guidance)"
|
| 513 |
)
|
| 514 |
|
| 515 |
-
|
| 516 |
transform_btn = gr.Button("🔄 Mock-Bild transformieren", variant="primary")
|
| 517 |
|
| 518 |
-
|
| 519 |
with gr.Row():
|
| 520 |
img_output = gr.Image(
|
| 521 |
label="✨ Transformiertes Mock-Bild",
|
|
@@ -552,7 +548,7 @@ def main_ui():
|
|
| 552 |
show_download_button=False
|
| 553 |
)
|
| 554 |
|
| 555 |
-
#
|
| 556 |
coordinate_inputs = [img_input, bbox_x1, bbox_y1, bbox_x2, bbox_y2, mode_radio]
|
| 557 |
|
| 558 |
img_input.upload(
|
|
|
|
| 155 |
return create_preview_image(image, bbox_coords, mode)
|
| 156 |
|
| 157 |
def mock_process_image_upload(image):
|
| 158 |
+
"""Mock für Bild-Upload: Setzt BBox in der Mitte"""
|
| 159 |
if not image:
|
| 160 |
+
return None, 100, 100, 300, 300 # x1, y1, x2, y2
|
| 161 |
|
| 162 |
w, h = image.size
|
| 163 |
bbox_size = min(w, h) * 0.3
|
|
|
|
| 168 |
|
| 169 |
print(f"📐 Bildgröße erkannt: {w}x{h} -> BBox: {int(x1)}-{int(x2)}, {int(y1)}-{int(y2)}")
|
| 170 |
|
| 171 |
+
preview = mock_update_live_preview(image, x1, y1, x2, y2, "environment_change")
|
| 172 |
+
return preview, int(x1), int(y1), int(x2), int(y2) # x1, y1, x2, y2
|
|
|
|
| 173 |
|
| 174 |
def mock_update_slider_for_image(image):
|
| 175 |
"""KORRIGIERT: Slider-Update mit getrennten Maxima für Breite und Höhe"""
|
|
|
|
| 182 |
)
|
| 183 |
|
| 184 |
w, h = image.size
|
|
|
|
| 185 |
max_x = min(w, MAX_IMAGE_SIZE)
|
| 186 |
max_y = min(h, MAX_IMAGE_SIZE)
|
| 187 |
|
| 188 |
print(f"📐 Slider-Maxima gesetzt: X={max_x}, Y={max_y} (Bild: {w}x{h})")
|
| 189 |
|
| 190 |
return (
|
| 191 |
+
gr.update(maximum=max_x), # bbox_x1: linke Kante max = Bildbreite
|
| 192 |
+
gr.update(maximum=max_y), # bbox_y1: obere Kante max = Bildhöhe
|
| 193 |
+
gr.update(maximum=max_x), # bbox_x2: rechte Kante max = Bildbreite
|
| 194 |
+
gr.update(maximum=max_y), # bbox_y2: untere Kante max = Bildhöhe
|
| 195 |
)
|
| 196 |
|
| 197 |
def mock_update_model_settings(model_id):
|
|
|
|
| 231 |
/* ===== INFO-BOXEN MIT GRÖßEREM TEXT ===== */
|
| 232 |
.info-box {
|
| 233 |
background: #f8fafc !important;
|
| 234 |
+
padding: 6px 10px !important;
|
| 235 |
border-radius: 4px !important;
|
| 236 |
border: 1px solid #e2e8f0 !important;
|
| 237 |
margin-bottom: 3px !important;
|
| 238 |
+
font-size: 12px !important;
|
| 239 |
line-height: 1.3 !important;
|
| 240 |
+
height: auto !important;
|
| 241 |
+
min-height: 40px !important;
|
| 242 |
+
color: #475569 !important;
|
| 243 |
display: block !important;
|
| 244 |
text-align: left !important;
|
| 245 |
font-family: 'Segoe UI', 'Monaco', monospace !important;
|
| 246 |
+
overflow: visible !important;
|
| 247 |
+
white-space: normal !important;
|
| 248 |
+
word-wrap: break-word !important;
|
| 249 |
}
|
| 250 |
|
| 251 |
/* Code in Info-Boxen größer */
|
|
|
|
| 253 |
background: #ffffff !important;
|
| 254 |
padding: 2px 4px !important;
|
| 255 |
border-radius: 3px !important;
|
| 256 |
+
font-size: 11px !important;
|
| 257 |
border: 1px solid #e2e8f0 !important;
|
| 258 |
+
color: #334155 !important;
|
| 259 |
font-weight: 500 !important;
|
| 260 |
}
|
| 261 |
|
|
|
|
| 281 |
|
| 282 |
/* ===== VISUELLE HIERARCHIE ===== */
|
| 283 |
.gr-column:first-child .info-box {
|
| 284 |
+
background: #f0f9ff !important; /* KEIN border-left mehr! */
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
.gr-column:last-child .info-box {
|
| 288 |
+
background: #fef2f2 !important; /* KEIN border-left mehr! */
|
|
|
|
| 289 |
}
|
| 290 |
|
| 291 |
.model-info-box {
|
|
|
|
| 436 |
with gr.Row():
|
| 437 |
gr.Markdown("### 📐 Bildelementbereich anpassen")
|
| 438 |
|
| 439 |
+
# SLIDER KORRIGIERT - Jetzt korrekte Zuordnung:
|
| 440 |
+
# Oben links: linke Kante (x1)
|
| 441 |
+
# Oben rechts: obere Kante (y1)
|
| 442 |
+
# Unten links: rechte Kante (x2)
|
| 443 |
+
# Unten rechts: untere Kante (y2)
|
| 444 |
with gr.Row():
|
| 445 |
with gr.Column():
|
| 446 |
bbox_x1 = gr.Slider(
|
|
|
|
| 479 |
placeholder="photorealistic coastal beach, keep person unchanged...",
|
| 480 |
lines=2,
|
| 481 |
label="🎯 Transformations-Prompt",
|
|
|
|
| 482 |
elem_classes=["prompt-box"]
|
| 483 |
)
|
| 484 |
with gr.Column():
|
|
|
|
| 490 |
placeholder="blurry face, deformed anatomy...",
|
| 491 |
lines=2,
|
| 492 |
label="🚫 Negativ-Prompt",
|
|
|
|
| 493 |
elem_classes=["prompt-box"]
|
| 494 |
)
|
| 495 |
|
|
|
|
| 510 |
label="🎛️ Prompt-Stärke (guidance)"
|
| 511 |
)
|
| 512 |
|
|
|
|
| 513 |
transform_btn = gr.Button("🔄 Mock-Bild transformieren", variant="primary")
|
| 514 |
|
|
|
|
| 515 |
with gr.Row():
|
| 516 |
img_output = gr.Image(
|
| 517 |
label="✨ Transformiertes Mock-Bild",
|
|
|
|
| 548 |
show_download_button=False
|
| 549 |
)
|
| 550 |
|
| 551 |
+
# KORREKT: coordinate_inputs in der richtigen Reihenfolge (x1, y1, x2, y2)
|
| 552 |
coordinate_inputs = [img_input, bbox_x1, bbox_y1, bbox_x2, bbox_y2, mode_radio]
|
| 553 |
|
| 554 |
img_input.upload(
|