huggingface / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
12.02k stars 759 forks source link

How do I know the loading progress when loading .onnx file? #993

Open aidscooler opened 2 weeks ago

aidscooler commented 2 weeks ago

Question

Because the .onnx file is large(about 170M),I decided to provide a loading progress. Code as below:

 const modelSettings = {
        // Do not require config.json to be present in the repository
        config: { model_type: "custom" },
        subfolder: "",
        process_callback: (progress) => {
          modelLoadingProgress.value = Math.round(progress * 100); 
          console.log("model : " + progress)         
        }
 };
 modelSettings.device = "webgpu";
 modelSettings.dtype = "fp32";
 model = await AutoModel.from_pretrained('briaai/RMBG-1.4', modelSettings);

I found the process_callback never been called. Can anyone help?

xenova commented 2 weeks ago

Hi there 👋 you have a typo: it should be progress_callback (not proCess)

aidscooler commented 2 weeks ago

Hi there 👋 you have a typo: it should be progress_callback (not proCess)

You are right,Thanks!!! What's there in the argument progress? It shows [object object] in the console.How do I know the details of progress?

xenova commented 2 weeks ago

We also provide information like total number of bytes, so progress is not a single number. Feel free to console.log it to see the available fields. :)