Spaces:
Running
on
T4
Running
on
T4
Upload gradio_app.py
Browse files- gradio_app.py +27 -27
gradio_app.py
CHANGED
@@ -137,37 +137,37 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
|
|
137 |
template_html = template_html.replace('#src#', f'{related_path}/')
|
138 |
f.write(template_html)
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
|
150 |
-
if textured:
|
151 |
-
|
152 |
-
else:
|
153 |
-
|
154 |
|
155 |
# Encode the GLB file as base64 to embed directly in the HTML
|
156 |
-
with open(mesh_file, "rb") as f:
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
model_viewer_html = f"""
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
"""
|
169 |
|
170 |
-
return model_viewer_html
|
171 |
|
172 |
@spaces.GPU(duration=40)
|
173 |
def _gen_shape(
|
|
|
137 |
template_html = template_html.replace('#src#', f'{related_path}/')
|
138 |
f.write(template_html)
|
139 |
|
140 |
+
iframe_tag = f'<iframe src="file={output_html_path}" height="{height}" width="100%" frameborder="0"></iframe>'
|
141 |
+
print(
|
142 |
+
f'Find html file {output_html_path}, {os.path.exists(output_html_path)}, relative HTML path is /static/{rel_path}')
|
143 |
+
|
144 |
+
return f"""
|
145 |
+
<div style='height: {height}; width: 100%;'>
|
146 |
+
{iframe_tag}
|
147 |
+
</div>
|
148 |
+
"""
|
149 |
|
150 |
+
#if textured:
|
151 |
+
# mesh_file = os.path.join(save_folder, "textured_mesh.glb")
|
152 |
+
#else:
|
153 |
+
# mesh_file = os.path.join(save_folder, "white_mesh.glb")
|
154 |
|
155 |
# Encode the GLB file as base64 to embed directly in the HTML
|
156 |
+
#with open(mesh_file, "rb") as f:
|
157 |
+
# glb_data = f.read()
|
158 |
+
# glb_base64 = base64.b64encode(glb_data).decode("utf-8")
|
159 |
+
|
160 |
+
#model_viewer_html = f"""
|
161 |
+
#<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|
162 |
+
#<model-viewer src="data:model/gltf-binary;base64,{glb_base64}"
|
163 |
+
# alt="3D Model"
|
164 |
+
# camera-controls
|
165 |
+
# auto-rotate
|
166 |
+
# style="height: {height}px; width: {width}px;">
|
167 |
+
#</model-viewer>
|
168 |
+
#"""
|
169 |
|
170 |
+
#return model_viewer_html
|
171 |
|
172 |
@spaces.GPU(duration=40)
|
173 |
def _gen_shape(
|