Saad0KH commited on
Commit
ab47e20
·
verified ·
1 Parent(s): b23b737

Update SegCloth.py

Browse files
Files changed (1) hide show
  1. SegCloth.py +15 -15
SegCloth.py CHANGED
@@ -52,21 +52,21 @@ def segment_clothing(img, clothes=["Hat", "Upper-clothes", "Skirt", "Pants", "Dr
52
  # Application du masque sur l'image vide
53
  empty_image.paste(segmented_part, mask=mask_image)
54
 
55
- # Déterminer la bounding box du masque
56
- bbox = mask_image.getbbox()
57
- if bbox:
58
- # Ajouter la marge autour de la bounding box
59
- left, top, right, bottom = bbox
60
- left = max(0, left - margin)
61
- top = max(0, top - margin)
62
- right = min(img.width, right + margin)
63
- bottom = min(img.height, bottom + margin)
64
-
65
- # Recadrer l'image à la taille du masque avec la marge
66
- cropped_image = empty_image.crop((left, top, right, bottom))
67
-
68
- # Vérifier si l'image recadrée est significative
69
- if is_image_significant(cropped_image):
70
  # Encodage de l'image recadrée en base64
71
  imageBase64 = encode_image_to_base64(cropped_image)
72
  result_images.append(imageBase64)
 
52
  # Application du masque sur l'image vide
53
  empty_image.paste(segmented_part, mask=mask_image)
54
 
55
+ # Vérifier si l'image est significative avant le recadrage
56
+ if is_image_significant(empty_image):
57
+ # Déterminer la bounding box du masque
58
+ bbox = mask_image.getbbox()
59
+ if bbox:
60
+ # Ajouter la marge autour de la bounding box
61
+ left, top, right, bottom = bbox
62
+ left = max(0, left - margin)
63
+ top = max(0, top - margin)
64
+ right = min(img.width, right + margin)
65
+ bottom = min(img.height, bottom + margin)
66
+
67
+ # Recadrer l'image à la taille du masque avec la marge
68
+ cropped_image = empty_image.crop((left, top, right, bottom))
69
+
70
  # Encodage de l'image recadrée en base64
71
  imageBase64 = encode_image_to_base64(cropped_image)
72
  result_images.append(imageBase64)