Astridkraft commited on
Commit
5de16df
·
verified ·
1 Parent(s): 484ce52

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +66 -48
ui.py CHANGED
@@ -166,12 +166,14 @@ def mock_process_image_upload(image):
166
  x2 = x1 + bbox_size
167
  y2 = y1 + bbox_size * 1.2
168
 
 
 
169
  # KORREKTUR: x1, x2, y1, y2 Reihenfolge
170
  preview = mock_update_live_preview(image, x1, x2, y1, y2, "environment_change")
171
  return preview, int(x1), int(x2), int(y1), int(y2) # x1, x2, y1, y2
172
 
173
  def mock_update_slider_for_image(image):
174
- """Mock für Slider-Update"""
175
  if not image:
176
  return (
177
  gr.update(maximum=MAX_IMAGE_SIZE),
@@ -181,14 +183,17 @@ def mock_update_slider_for_image(image):
181
  )
182
 
183
  w, h = image.size
184
- max_val = min(max(w, h), MAX_IMAGE_SIZE)
 
 
 
 
185
 
186
- print(f"📐 Mock Slider-Maxima: {max_val}")
187
  return (
188
- gr.update(maximum=max_val),
189
- gr.update(maximum=max_val),
190
- gr.update(maximum=max_val),
191
- gr.update(maximum=max_val)
192
  )
193
 
194
  def mock_update_model_settings(model_id):
@@ -225,51 +230,50 @@ def main_ui():
225
  title="AI Image Generator - Mock Version",
226
  theme=gr.themes.Base(),
227
  css="""
228
- /* ===== DEZENTERE INFO-BOXEN (KLEINERE HÖHE) ===== */
229
  .info-box {
230
  background: #f8fafc !important;
231
- padding: 3px 6px !important; /* Noch weniger Padding */
232
- border-radius: 3px !important; /* Kleinere Rundung */
233
  border: 1px solid #e2e8f0 !important;
234
- margin-bottom: 1px !important; /* Minimaler Abstand */
235
- font-size: 10px !important; /* Kleinere Schrift */
236
- line-height: 1.1 !important;
237
- height: 28px !important; /* FESTE KLEINERE HÖHE */
238
- min-height: 28px !important; /* Feste Mindesthöhe */
239
- max-height: 28px !important; /* Feste Maximale Höhe */
240
- color: #64748b !important;
241
- display: flex !important; /* Flex für Zentrierung */
242
- align-items: center !important; /* Vertikal zentrieren */
243
  text-align: left !important;
244
- font-family: 'Segoe UI', monospace !important;
245
- overflow: hidden !important; /* Text wird abgeschnitten */
246
- white-space: nowrap !important; /* Kein Umbruch */
 
247
  }
248
 
249
- /* Code in Info-Boxen noch kleiner */
250
  .info-box code {
251
  background: #ffffff !important;
252
- padding: 1px 2px !important;
253
- border-radius: 2px !important;
254
- font-size: 9px !important;
255
  border: 1px solid #e2e8f0 !important;
256
- color: #475569 !important;
257
- font-weight: normal !important;
258
  }
259
 
260
- /* ===== TEXTBOXEN (FESTE HÖHE, KEINE DYNAMIK) ===== */
261
  .prompt-box textarea {
262
  min-height: 90px !important;
263
- max-height: 90px !important; /* Feste Höhe */
264
- height: 90px !important; /* Feste Höhe */
265
  border-radius: 6px !important;
266
  border: 2px solid #3b82f6 !important;
267
- padding: 10px !important;
268
  font-size: 14px !important;
269
  background: white !important;
270
  box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
271
- resize: vertical !important; /* Nur vertikales Resize erlauben */
272
- overflow-y: auto !important; /* Scrollen wenn nötig */
273
  }
274
 
275
  .prompt-box textarea:focus {
@@ -279,42 +283,56 @@ def main_ui():
279
 
280
  /* ===== VISUELLE HIERARCHIE ===== */
281
  .gr-column:first-child .info-box {
282
- border-left: 2px solid #3b82f6 !important; /* Dünnerer Rahmen */
283
  background: #f0f9ff !important;
284
  }
285
 
286
  .gr-column:last-child .info-box {
287
- border-left: 2px solid #ef4444 !important; /* Dünnerer Rahmen */
288
  background: #fef2f2 !important;
289
  }
290
 
291
  .model-info-box {
292
  background: #e8f4fd;
293
- padding: 10px;
294
  border-radius: 6px;
295
- margin: 8px 0;
296
- border-left: 3px solid #2196f3;
297
- font-size: 13px !important;
298
  }
299
 
300
  #generate-button {
301
  background-color: #0080FF !important;
302
  margin: 20px auto !important;
303
  width: 280px;
 
 
304
  }
305
 
306
  .radio-group {
307
  background: #f8f9fa;
308
- padding: 12px;
309
- border-radius: 6px;
310
- margin: 8px 0;
 
311
  }
312
 
313
  .status-message {
314
- padding: 8px;
315
- border-radius: 4px;
316
- margin: 8px 0;
317
- font-size: 13px;
 
 
 
 
 
 
 
 
 
 
 
318
  }
319
  """
320
  ) as demo:
