import gradio as gr from main import process_image_pifuhd, process_image, generate_mask, run_garment_inference, process_mesh from PIL import Image # Function for PIFuHD processing def generate_mesh_pifuhd(image): obj_path = process_image_pifuhd(image) return obj_path # Function for AnchorUDF processing def process_anchorudf(image): processed_image_path = process_image(image) mask_path = generate_mask(processed_image_path) run_garment_inference() try: cleaned_ply_path = process_mesh(scale_factor=0.5, nb_neighbors=40, std_ratio=1.0, voxel_size=0.003) except FileNotFoundError as e: return str(e) return cleaned_ply_path # Define Gradio interface for PIFuHD pifuhd_interface = gr.Interface( fn=generate_mesh_pifuhd, inputs=gr.Image(type="pil"), outputs="file", title="Mesh Generator", description="Upload an image to generate a 3D mesh." ) # Define Gradio interface for AnchorUDF anchorudf_interface = gr.Interface( fn=process_anchorudf, inputs=gr.Image(type="filepath"), outputs="file", title="Garment Inference", description="Upload an image for garment inference." ) # Combine both interfaces into one Gradio app app = gr.TabbedInterface( interface_list=[pifuhd_interface, anchorudf_interface], tab_names=["Human", "Garment"] ) # Run the Gradio app if __name__ == "__main__": app.launch(max_threads=True, debug=True)