Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from io import BytesIO
|
|
10 |
def get_segmentation_mask(image_url):
|
11 |
client = Client("facebook/sapiens-seg")
|
12 |
result = client.predict(image=handle_file(image_url), model_name="1b", api_name="/process_image")
|
13 |
-
return np.load(result[1]) # Result[
|
14 |
|
15 |
def process_image(image, categories_to_hide):
|
16 |
# Convert uploaded image to a PIL Image
|
@@ -26,7 +26,7 @@ def process_image(image, categories_to_hide):
|
|
26 |
"Clothes": [1, 12, 22, 8, 9, 17, 18], # Includes Shoes, Socks, Slippers
|
27 |
"Face": [2, 23, 24, 25, 26, 27], # Face Neck, Lips, Teeth, Tongue
|
28 |
"Hair": [3], # Hair
|
29 |
-
"Skin
|
30 |
}
|
31 |
|
32 |
# Convert image to numpy array (RGBA)
|
@@ -55,7 +55,7 @@ demo = gr.Interface(
|
|
55 |
inputs=[
|
56 |
gr.File(label="Upload an Image"),
|
57 |
gr.CheckboxGroup([
|
58 |
-
"Background", "Clothes", "Face", "Hair", "Skin
|
59 |
], label="Select Categories to Preserve")
|
60 |
],
|
61 |
outputs=gr.Image(label="Masked Image", type="pil"),
|
|
|
10 |
def get_segmentation_mask(image_url):
|
11 |
client = Client("facebook/sapiens-seg")
|
12 |
result = client.predict(image=handle_file(image_url), model_name="1b", api_name="/process_image")
|
13 |
+
return np.load(result[1]) # Result[1] contains the .npy mask
|
14 |
|
15 |
def process_image(image, categories_to_hide):
|
16 |
# Convert uploaded image to a PIL Image
|
|
|
26 |
"Clothes": [1, 12, 22, 8, 9, 17, 18], # Includes Shoes, Socks, Slippers
|
27 |
"Face": [2, 23, 24, 25, 26, 27], # Face Neck, Lips, Teeth, Tongue
|
28 |
"Hair": [3], # Hair
|
29 |
+
"Skin": [4, 5, 6, 7, 10, 11, 13, 14, 15, 16, 19, 20, 21] # Hands, Feet, Arms, Legs, Torso
|
30 |
}
|
31 |
|
32 |
# Convert image to numpy array (RGBA)
|
|
|
55 |
inputs=[
|
56 |
gr.File(label="Upload an Image"),
|
57 |
gr.CheckboxGroup([
|
58 |
+
"Background", "Clothes", "Face", "Hair", "Skin"
|
59 |
], label="Select Categories to Preserve")
|
60 |
],
|
61 |
outputs=gr.Image(label="Masked Image", type="pil"),
|