Astridkraft commited on
Commit
5aabbfd
·
verified ·
1 Parent(s): 8133841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -419,12 +419,23 @@ def enhanced_composite_with_sam(original_image, inpaint_result, original_mask,
419
  # GaussianBlur erzeugt Graustufenwerte (0-255) statt binärer Maske (0 oder 255)
420
  #soft_mask ist eine Maske mit Zahlen. 255-weiß, 0-schwarz
421
  soft_mask = mask_cropped.filter(ImageFilter.GaussianBlur(3))
422
-
423
- print(f"🔍 Soft-Mask unique values PRE: {np.unique(np.array(soft_mask))[:20]}")
424
- print(f"🔍 Soft-Mask Min/Max: {np.array(soft_mask).min()}, {np.array(soft_mask).max()}")
425
-
426
  alpha_mask = soft_mask
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  # rgb_only ist das von Inpaint generierte reine Farbbild in Original-BBox-Größe
429
  rgb_only = edited_region_fullsize.convert("RGB")
430
 
 
419
  # GaussianBlur erzeugt Graustufenwerte (0-255) statt binärer Maske (0 oder 255)
420
  #soft_mask ist eine Maske mit Zahlen. 255-weiß, 0-schwarz
421
  soft_mask = mask_cropped.filter(ImageFilter.GaussianBlur(3))
 
 
 
 
422
  alpha_mask = soft_mask
423
 
424
+
425
+ # SAM-QUALITÄTS-CHECK (Minimum aber aussagekräftig)
426
+ alpha_array = np.array(alpha_mask)
427
+ total_pixels = alpha_array.size
428
+ face_pixels = np.sum(alpha_array > 200)
429
+ soft_pixels = np.sum((alpha_array > 0) & (alpha_array < 255))
430
+ face_percent = face_pixels / total_pixels * 100
431
+
432
+ print(f"📊 [SAM] Gesicht: {face_percent:.1f}%, Alpha: {alpha_array.min()}-{alpha_array.max()}")
433
+ if face_percent < 10:
434
+ print("❌ KRITISCH: Fast kein Gesicht!")
435
+ elif face_percent > 90:
436
+ print("⚠️ ZU VIEL: Fast ganze BBox!")
437
+
438
+
439
  # rgb_only ist das von Inpaint generierte reine Farbbild in Original-BBox-Größe
440
  rgb_only = edited_region_fullsize.convert("RGB")
441