Thanks for the answer. But how can I load a model then? And how is one supposed to implement the example then?
As written, I already tried to get the paths from input fields…
Got it working now, with the following code (in case someone got the same problem):
loadModel = async function (e) {
return new Promise((resolve) => {
let file = e.target.files[0];
let path = file.name;
let reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = function (ev) {
if (reader.readyState === 2) {
let buffer = reader.result;
let data = new Uint8Array(buffer);
cv.FS_createDataFile('/', path, data, true, false, false);
resolve(path);
}
}
});
}
configPathInput.addEventListener('change', async (e) => {
configPath = await loadModel(e);
console.log(typeof configPath);
console.log(configPath);
});
modelPathInput.addEventListener('change', async (e) => {
modelPath = await loadModel(e);
console.log(typeof modelPath);
console.log(modelPath);
});
rerunButton.addEventListener('click', async (e) => {
let net = cv.readNet(configPath, modelPath);
console.log(net);
}, false);
I don’t really get what’s going on tbh, but nice that it is working now. Coming from python, the file handling in JS is very different and difficult to comprehend.
Any advice on how to proceed to load the files straight from disk without having to use input fields? Do I have to use Blobs or something?