0

I've built digits from this tutorial recently, everything is ok and I finally trained my AlexNet model (also trained a SqueezNet so that I can upload the model here) ! the problem is when I download my model from Digits, I can not load it into my program for testing!I have tested my program with GoogleNet downloaded from this link and it's working fine! I'm using OpenCV readNetFromCaffe in this function to load Caffe model

void deepNetwork::loadModel( cv::String  model ,cv::String  weight ,string lablesPath,int ps){
patchSize=ps;
labeslPath=lablesPath;
 try
{
    net = dnn::readNetFromCaffe(weight,model);
    cerr<<"loaded succ"<<endl;
}
catch (cv::Exception& e)
{
    std::cerr << "Exception: " << e.what() << std::endl;

}}

I get the following error loading my model

OpenCV Error: Assertion failed (pbBlob.raw_data_type() == caffe::FLOAT16) in blo
bFromProto, file /home/nvidia/build-opencv/opencv/modules/dnn/src/caffe/caffe_im
porter.cpp, line 242 Exception: /home/nvidia/build-opencv/opencv/modules/dnn/src/caffe/caffe_importer .cpp:242: error: (-215) pbBlob.raw_data_type() == caffe::FLOAT16 in function blo
bFromProto

OpenCV Error: Requested object was not found (Requested blob "data" not found) i
n setInput, file /home/nvidia/build-opencv/opencv/modules/dnn/src/dnn.cpp, line
1606 terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/build-opencv/opencv/modules/dnn/src/dnn.cpp:1606: error: (-204) Requested blob "data" not found in function setInput

Aborted (core dumped)

any help would be appreciated <3

opencv version 3.3.1 also tested on (3.3.0 ,3.4.1) same error! testing on a system without Cuda, Cudnn or Caffe just pure c++ and OpenCv... but i've trained my model on a aws ec2 instance (p3.2xlarge ) with Cuda,Cudnn and caffe !

you can download the trained squeezNet model (.prototxt and .caffemodel) here

Amir
  • 155
  • 3
  • 16

2 Answers2

0

finally, I found the problem! it's a version problem I have digits 6.1.1 working with nvcaffe 0.17.0 for training which is not compatible with previous Caffe and OpenCv libraries ! you have to downgrade NvCaffe to version 0.15.14 and it will open with OpenCv easily!

Amir
  • 155
  • 3
  • 16
0

OpenCV DNN model expect caffemodel in BVLC format. But, NVCaffe stores the caffe model in more efficient format which different than BVLC Caffe. If you want model compatible with both BVLC/Caffe as well as NVcaffe.

Add this flag in solver.prototxt store_blobs_in_old_format = true

Please read the DIGITS NVCaffe Documentation. NVCaffe Documenation - store_blobs_in_old_format