Ask Your Question
0

Loading a Caffe model in OpenCV.js[Solved]

asked 2019-07-17 03:35:34 -0500

zy890p gravatar image

updated 2019-07-26 06:30:53 -0500

supra56 gravatar image

Hi there,

I am testing how to use the readNetFromCaffe() function to load the MobileNetSSD_deploy.prototxt and MobileNetSSD_deploy.caffemodel files. But the system keep complaining with this message:

Exception: OpenCV(4.1.1-pre) /build/master-contrib_docs-lin64/opencv/modules/dnn/src/caffe/caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "file.txt" in function 'ReadProtoFromTextFile'

Can anyone help ? Thanks.

Here are the lines I used to load the files:

let modelTxt='MobileNetSSD_deploy.prototxt';

let modelBin='MobileNetSSD_deploy.caffemodel';

utils.createFileFromUrl('file.txt', modelTxt, callback);

utils.createFileFromUrl('file.bin', modelBin, callback);

net=cv.readNetFromCaffe('file.txt', 'file.bin');
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-07-25 21:12:07 -0500

zy890p gravatar image

updated 2019-07-25 21:23:37 -0500

I finally rewritten a function like this and it's working now.

function loadModels() {
var proto = 'MobileNetSSD_deploy.prototxt';
var weights = 'MobileNetSSD_deploy.caffemodel';
utils.createFileFromUrl(proto, proto, () =>
{
    document.getElementById('status').innerHTML = 'Downloading ' + proto;
    utils.createFileFromUrl(weights, weights, () =>
    {
        document.getElementById('status').innerHTML = 'Downloading ' + weights;
        netDet=cv.readNetFromCaffe(proto,  weights);
        console.log('Transfer completed.');
        document.getElementById('status').innerHTML = 'Caffe network loaded.';
    });
});
}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-07-17 03:35:34 -0500

Seen: 48 times

Last updated: Jul 26