Update app.py
Browse files
app.py
CHANGED
|
@@ -233,6 +233,18 @@ def scale_image_and_mask_together(image, mask, target_size=512, bbox_coords=None
|
|
| 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 = {
|
| 238 |
'x_offset': x_offset,
|
|
@@ -244,6 +256,7 @@ def scale_image_and_mask_together(image, mask, target_size=512, bbox_coords=None
|
|
| 244 |
'scale_factor': scale,
|
| 245 |
'target_size': target_size,
|
| 246 |
'original_bbox': bbox_coords,
|
|
|
|
| 247 |
'mode': mode
|
| 248 |
}
|
| 249 |
|
|
|
|
| 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 |
+
# Hiermit wird die tranformierte BBox=BBox skaliert + Padding berechnet
|
| 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 |
# WICHTIG: Speichere alle Informationen für späteres Compositing
|
| 249 |
padding_info = {
|
| 250 |
'x_offset': x_offset,
|
|
|
|
| 256 |
'scale_factor': scale,
|
| 257 |
'target_size': target_size,
|
| 258 |
'original_bbox': bbox_coords,
|
| 259 |
+
'scaled_bbox': scaled_bbox,
|
| 260 |
'mode': mode
|
| 261 |
}
|
| 262 |
|