Spaces:
Running
on
T4
Running
on
T4
Upload gradio_app.py
Browse files- gradio_app.py +12 -10
gradio_app.py
CHANGED
|
@@ -153,19 +153,16 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
|
|
| 153 |
else:
|
| 154 |
mesh_file_path = os.path.join(save_folder, f'white_mesh.glb')
|
| 155 |
|
| 156 |
-
|
| 157 |
print(
|
| 158 |
f'Find html file {mesh_file_path}, {os.path.exists(mesh_file_path)}')
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
# Encode the GLB file as base64 to embed directly in the HTML
|
| 162 |
-
with open(mesh_file_path, 'rb') as f:
|
| 163 |
-
encoded = base64.b64encode(f.read()).decode('utf-8')
|
| 164 |
|
| 165 |
html = f"""
|
| 166 |
-
<
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
| 169 |
</model-viewer>
|
| 170 |
"""
|
| 171 |
|
|
@@ -424,7 +421,12 @@ def build_app():
|
|
| 424 |
|
| 425 |
"""
|
| 426 |
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
gr.HTML(title_html)
|
| 429 |
|
| 430 |
with gr.Row():
|
|
|
|
| 153 |
else:
|
| 154 |
mesh_file_path = os.path.join(save_folder, f'white_mesh.glb')
|
| 155 |
|
|
|
|
| 156 |
print(
|
| 157 |
f'Find html file {mesh_file_path}, {os.path.exists(mesh_file_path)}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
html = f"""
|
| 160 |
+
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|
| 161 |
+
<model-viewer src="{mesh_file_path}"
|
| 162 |
+
alt="3D Model"
|
| 163 |
+
camera-controls
|
| 164 |
+
auto-rotate
|
| 165 |
+
style="height: 690px; width: 500px;">
|
| 166 |
</model-viewer>
|
| 167 |
"""
|
| 168 |
|
|
|
|
| 421 |
|
| 422 |
"""
|
| 423 |
|
| 424 |
+
custom_js = """
|
| 425 |
+
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|
| 426 |
+
"""
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
with gr.Blocks(theme=gr.themes.Base(), title='Hunyuan-3D-2.0', analytics_enabled=False, css=custom_css, js=custom_js) as demo:
|
| 430 |
gr.HTML(title_html)
|
| 431 |
|
| 432 |
with gr.Row():
|