File size: 1,223 Bytes
bddf3b8
 
 
6db8040
6c0a327
6db8040
6c0a327
 
 
 
 
 
84538bc
6c0a327
 
84538bc
6c0a327
 
84538bc
bddf3b8
15b2e0a
 
 
 
 
6db8040
 
6c0a327
6db8040
15b2e0a
 
ad97bfe
15b2e0a
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from SegCloth import segment_clothing

# Define items for each category, including Background
CATEGORY_ITEMS = {
    "Background": ["Background"],
    "Clothes": ["Hat", "Upper-clothes", "Skirt", "Pants", "Dress", "Belt", "Left-shoe", "Right-shoe", "Scarf"],
    "Face": ["Face", "Sunglasses"],
    "Hair": ["Hair"],
    "Skin": ["Left-arm", "Right-arm", "Left-leg", "Right-leg"]
}

def segment(image, categories_to_hide):
    # Get the items based on the selected categories
    selected_items = []
    for category in categories_to_hide:
        selected_items.extend(CATEGORY_ITEMS.get(category, []))
    
    return segment_clothing(image, selected_items)

iface = gr.Interface(
    fn=segment, 
    inputs=[
        gr.Image(type='pil', label='Image'),
        
        # Category Selection CheckboxGroup including Background
        gr.CheckboxGroup(choices=["Background", "Clothes", "Face", "Hair", "Skin"],
                         label='Select Categories',
                         value=["Background", "Clothes", "Face", "Hair", "Skin"])  # Default selection
    ], 
    outputs=gr.Image(label='Clothing Crop'),
    examples=[['./1.jpg', ["Background", "Clothes", "Face"]]]
)

iface.launch()