Fix API endpoint dispatching: add api_names, clean signatures, replace gr.Walkthrough with gr.Tabs
Browse files418 unmodified lines419420421422423424425426102 unmodified lines5295305315325335345355366 unmodified lines54354454554654754854963 unmodified lines61361461561661761861962062162262322 unmodified lines6466476486496506511 unmodified line6536546556566576586593 unmodified lines663664665666667668669670671672673674675676418 unmodified linestex_slat_guidance_rescale: float,tex_slat_sampling_steps: int,tex_slat_rescale_t: float,req: gr.Request,progress=gr.Progress(track_tqdm=True),) -> Tuple[str, str]:# --- Sampling ---outputs, latents = pipeline.run(102 unmodified linesstate: str,decimation_target: int,texture_size: int,req: gr.Request,progress=gr.Progress(track_tqdm=True),) -> Tuple[str, str]:"""Extract a GLB file from the 3D model.6 unmodified linesReturns:str: The path to the extracted GLB file."""user_dir = os.path.join(TMP_DIR, str(req.session_hash))shape_slat, tex_slat, res = unpack_state(state)mesh = pipeline.decode_latent(shape_slat, tex_slat, res)[0]mesh.simplify(16777216)63 unmodified linestex_slat_rescale_t = gr.Slider(1.0, 6.0, label="Rescale T", value=3.0, step=0.1)with gr.Column(scale=10):with gr.Walkthrough(selected=0) as walkthrough:with gr.Step("Preview", id=0):preview_output = gr.HTML(empty_html, label="3D Asset Preview", show_label=True, container=True)extract_btn = gr.Button("Extract GLB")with gr.Step("Extract", id=1):glb_output = gr.Model3D(label="Extracted GLB", height=724, show_label=True, display_mode="solid", clear_color=(0.25, 0.25, 0.25, 1.0))download_btn = gr.DownloadButton(label="Download GLB")gr.Markdown("*We are actively working on improving the speed of GLB extraction. Currently, it may take half a minute or more and face count is limited.*")22 unmodified linespreprocess_image,inputs=[image_prompt],outputs=[image_prompt],)generate_btn.click(1 unmodified lineinputs=[randomize_seed, seed],outputs=[seed],).then(lambda: gr.Walkthrough(selected=0), outputs=walkthrough).then(image_to_3d,inputs=[3 unmodified linestex_slat_guidance_strength, tex_slat_guidance_rescale, tex_slat_sampling_steps, tex_slat_rescale_t,],outputs=[output_buf, preview_output],)extract_btn.click(lambda: gr.Walkthrough(selected=1), outputs=walkthrough).then(extract_glb,inputs=[output_buf, decimation_target, texture_size],outputs=[glb_output, download_btn],)418 unmodified lines419420421422423424102 unmodified lines5275285295305315326 unmodified lines53954054154254354454563 unmodified lines60961061161261361461561661761861922 unmodified lines6426436446456466476481 unmodified line6506516526536546556566573 unmodified lines661662663664665666667668669670671672673674675676677418 unmodified linestex_slat_guidance_rescale: float,tex_slat_sampling_steps: int,tex_slat_rescale_t: float,) -> Tuple[str, str]:# --- Sampling ---outputs, latents = pipeline.run(102 unmodified linesstate: str,decimation_target: int,texture_size: int,) -> Tuple[str, str]:"""Extract a GLB file from the 3D model.6 unmodified linesReturns:str: The path to the extracted GLB file."""user_dir = os.path.join(TMP_DIR, f"glb_{int(time.time()*1000)}")shape_slat, tex_slat, res = unpack_state(state)mesh = pipeline.decode_latent(shape_slat, tex_slat, res)[0]mesh.simplify(16777216)63 unmodified linestex_slat_rescale_t = gr.Slider(1.0, 6.0, label="Rescale T", value=3.0, step=0.1)with gr.Column(scale=10):with gr.Tabs(selected=0) as tabs:with gr.Tab("Preview", id=0):preview_output = gr.HTML(empty_html, label="3D Asset Preview", show_label=True, container=True)extract_btn = gr.Button("Extract GLB")with gr.Tab("Extract", id=1):glb_output = gr.Model3D(label="Extracted GLB", height=724, show_label=True, display_mode="solid", clear_color=(0.25, 0.25, 0.25, 1.0))download_btn = gr.DownloadButton(label="Download GLB")gr.Markdown("*We are actively working on improving the speed of GLB extraction. Currently, it may take half a minute or more and face count is limited.*")22 unmodified linespreprocess_image,inputs=[image_prompt],outputs=[image_prompt],api_name="preprocess_image",)generate_btn.click(1 unmodified lineinputs=[randomize_seed, seed],outputs=[seed],).then(lambda: gr.Tabs(selected=0),outputs=tabs,).then(image_to_3d,inputs=[3 unmodified linestex_slat_guidance_strength, tex_slat_guidance_rescale, tex_slat_sampling_steps, tex_slat_rescale_t,],outputs=[output_buf, preview_output],api_name="image_to_3d",)extract_btn.click(extract_glb,inputs=[output_buf, decimation_target, texture_size],outputs=[glb_output, download_btn],api_name="extract_glb",).then(lambda: gr.Tabs(selected=1),outputs=tabs,)
app.py+12-11