Unable to Load 3D Model File and Encountering JSON Parsing Error

35 Views Asked by At

I'm using Gradio to build a web application that involves loading 3D model files. I've encountered an issue where I can't successfully load 3D model files, and the following error appears in the browser's console:

babylon.js:15  BJS - [16:43:02]: Unable to load from http://127.0.0.1:7861/file=C:\Users\Username\AppData\Local\Temp\gradio\fddfd8b516dfea30f08ed466f059e630c73fb602\Bunny.obj: importScene of undefined from undefined version: undefined, exporter version: undefinedimportScene has failed JSON parse

and

Unable to find a plugin to load .Wuliu\AppData\Local\Temp\gradio\fddfd8b516dfea30f08ed466f059e630c73fb602\Bunny files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type

I'm using the official Gradio example code provided below:

import gradio as gr
import os

def load_mesh(mesh_file_name):
    return mesh_file_name

demo = gr.Interface(
    fn=load_mesh,
    inputs=gr.Model3D(),
    outputs=gr.Model3D(
            clear_color=[0.0, 0.0, 0.0, 0.0],  label="3D Model"),
    examples=[
        [os.path.join(os.path.abspath(''), "files/Bunny.obj")],
        [os.path.join(os.path.abspath(''), "files/Duck.glb")],
        [os.path.join(os.path.abspath(''), "files/Fox.gltf")],
        [os.path.join(os.path.abspath(''), "files/face.obj")],
    ]
)
if __name__ == "__main__":
    demo.launch()

I'm using Windows 10 as my operating system and have created a virtual environment. My Python version is 3.12, and I'm using Gradio version 4.14.0. The peculiar thing is that I've tested this on multiple machines, and the same operation works on most of them, but two of my PCs are unable to run it. I'm not sure why this discrepancy exists.

Given my limited knowledge in JavaScript and Babylon.js, I'm unsure how to proceed with debugging this issue. Does anyone have insights on how I can solve this problem within the Gradio context without diving into JavaScript and Babylon.js?

I've tried checking the file path and the model file format, but I still can't resolve this issue. Does anyone know how to solve this problem?

0

There are 0 best solutions below