Spaces:
Runtime error
Runtime error
Update SegCloth.py
Browse files- SegCloth.py +1 -8
SegCloth.py
CHANGED
@@ -7,11 +7,6 @@ import base64
|
|
7 |
# Initialisation du pipeline de segmentation
|
8 |
segmenter = pipeline(model="mattmdjaga/segformer_b2_clothes")
|
9 |
|
10 |
-
def encode_image_to_base64(image):
|
11 |
-
buffered = BytesIO()
|
12 |
-
image.save(buffered, format="PNG")
|
13 |
-
return base64.b64encode(buffered.getvalue()).decode('utf-8')
|
14 |
-
|
15 |
def is_image_significant(image, threshold=0.01):
|
16 |
"""
|
17 |
Vérifie si une image contient suffisamment de contenu non transparent.
|
@@ -67,8 +62,6 @@ def segment_clothing(img, clothes=["Hat", "Upper-clothes", "Skirt", "Pants", "Dr
|
|
67 |
# Recadrer l'image à la taille du masque avec la marge
|
68 |
cropped_image = empty_image.crop((left, top, right, bottom))
|
69 |
|
70 |
-
|
71 |
-
imageBase64 = encode_image_to_base64(cropped_image)
|
72 |
-
result_images.append(imageBase64)
|
73 |
|
74 |
return result_images
|
|
|
7 |
# Initialisation du pipeline de segmentation
|
8 |
segmenter = pipeline(model="mattmdjaga/segformer_b2_clothes")
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
def is_image_significant(image, threshold=0.01):
|
11 |
"""
|
12 |
Vérifie si une image contient suffisamment de contenu non transparent.
|
|
|
62 |
# Recadrer l'image à la taille du masque avec la marge
|
63 |
cropped_image = empty_image.crop((left, top, right, bottom))
|
64 |
|
65 |
+
result_images.append(cropped_image)
|
|
|
|
|
66 |
|
67 |
return result_images
|