Comments (4)
#include <opencv2\opencv.hpp>
#include <opencv2\dnn.hpp>
#include
#include
#include
using namespace std;
using namespace cv;
using namespace cv::dnn;
int main()
{
//input
string classNameFile = "synset_words.txt";
String imageFile = "1.jpg";
String modelTxt = "deploy.prototxt";
String modelBin = "squeezenet_v1.0.caffemodel";
// image preprocessing
Mat img = imread(imageFile);
if (img.empty())
{
cerr << "fail to load the image" << endl;
exit(-1);
}
resize(img, img, Size(227, 227));
//read class name syssets word
vector className;
string name;
ifstream fp(classNameFile);
if (!fp.is_open())
{
cerr << "fail to load the class names";
}
while (!fp.eof())
{
getline(fp, name);
if (name.length())
{
className.push_back(name.substr(name.find(' ') + 1));
}
}
fp.close();
//load caffe model
cv::dnn::initModule();
Net CaffeNet = dnn::readNetFromCaffe(modelTxt, modelBin);
if (CaffeNet.empty())
{
cerr << "fail to load model" << endl;
exit(-1);
}
// forward pass
dnn::Blob imgBlob = dnn::Blob::fromImages(img);
CaffeNet.setBlob(".data", imgBlob);
CaffeNet.forward();
dnn::Blob probBlob = CaffeNet.getBlob("prob");
Mat proMat = probBlob.matRefConst().reshape(1, 1);
//
return 0;
}
this is the full code, and the problem comes from the last line
Mat proMat = probBlob.matRefConst().reshape(1, 1);
from squeezenet.
I somehow solved this by probBlob.getPlane()function
but still do not know why probBlob.matRefConst() didn't work
from squeezenet.
@chibai I download pre-built opencv 3.4.3 on my windows 10. But init_module is not the member of cv::dnn .
from squeezenet.
@chibai I download pre-built opencv 3.4.3 on my windows 10. But init_module is not the member of cv::dnn .
API always changed. Please refer the newest version https://github.com/opencv/opencv/blob/master/samples/dnn/classification.cpp
from squeezenet.
Related Issues (20)
- Has anyone successfully trained Squeezenet with residual connections?
- model convert HOT 1
- SqueezeNet v1.1 with Residual Connections with Dense→Sparse→Dense (DSD) Training
- Top-1 Acc=61.0% on ImageNet, without any sacrificing compared with SqueezeNet v1.1. HOT 4
- Image Width Issue HOT 1
- tensorflow- After hundreds of epochs, my total_loss stay around 0.6~0.7, and not decreased HOT 2
- 1.1 deploy.prototxt HOT 1
- SqueezeNet is slower when using GPU than when using CPU? HOT 2
- training from scratch, random seed HOT 1
- why can not get the output of the prob layer? HOT 1
- SqueezeNet training on cifar HOT 3
- The SqueezeNet deploy.caffemodel files have all 0.0 weight and bias data HOT 1
- Fine-tuning SqueezeNet HOT 2
- which label list you used HOT 1
- why not use lr_mult, decay_mult like {1, 1, 2, 0}? HOT 3
- optimization and compression
- Image normalization values HOT 1
- squeezenet v1_1 for facedetector , possible , feasable ? HOT 1
- squeezenet for speech HOT 3
- Some minor mistakes in the paper HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squeezenet.