@@ -422,7 +440,7 @@ def main_ui():
422
  with gr.Row():
423
  gr.Markdown("### 📐 Bildelementbereich anpassen")
424
 
425
- # SLIDER MIT DYNAMISCHEM MAXIMUM (4096 für große Bilder)
426
  with gr.Row():
427
  with gr.Column():
428
  bbox_x1 = gr.Slider(
 
166
  x2 = x1 + bbox_size
167
  y2 = y1 + bbox_size * 1.2
168
 
169
+ print(f"📐 Bildgröße erkannt: {w}x{h} -> BBox: {int(x1)}-{int(x2)}, {int(y1)}-{int(y2)}")
170
+
171
  # KORREKTUR: x1, x2, y1, y2 Reihenfolge
172
  preview = mock_update_live_preview(image, x1, x2, y1, y2, "environment_change")
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"""
177
  if not image:
178
  return (
179
  gr.update(maximum=MAX_IMAGE_SIZE),
 
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):
 
230
  title="AI Image Generator - Mock Version",
231
  theme=gr.themes.Base(),
232
  css="""
233
+ /* ===== INFO-BOXEN MIT GRÖßEREM TEXT ===== */
234
  .info-box {
235
  background: #f8fafc !important;
236
+ padding: 6px 10px !important; /* Mehr Padding für größeren Text */
237
+ border-radius: 4px !important;
238
  border: 1px solid #e2e8f0 !important;
239
+ margin-bottom: 3px !important;
240
+ font-size: 12px !important; /* GRÖßERE SCHRIFT (vorher 10px) */
241
+ line-height: 1.3 !important;
242
+ height: auto !important; /* Flexible Höhe für Text */
243
+ min-height: 40px !important; /* Höhere Mindesthöhe */
244
+ color: #475569 !important; /* Dunklerer Text für bessere Lesbarkeit */
245
+ display: block !important;
 
 
246
  text-align: left !important;
247
+ font-family: 'Segoe UI', 'Monaco', monospace !important;
248
+ overflow: visible !important; /* Text darf sichtbar sein */
249
+ white-space: normal !important; /* Textumbruch erlauben */
250
+ word-wrap: break-word !important; /* Lange Wörter umbrechen */
251
  }
252
 
253
+ /* Code in Info-Boxen größer */
254
  .info-box code {
255
  background: #ffffff !important;
256
+ padding: 2px 4px !important;
257
+ border-radius: 3px !important;
258
+ font-size: 11px !important; /* Größerer Code */
259
  border: 1px solid #e2e8f0 !important;
260
+ color: #334155 !important; /* Dunklerer Code */
261
+ font-weight: 500 !important;
262
  }
263
 
264
+ /* ===== TEXTBOXEN (FESTE HÖHE) ===== */
265
  .prompt-box textarea {
266
  min-height: 90px !important;
267
+ max-height: 90px !important;
268
+ height: 90px !important;
269
  border-radius: 6px !important;
270
  border: 2px solid #3b82f6 !important;
271
+ padding: 12px !important;
272
  font-size: 14px !important;
273
  background: white !important;
274
  box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
275
+ resize: vertical !important;
276
+ overflow-y: auto !important;
277
  }
278
 
279
  .prompt-box textarea:focus {
 
283
 
284
  /* ===== VISUELLE HIERARCHIE ===== */
285
  .gr-column:first-child .info-box {
286
+ border-left: 3px solid #3b82f6 !important;
287
  background: #f0f9ff !important;
288
  }
289
 
290
  .gr-column:last-child .info-box {
291
+ border-left: 3px solid #ef4444 !important;
292
  background: #fef2f2 !important;
293
  }
294
 
295
  .model-info-box {
296
  background: #e8f4fd;
297
+ padding: 12px;
298
  border-radius: 6px;
299
+ margin: 10px 0;
300
+ border-left: 4px solid #2196f3;
301
+ font-size: 14px !important;
302
  }
303
 
304
  #generate-button {
305
  background-color: #0080FF !important;
306
  margin: 20px auto !important;
307
  width: 280px;
308
+ font-size: 16px !important;
309
+ font-weight: 600 !important;
310
  }
311
 
312
  .radio-group {
313
  background: #f8f9fa;
314
+ padding: 15px;
315
+ border-radius: 8px;
316
+ margin: 10px 0;
317
+ font-size: 14px !important;
318
  }
319
 
320
  .status-message {
321
+ padding: 10px;
322
+ border-radius: 5px;
323
+ margin: 10px 0;
324
+ font-size: 14px;
325
+ background: #f0f9ff;
326
+ border-left: 4px solid #3b82f6;
327
+ }
328
+
329
+ /* Slider besser sichtbar */
330
+ .gr-slider {
331
+ margin: 8px 0 !important;
332
+ }
333
+
334
+ .gr-slider .wrap {
335
+ padding: 8px 0 !important;
336
  }
337
  """
338
  ) as demo:
 
440
  with gr.Row():
441
  gr.Markdown("### 📐 Bildelementbereich anpassen")
442
 
443
+ # SLIDER MIT DYNAMISCHEM MAXIMUM (getrennt für X und Y)
444
  with gr.Row():
445
  with gr.Column():
446
  bbox_x1 = gr.Slider(