Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from SegCloth import segment_clothing
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
return segment_clothing(img, selected_items)
|
11 |
|
12 |
iface = gr.Interface(
|
@@ -14,28 +22,13 @@ iface = gr.Interface(
|
|
14 |
inputs=[
|
15 |
gr.Image(type='pil', label='Image'),
|
16 |
|
17 |
-
#
|
18 |
-
gr.CheckboxGroup(choices=["
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
# Face Category
|
23 |
-
gr.CheckboxGroup(choices=["Face", "Sunglasses"],
|
24 |
-
value=["Face", "Sunglasses"],
|
25 |
-
label='Face'),
|
26 |
-
|
27 |
-
# Hair Category
|
28 |
-
gr.CheckboxGroup(choices=["Hair"],
|
29 |
-
value=["Hair"],
|
30 |
-
label='Hair'),
|
31 |
-
|
32 |
-
# Skin Category
|
33 |
-
gr.CheckboxGroup(choices=["Left-arm", "Right-arm", "Left-leg", "Right-leg"],
|
34 |
-
value=["Left-arm", "Right-arm", "Left-leg", "Right-leg"],
|
35 |
-
label='Skin')
|
36 |
],
|
37 |
outputs=gr.Image(label='Clothing Crop'),
|
38 |
-
examples=[['./1.jpg', ["
|
39 |
theme="Nymbo/Alyx_Theme"
|
40 |
)
|
41 |
|
|
|
1 |
import gradio as gr
|
2 |
from SegCloth import segment_clothing
|
3 |
|
4 |
+
# Define items for each category
|
5 |
+
CATEGORY_ITEMS = {
|
6 |
+
"Clothes": ["Hat", "Upper-clothes", "Skirt", "Pants", "Dress", "Belt", "Left-shoe", "Right-shoe", "Scarf"],
|
7 |
+
"Face": ["Face", "Sunglasses"],
|
8 |
+
"Hair": ["Hair"],
|
9 |
+
"Skin": ["Left-arm", "Right-arm", "Left-leg", "Right-leg"]
|
10 |
+
}
|
11 |
+
|
12 |
+
def segment(img, selected_categories):
|
13 |
+
# Get the items based on the selected categories
|
14 |
+
selected_items = []
|
15 |
+
for category in selected_categories:
|
16 |
+
selected_items.extend(CATEGORY_ITEMS.get(category, []))
|
17 |
+
|
18 |
return segment_clothing(img, selected_items)
|
19 |
|
20 |
iface = gr.Interface(
|
|
|
22 |
inputs=[
|
23 |
gr.Image(type='pil', label='Image'),
|
24 |
|
25 |
+
# Category Selection CheckboxGroup
|
26 |
+
gr.CheckboxGroup(choices=["Clothes", "Face", "Hair", "Skin"],
|
27 |
+
label='Select Categories',
|
28 |
+
value=["Clothes", "Face", "Hair", "Skin"]) # Default selection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
],
|
30 |
outputs=gr.Image(label='Clothing Crop'),
|
31 |
+
examples=[['./1.jpg', ["Clothes", "Face"]]],
|
32 |
theme="Nymbo/Alyx_Theme"
|
33 |
)
|
34 |
|