From 2994e02c9374ff549852ae760600046e5b223ff2 Mon Sep 17 00:00:00 2001 From: Theodore Rolle Date: Tue, 21 Jan 2025 22:09:33 -0800 Subject: [PATCH] Fix 3D viewer not loading due to HTML path issue in gradio_app.py This small patch fixes a logical error in gradio_app.py, causing the generated HTML to contain the filepath relative to app root rather than relative to /static/. Before the patch, the generated `iframe_tag` would contain incorrect references such as `/static/./gradio_cache/5/white_mesh.html`. This fix uses `os.path.relpath()` to strip `SAVE_DIR` from the prefix, thus giving the correct path relative to the static cache directory, ex: `/static/5/white_mesh.html` --- gradio_app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gradio_app.py b/gradio_app.py index 719bdd5..0c2119a 100644 --- a/gradio_app.py +++ b/gradio_app.py @@ -71,8 +71,9 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False): with open(output_html_path, 'w') as f: f.write(template_html.replace('', obj_html)) - iframe_tag = f'' - print(f'Find html {output_html_path}, {os.path.exists(output_html_path)}') + rel_path = os.path.relpath(output_html_path, SAVE_DIR) + iframe_tag = f'' + print(f'Find html file {output_html_path}, {os.path.exists(output_html_path)}, relative HTML path is /static/{rel_path}') return f"""