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

Update sam_module.py

Browse files
Files changed (1) hide show
  1. sam_module.py +9 -9
sam_module.py CHANGED
@@ -154,11 +154,11 @@ def create_sam_mask(self, image, bbox_coords, mode):
154
  confidence_score * 0.1
155
  )
156
 
157
- print(f" 📊 STANDARD-SCORES für Maske {i+1}:")
158
- print(f" • BBox-Überlappung: {bbox_overlap_ratio:.3f}")
159
- print(f" • Zentrums-Distanz: {centroid_distance if 'centroid_distance' in locals() else 'N/A'}")
160
- print(f" • Flächen-Ratio: {area_ratio:.3f}")
161
- print(f" • GESAMTSCORE: {score:.3f}")
162
 
163
  if score > best_score:
164
  best_score = score
@@ -189,15 +189,15 @@ 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((image.height, image.width), dtype=np.uint8)
193
- # BBox auf 512x512 skalieren für Fallback
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), 255, -1)
201
 
202
  # Damit wird die Rohmaske für die UI-Anzeige gespeichert
203
  raw_mask_array = mask_array.copy()
@@ -216,7 +216,7 @@ def create_sam_mask(self, image, bbox_coords, mode):
216
 
217
  # Maske invertieren (Person wird schwarz, Hintergrund weiß)
218
  mask_array = 255 - mask_array
219
- print(" ✅ Maske invertiert (Person schwarz, Hintergrund
220
 
221
 
222
  # Weiße Punkte in der Person (schwarz) entfernen
 
154
  confidence_score * 0.1
155
  )
156
 
157
+ print(f" 📊 STANDARD-SCORES für Maske {i+1}:")
158
+ print(f" • BBox-Überlappung: {bbox_overlap_ratio:.3f}")
159
+ print(f" • Zentrums-Distanz: {centroid_distance if 'centroid_distance' in locals() else 'N/A'}")
160
+ print(f" • Flächen-Ratio: {area_ratio:.3f}")
161
+ print(f" • GESAMTSCORE: {score:.3f}")
162
 
163
  if score > best_score:
164
  best_score = score
 
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()
 
216
 
217
  # Maske invertieren (Person wird schwarz, Hintergrund weiß)
218
  mask_array = 255 - mask_array
219
+ print(" ✅ Maske invertiert (Person schwarz, Hintergrund weiß)")
220
 
221
 
222
  # Weiße Punkte in der Person (schwarz) entfernen