Astridkraft commited on
Commit
d02ccbc
·
verified ·
1 Parent(s): 34665ba

Update sam_module.py

Browse files
Files changed (1) hide show
  1. sam_module.py +7 -3
sam_module.py CHANGED
@@ -189,15 +189,19 @@ def create_sam_mask(self, image, bbox_coords, mode):
189
  # Fallback bei leerer Maske, der höchste Wert ist 0 also schwarz
190
  if mask_array.max() == 0:
191
  print(" ⚠️ Maske leer, erstelle rechteckige Fallback-Maske")
192
- mask_array = np.zeros((512, 512), dtype=np.uint8)
193
- # Erstellt ein 512x512 Bild mit weißem Hintergrund und schwarzem Rechteck
 
194
  scale_x = 512 / image.width
195
  scale_y = 512 / image.height
196
  fb_x1 = int(x1 * scale_x)
197
  fb_y1 = int(y1 * scale_y)
198
  fb_x2 = int(x2 * scale_x)
199
  fb_y2 = int(y2 * scale_y)
200
- cv2.rectangle(mask_array, (fb_x1, fb_y1), (fb_x2, fb_y2), 0, -1) #schwarze Person
 
 
 
201
 
202
  # Damit wird die Rohmaske für die UI-Anzeige gespeichert
203
  raw_mask_array = mask_array.copy()
 
189
  # Fallback bei leerer Maske, der höchste Wert ist 0 also schwarz
190
  if mask_array.max() == 0:
191
  print(" ⚠️ Maske leer, erstelle rechteckige Fallback-Maske")
192
+ mask_array = np.zeros((512, 512), dtype=np.uint8) * 255 #weiße 512x512-Maske
193
+
194
+ # Skaliere BBox auf 512x512
195
  scale_x = 512 / image.width
196
  scale_y = 512 / image.height
197
  fb_x1 = int(x1 * scale_x)
198
  fb_y1 = int(y1 * scale_y)
199
  fb_x2 = int(x2 * scale_x)
200
  fb_y2 = int(y2 * scale_y)
201
+
202
+ # Schwarzes Rechteck für Person
203
+ cv2.rectangle(mask_array, (fb_x1, fb_y1), (fb_x2, fb_y2), 0, -1)
204
+
205
 
206
  # Damit wird die Rohmaske für die UI-Anzeige gespeichert
207
  raw_mask_array = mask_array.copy()