File size: 1,439 Bytes
a9c51af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fadc8ac
a9c51af
8d06ead
81abe4b
a9c51af
 
 
 
 
fadc8ac
a9c51af
8d06ead
81abe4b
a9c51af
 
 
 
 
8d06ead
a9c51af
 
 
 
39a6825
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)