Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,753 Bytes
75d84c2 27fc85d 5ecc81f 27fc85d 75d84c2 5ecc81f d02142b 5ecc81f 27fc85d f882a9b 5ecc81f d02142b 5ecc81f d02142b 5ecc81f f882a9b |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
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"""
<div style='height: {650}px; width: 100%; border-radius: 8px; border-color: #e5e7eb; border-style: solid; border-width: 1px; display: flex; justify-content: center; align-items: center;'>
<div style='text-align: center; font-size: 16px; color: #6b7280;'>
<p style="color: #8d8d8d;">Welcome to Hunyuan3D!</p>
<p style="color: #8d8d8d;">No mesh here.</p>
</div>
</div>
"""
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)
with gr.Column():
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.Number(value=5.0, label='Guidance Scale', min_width=100)
num_chunks = gr.Slider(maximum=5000000, minimum=1000, value=8000,
label='Number of Chunks', min_width=100)
with gr.Column(scale=6):
gr.Markdown("#### Generated Mesh")
with gr.Tabs(selected='gen_mesh_panel') as tabs_output:
with gr.Tab('Exporting Mesh', id='export_mesh_panel'):
html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
with gr.Tab('Mesh Statistic', id='stats_panel'):
stats = gr.Json({}, label='Mesh Stats')
with gr.Column(scale=3):
gr.Markdown("#### Image Examples")
gr.Examples(examples=example_imgs, inputs=[image],
label=None, examples_per_page=18)
demo.launch() |