devendergarg14 commited on
Commit
6c0a327
Β·
verified Β·
1 Parent(s): 0963681

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -26
app.py CHANGED
@@ -1,12 +1,20 @@
1
  import gradio as gr
2
  from SegCloth import segment_clothing
3
 
4
- def segment(img, clothes, face, hair, skin):
5
- clothes = clothes if clothes is not None else []
6
- face = face if face is not None else []
7
- hair = hair if hair is not None else []
8
- skin = skin if skin is not None else []
9
- selected_items = clothes + face + hair + skin # Combine all selections into one list
 
 
 
 
 
 
 
 
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
- # Clothes Category
18
- gr.CheckboxGroup(choices=["Hat", "Upper-clothes", "Skirt", "Pants", "Dress", "Belt", "Left-shoe", "Right-shoe", "Scarf"],
19
- value=["Hat", "Upper-clothes", "Skirt", "Pants", "Dress", "Belt", "Left-shoe", "Right-shoe", "Scarf"],
20
- label='Clothes'),
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', ["Hat", "Upper-clothes", "Skirt", "Pants", "Dress", "Belt", "Left-shoe", "Right-shoe", "Scarf"]]],
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