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()