Update sam_module.py
Browse files- sam_module.py +18 -14
sam_module.py
CHANGED
|
@@ -951,24 +951,28 @@ def create_sam_mask(self, image, bbox_coords, mode):
|
|
| 951 |
elif 0.8 <= coverage_ratio <= 1.2:
|
| 952 |
print(f" ✅ OPTIMALE Gesichtsabdeckung ({coverage_ratio:.1%})")
|
| 953 |
|
| 954 |
-
# ============================================================
|
| 955 |
-
# FINALE AUSGABE FÜR GESICHTSMODUS
|
| 956 |
-
# ============================================================
|
| 957 |
-
if mode == "face_only_change" and crop_size is not None:
|
| 958 |
-
print(f"👤 Bei face_only_change: Crop={crop_size}×{crop_size}px, Heuristik-Score={best_score:.3f}")
|
| 959 |
-
print(f"👤 Kopfabdeckung: {coverage_ratio:.1%} der BBox")
|
| 960 |
-
|
| 961 |
-
|
| 962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 963 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 964 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 965 |
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
# Am Ende:
|
| 969 |
-
mask = Image.new("L", (512, 512), 128) # Platzhalter
|
| 970 |
-
raw_mask = mask.copy()
|
| 971 |
-
return mask, raw_mask
|
| 972 |
|
| 973 |
# ============================================================
|
| 974 |
# UNBEKANNTER MODUS
|
|
|
|
| 951 |
elif 0.8 <= coverage_ratio <= 1.2:
|
| 952 |
print(f" ✅ OPTIMALE Gesichtsabdeckung ({coverage_ratio:.1%})")
|
| 953 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 954 |
|
| 955 |
+
|
| 956 |
+
# Zurück zu PIL Image
|
| 957 |
+
mask = Image.fromarray(mask_array).convert("L")
|
| 958 |
+
raw_mask = Image.fromarray(raw_mask_array).convert("L")
|
| 959 |
|
| 960 |
+
print("#" * 80)
|
| 961 |
+
print(f"✅ SAM 2 SEGMENTIERUNG ABGESCHLOSSEN")
|
| 962 |
+
print(f"📐 Finale Maskengröße: {mask.size}")
|
| 963 |
+
print(f"🎛️ Verwendeter Modus: {mode}")
|
| 964 |
|
| 965 |
+
# ============================================================
|
| 966 |
+
# FINALE AUSGABE FÜR GESICHTSMODUS
|
| 967 |
+
# ============================================================
|
| 968 |
+
if crop_size is not None:
|
| 969 |
+
print(f"👤 Bei face_only_change: Crop={crop_size}×{crop_size}px, Heuristik-Score={best_score:.3f}")
|
| 970 |
+
print(f"👤 Kopfabdeckung: {coverage_ratio:.1%} der BBox")
|
| 971 |
+
|
| 972 |
+
print(f" DEBUG NACHHER - Min/Max: {mask_array.min()}/{mask_array.max()}, Typ: {mask_array.dtype}")
|
| 973 |
+
print("#" * 80)
|
| 974 |
|
| 975 |
+
return mask, raw_mask
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 976 |
|
| 977 |
# ============================================================
|
| 978 |
# UNBEKANNTER MODUS
|