Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Model not initialized #1135

Open
1 of 5 tasks
vlohar08 opened this issue Jan 3, 2025 · 0 comments
Open
1 of 5 tasks

Error: Model not initialized #1135

vlohar08 opened this issue Jan 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@vlohar08
Copy link

vlohar08 commented Jan 3, 2025

System Info

"@huggingface/transformers": "^3.2.4",
"next": "15.1.3",
"onnxruntime-web": "1.21.0-dev.20241205-d27fecd3d3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"sharp": "^0.33.5"

OS: Windows 11
Node: v20.17.0
Browser: Version 131.0.6778.205

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

Hi,
I am trying to load a model in a Next.js App. It is mostly working like the model is downloaded correctly but not initialized.
I have this part of the code where the Model loaded is never printed in the console. Idk why but the AutoModel promise never resolves or rejects. Check this repo for full code.

    console.log("Model loading");

    state.model = await AutoModel.from_pretrained(MODEL_ID, {
      dtype: "fp16",
      device: "webgpu",
      progress_callback: (progress: ProgressInfo) => {
        if (onProgress && progress.status === "progress") {
          onProgress(progress.progress);
        }
      },
    });

    console.log("Model loaded");

And, when I still try to process the image, I get this error Error: Failed to process the image or a custom error Model not initialized. Why? bcoz, the promise was never resolved or rejected. So the next code was never executed.

Reproduction

  1. Clone this repo
  2. Install all dependencies. (I use pnpm)
  3. Start the dev server (pnpm dev)
  4. Wait for the model to load
  5. Upload an image and click on the Remove Background button
  6. Check the console for error
@vlohar08 vlohar08 added the bug Something isn't working label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant