File size: 1,179 Bytes
e7bcb12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from PIL import Image
import os
# Import your core functions (estimate_pose, segment_clothing, inpaint_clothing, change_clothing) from your main script
from main_code_script import change_clothing  # Replace your_main_script
def predict(image_path, garment_image_path): # Changed input
    """
    The prediction function for Gradio.
    """
    try:
        modified_image = change_clothing(image_path, garment_image_path) # Changed input
        if modified_image:
            return modified_image
        else:
            return "Failed to change clothing.  Please check the images."
    except Exception as e:
        return f"Error: {e}"
# Create the Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs=[
        gr.Image(type="filepath", label="Input Image (Person)"), # Changed label
        gr.Image(type="filepath", label="Garment Image"),  # Added input
    ],
    outputs=gr.Image(type="pil", label="Modified Image"),
    title="AI Clothing Changer",
    description="Try on different clothes with AI by uploading a garment image!", # Changed description
)
# Launch the Gradio interface
if __name__ == "__main__":
    iface.launch()