Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure with model.forward() #9

Open
The-underground-Eugene opened this issue Jan 22, 2022 · 1 comment
Open

failure with model.forward() #9

The-underground-Eugene opened this issue Jan 22, 2022 · 1 comment

Comments

@The-underground-Eugene
Copy link

hey guys,

got this code
vector class_names;
ifstream ifs(string("F:\DNN\alphabet_36.txt").c_str());
string line;
while (getline(ifs, line))
{
class_names.push_back(line);
}

if (Rotated_Image.empty())
{
	cout << "CHECK IMAGE FILE PATH!" << endl;

}
else
{
	cout << "IMAGE SUCCESSFULLY READ!" << endl;
}

auto model = readNetFromONNX("F:\\DNN\\CRNN_VGG_BiLSTM_CTC.onnx");
if (model.empty())
{
	cout << " CAN'T LOAD NEURAL NETWORK MODEL" << endl;
	return 0;
}
else
{
	cout << " NEURAL NETWORK MODEL LOADED" << endl;
}
Mat blob = blobFromImage(Rotated_Image,1.0, Size(300, 300), Scalar(127.5, 127.5, 127.5),true,false);
model.setInput(blob);
Mat outputs = model.forward();
Point classIdPoint;
double final_prob;
minMaxLoc(outputs.reshape(1, 1), 0, &final_prob, 0, &classIdPoint);
int label_id = classIdPoint.x;
string out_text = format("%s, %.3f", (class_names[label_id].c_str()), final_prob);
// put the class name text on top of the image
putText(Rotated_Image, out_text, Point(25, 50), FONT_HERSHEY_SIMPLEX, 1, Scalar(0, 255, 0), 2);
imshow("[]***", Rotated_Image);

return 0;

but i get these errors
OpenCV(4.4.0) Error: Assertion failed (ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0) in cv::dnn::ConvolutionLayerImpl::getMemoryShapes, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\layers\convolution_layer.cpp, line 348
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\dnn.cpp (3444) cv::dnn::dnn4_v20200609::Net::Impl::getLayerShapesRecursively OPENCV/DNN: [Convolution]:(45): getMemoryShapes() throws exception. inputs=1 outputs=0/1 blobs=2
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\dnn.cpp (3447) cv::dnn::dnn4_v20200609::Net::Impl::getLayerShapesRecursively input[0] = [ 1 3 480 640 ]
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\dnn.cpp (3455) cv::dnn::dnn4_v20200609::Net::Impl::getLayerShapesRecursively blobs[0] = CV_32FC1 [ 64 1 3 3 ]
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\dnn.cpp (3455) cv::dnn::dnn4_v20200609::Net::Impl::getLayerShapesRecursively blobs[1] = CV_32FC1 [ 64 1 ]
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\dnn.cpp (3457) cv::dnn::dnn4_v20200609::Net::Impl::getLayerShapesRecursively Exception message: OpenCV(4.4.0) C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\layers\convolution_layer.cpp:348: error: (-215:Assertion failed) ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'

what did i miss

@iceberghbs
Copy link

so do I!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants