import spaces
import gradio as gr
from glob import glob
@spaces.GPU(duration=60)
def gen_shape():
print("do nothing")
def get_example_img_list():
print('Loading example img list ...')
return sorted(glob('./assets/example_images/**/*.png', recursive=True))
example_imgs = get_example_img_list()
HTML_OUTPUT_PLACEHOLDER = f"""
Welcome to Hunyuan3D!
No mesh here.
"""
MAX_SEED = 1e7
title = "## Image to 3D"
description = "A lightweight image to 3D converter"
with gr.Blocks().queue() as demo:
gr.Markdown(title)
gr.Markdown(description)
with gr.Row():
with gr.Column(scale=3):
gr.Markdown("#### Image Prompt")
image = gr.Image(sources=["upload"], label='Image', type='pil', image_mode='RGBA', height=290)
gen_button = gr.Button(value='Generate Shape', variant='primary')
with gr.Accordion("Advanced Options", open=False):
seed = gr.Slider(
label="Seed",
minimum=0,
maximum=MAX_SEED,
step=1,
value=1234,
min_width=100,
)
with gr.Column():
num_steps = gr.Slider(maximum=100, minimum=1, value=5, step=1, label='Inference Steps')
octree_resolution = gr.Slider(maximum=512, minimum=16, value=256, label='Octree Resolution')
with gr.Column():
cfg_scale = gr.Slider(maximum=20.0, minimum=1.0, value=5.5, step=0.1, label='Guidance Scale')
num_chunks = gr.Slider(maximum=5000000, minimum=1000, value=8000, label='Number of Chunks')
target_face_num = gr.Slider(maximum=1000000, minimum=100, value=10000, label='Target Face Number')
with gr.Column(scale=6):
gr.Markdown("#### Generated Mesh")
html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
with gr.Column(scale=3):
gr.Markdown("#### Image Examples")
gr.Examples(examples=example_imgs, inputs=[image],
label=None, examples_per_page=18)
demo.launch()