Update app.py
Browse files
app.py
CHANGED
|
@@ -232,6 +232,19 @@ def scale_image_and_mask_together(image, mask, target_size=512, bbox_coords=None
|
|
| 232 |
# mit Hilfe der Offsets wird nun die herunterskalierte BBox (entweder als Rechteck oder als SAM-Maske)
|
| 233 |
# in das Graustufenbild eingefügt. Das Padding ergibt sich aus dem Graustufenbild!
|
| 234 |
padded_mask.paste(scaled_mask, (x_offset, y_offset))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
# WICHTIG: Speichere alle Informationen für späteres Compositing
|
| 237 |
padding_info = {
|
|
|
|
| 232 |
# mit Hilfe der Offsets wird nun die herunterskalierte BBox (entweder als Rechteck oder als SAM-Maske)
|
| 233 |
# in das Graustufenbild eingefügt. Das Padding ergibt sich aus dem Graustufenbild!
|
| 234 |
padded_mask.paste(scaled_mask, (x_offset, y_offset))
|
| 235 |
+
|
| 236 |
+
#
|
| 237 |
+
scaled_bbox = None
|
| 238 |
+
if bbox_coords and all(c is not None for c in bbox_coords):
|
| 239 |
+
x1, y1, x2, y2 = bbox_coords
|
| 240 |
+
scaled_bbox = (
|
| 241 |
+
int(x1 * scale) + x_offset, # Einmalige, konsistente Berechnung
|
| 242 |
+
int(y1 * scale) + y_offset,
|
| 243 |
+
int(x2 * scale) + x_offset,
|
| 244 |
+
int(y2 * scale) + y_offset
|
| 245 |
+
)
|
| 246 |
+
print(f"📐 Skalierte BBox gespeichert: {scaled_bbox} (von {bbox_coords})")
|
| 247 |
+
|
| 248 |
|
| 249 |
# WICHTIG: Speichere alle Informationen für späteres Compositing
|
| 250 |
padding_info = {
|