Update sam_module.py
Browse files- sam_module.py +1 -3
sam_module.py
CHANGED
|
@@ -174,7 +174,7 @@ def create_sam_mask(self, image, bbox_coords, mode):
|
|
| 174 |
# Fallback bei leerer Maske, der höchste Wert ist 0 also schwarz
|
| 175 |
if mask_array.max() == 0:
|
| 176 |
print(" ⚠️ Maske leer, erstelle rechteckige Fallback-Maske")
|
| 177 |
-
mask_array = np.zeros((
|
| 178 |
# BBox auf 512x512 skalieren für Fallback
|
| 179 |
scale_x = 512 / image.width
|
| 180 |
scale_y = 512 / image.height
|
|
@@ -200,8 +200,6 @@ def create_sam_mask(self, image, bbox_coords, mode):
|
|
| 200 |
|
| 201 |
|
| 202 |
# Maske invertieren (Person wird schwarz, Hintergrund weiß)
|
| 203 |
-
threshold = 0.5
|
| 204 |
-
mask_array = (mask_np > threshold).astype(np.uint8) * 255
|
| 205 |
mask_array = 255 - mask_array
|
| 206 |
print(" ✅ Maske invertiert (Person schwarz, Hintergrund
|
| 207 |
|
|
|
|
| 174 |
# Fallback bei leerer Maske, der höchste Wert ist 0 also schwarz
|
| 175 |
if mask_array.max() == 0:
|
| 176 |
print(" ⚠️ Maske leer, erstelle rechteckige Fallback-Maske")
|
| 177 |
+
mask_array = np.zeros((image.height, image.width), dtype=np.uint8)
|
| 178 |
# BBox auf 512x512 skalieren für Fallback
|
| 179 |
scale_x = 512 / image.width
|
| 180 |
scale_y = 512 / image.height
|
|
|
|
| 200 |
|
| 201 |
|
| 202 |
# Maske invertieren (Person wird schwarz, Hintergrund weiß)
|
|
|
|
|
|
|
| 203 |
mask_array = 255 - mask_array
|
| 204 |
print(" ✅ Maske invertiert (Person schwarz, Hintergrund
|
| 205 |
|