angeladai / cnncomplete

[CVPR'17] Shape Completion using 3D-Encoder-Predictor CNNs and Shape Synthesis
http://graphics.stanford.edu/projects/cnncomplete/
Other
140 stars 24 forks source link

failure with model.forward() #9

Open The-underground-Eugene opened 2 years ago

The-underground-Eugene commented 2 years ago

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 commented 2 years ago

so do I!