try: import gradio as gr except ImportError as exc: raise ImportError( "gradio is required for gradio functionality. " "Install it with: pip install embed4d[gradio]" ) from exc from embed4d import model3d_viewer with gr.Blocks() as demo: gr.Markdown("# GLB Viewer: Custom HTML vs Gradio Model3D") with gr.Row(): with gr.Column(): gr.Markdown("## Embed 4D (3D + time) — lightweight GLB/GLTF animation") file_input = gr.File(file_types=[".glb"], label="Select GLB File") with gr.Row(): with gr.Column(): gr.Markdown("### Custom HTML Viewer") viewer_output_custom = gr.HTML() with gr.Column(): gr.Markdown("### Gradio Model3D") viewer_output_model3d = gr.Model3D() # Update HTML viewer # `gr.File` is dynamically typed; pylint can't see `.change()`. # pylint: disable=no-member file_input.change( lambda file: model3d_viewer(file.name if file else None), inputs=file_input, outputs=viewer_output_custom, ) # Update Model3D viewer (just pass the file path) file_input.change( lambda file: file.name if file else None, inputs=file_input, outputs=viewer_output_model3d, ) # pylint: enable=no-member demo.launch()