Webnn: Uncaught (in promise) Error: External mounted files are not available.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- machine-learning, web-dev
Research direction
Start by reproducing the WebNN model load from index.html and main.js using the referenced model.onnx and classes.txt, then inspect where the external-mounted-files error is raised. Compare the browser, ONNX Runtime Web, WebNN, and Qualcomm NPU setup used by the report; done means the cause is identified and a verified loading configuration or documented limitation is provided.
Written by the indexing model from the issue text.
Description
I am trying to infer a model in Qualcomm NPU. I try to load the model and this is the error I get:
This is my index.html code
<title>ONNX Runtime WebNN Example</title>WebNN Image Classifier
Select an image to classify. <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.all.min.js"></script> <script src="main.js"></script>This is my inference code while trying to infer on Qualcomm NPU (main.js):
const modelPath = 'model.onnx';
const classesPath = 'classes.txt';
const options = {
executionProviders: [
{
name: 'webnn',
deviceType: 'npu',
powerPreference: 'default',
},
],
};
let classLabels = [];
async function loadClasses() {
const response = await fetch(classesPath);
const text = await response.text();
classLabels = text.split('\n').map(label => label.trim()).filter(label => label.length > 0);
}
async function loadModel() {
try {
const session = await ort.InferenceSession.create(modelPath, options);
return session;
} catch (err) {
document.getElementById('result').textContent = Model load failed: ${err.message};
throw err;
}
}
function preprocessImage(imageElement) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 224;
canvas.height = 224;
ctx.drawImage(imageElement, 0, 0, 224, 224);
const imageData = ctx.getImageData(0, 0, 224, 224).data;
const input = new Float32Array(3 * 224 * 224);
for (let i = 0; i < 224 * 224; i++) {
input[i] = imageData[i * 4] / 255.0;
input[i + 224 * 224] = imageData[i * 4 + 1] / 255.0;
input[i + 2 * 224 * 224] = imageData[i * 4 + 2] / 255.0;
}
return new ort.Tensor('float32', input, [1, 3, 224, 224]);
}
async function classifyImage(file) {
const img = new Image();
img.src = URL.createObjectURL(file);
await img.decode();
const session = await loadModel();
const inputTensor = preprocessImage(img);
const feeds = { image_tensor: inputTensor }; // ✅ Correct input name
const results = await session.run(feeds);
const outputData = results.class_logits.data; // ✅ Correct output name
const topIndex = outputData.indexOf(Math.max(...outputData));
const predictedLabel = classLabels[topIndex] || Class ${topIndex};
document.getElementById('result').textContent = Prediction: ${predictedLabel};
}
document.getElementById('imageInput').addEventListener('change', async (e) => {
const file = e.target.files[0];
if (file) {
await loadClasses();
classifyImage(file);
}
});
I don't know why I am getting this error
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 418
- PR merge metrics
- No merged PRs in 30d
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/onnxruntime-inference-examples
-
Replace deprecated light-server with lite-server for onnxruntime-webPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Minor: typoPossibly taken @Hashim1999164 claimed this 77 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
microsoft/onnxruntime-inference-examples#124 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Package "onnxruntime-react-native" does not contain a valid config pluginPossibly taken @reginaldalfret claimed this 35 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in microsoft/onnxruntime-inference-examples
Similar issues
-
bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
chipsalliance/verible#2644 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
grafana/pyroscope-dotnet#470 ·
Maintainers usually reply within 1 day
-
documentation P5 XS
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-astro/AlpacaBridge#1848 ·
Maintainers usually reply within 1 day
-
DiskANN AnnIterator returns unconverted IP distances after the graph walk runs out of candidatesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
zilliztech/knowhere#1933 ·
Maintainers usually reply within 1 day