Ask Your Question
0

dnn::Net work correctly in Debug and doesn't work in Release

asked 2019-03-18 12:21:29 -0600

Julliya gravatar image

Hello!

There is the strange problem in my solution.

I use pretrained caffe model with resnet-128, and when it's run in debug mode, result of forward() is correct, but in release mode method forward() returns cv::Mat with correct dimension and nan-elements. I tried use version 3.4.3 for windows (from site), and then tried migrating to 4.0.1, but result is the same.

My solution contains other caffe models, but they work correctly in both modes.

Where can I find a bug?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-03-22 05:51:31 -0600

Julliya gravatar image

I have managed to find the error in additional input data, I wrong created 4d cv::Mat 4d. The right way is

int s[] = { 1, n_channels, w, h };
cv::Mat blob = cv::Mat(4, s, CV_32F, cv::Scalar::all(val));

in my code was

int s[] = { 1, n_channels, w, h };
cv::Mat blob = cv::Mat(4, s, CV_32F);
cv::Mat unit(s[2], s[3], CV_32F, cv::Scalar(val));
for (int i = 0; i < s[1]; i++) {
    unit.copyTo(cv::Mat(unit.rows, unit.cols, CV_32F, blob.ptr((i, 0))));
}

Why it worked in the debug mode and did not work in the release mode I did not understand

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-03-18 12:21:29 -0600

Seen: 343 times

Last updated: Mar 18 '19