Update app.py
Browse files
app.py
CHANGED
|
@@ -362,24 +362,26 @@ def enhanced_composite_with_sam(original_image, inpaint_result, original_mask,
|
|
| 362 |
return final_image.convert("RGB")
|
| 363 |
|
| 364 |
|
| 365 |
-
#BBox
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
| 383 |
|
| 384 |
if bbox_in_512[2] > bbox_in_512[0] and bbox_in_512[3] > bbox_in_512[1]:
|
| 385 |
# Bearbeiteten Bereich aus dem 512×512-Ergebnis ausschneiden
|
|
|
|
| 362 |
return final_image.convert("RGB")
|
| 363 |
|
| 364 |
|
| 365 |
+
# Verwende gespeicherte BBox aus scaled_image_and_mask_together()
|
| 366 |
+
if 'scaled_bbox' in padding_info and padding_info['scaled_bbox'] is not None:
|
| 367 |
+
bbox_in_512 = padding_info['scaled_bbox'] # ← WICHTIG: Verwende die gespeicherte!
|
| 368 |
+
print(f"✅ Verwende gespeicherte BBox: {bbox_in_512}")
|
| 369 |
+
else:
|
| 370 |
+
#BBox-Koordinaten korrekt transformieren
|
| 371 |
+
#Die BBox-Koordinaten müssen vom Originalbild nach 512x512 transformiert werden
|
| 372 |
+
bbox_scaled = (
|
| 373 |
+
int(bbox_coords[0] * scale_factor),
|
| 374 |
+
int(bbox_coords[1] * scale_factor),
|
| 375 |
+
int(bbox_coords[2] * scale_factor),
|
| 376 |
+
int(bbox_coords[3] * scale_factor)
|
| 377 |
+
)
|
| 378 |
+
#Mit den Padding-Offsets wird bei nicht quadratischen 512x512 Bildern das Padding hinzugefügt
|
| 379 |
+
bbox_in_512 = (
|
| 380 |
+
bbox_scaled[0] + x_offset,
|
| 381 |
+
bbox_scaled[1] + y_offset,
|
| 382 |
+
bbox_scaled[2] + x_offset,
|
| 383 |
+
bbox_scaled[3] + y_offset
|
| 384 |
+
)
|
| 385 |
|
| 386 |
if bbox_in_512[2] > bbox_in_512[0] and bbox_in_512[3] > bbox_in_512[1]:
|
| 387 |
# Bearbeiteten Bereich aus dem 512×512-Ergebnis ausschneiden
|