Comments (18)
加个防呆,像你这个如果超过的72的话,就用72.这部分等会我更新下看看,你可以自己加上去。
from yolov5-seg-opencv-onnxruntime-cpp.
还会有崩溃:
mask是64102
但是box确是65102
football1.zip
您测试一下下面这个附件视频
from yolov5-seg-opencv-onnxruntime-cpp.
模型是yolov5-seg.onnx么
from yolov5-seg-opencv-onnxruntime-cpp.
我就是跑这个视频时,崩溃的,图片不崩溃,不好抓崩溃的图
from yolov5-seg-opencv-onnxruntime-cpp.
跟模型没关系,就是有些超限判断,n模型和s模型,都会崩溃
from yolov5-seg-opencv-onnxruntime-cpp.
引擎是onnxruntime还是opencv
from yolov5-seg-opencv-onnxruntime-cpp.
onnxruntime和opencv两个都会崩溃
from yolov5-seg-opencv-onnxruntime-cpp.
from yolov5-seg-opencv-onnxruntime-cpp.
你更新下除了main.cpp外的文件看下还会不会
from yolov5-seg-opencv-onnxruntime-cpp.
奇怪了。我重新更新下,跑一下。
from yolov5-seg-opencv-onnxruntime-cpp.
你更新下除了main.cpp外的文件看下还会不会
这个地方,是一个很玄虚的地方
cv::Vec4f params = mask_params.params;
这个变量名称是只有params不会报错,也不会崩溃
from yolov5-seg-opencv-onnxruntime-cpp.
崩溃就是那个越界问题:
其他地方,啥都不用动,就更改一下这个变量的名称,那个视频就立马崩溃。
另外,这个mask_params.params,我直接使用外部的这个LetterBox的变量,也崩溃:
只有按照您的代码,并且名称也必须是cv::Vec4f params = mask_params.params;就不崩溃
from yolov5-seg-opencv-onnxruntime-cpp.
变量名修改不是问题,应该是哪里修改没改完整,导致某一帧的参数不一致,但是你这里的参数没有修改过来导致的。我这里的零时变量又不是什么智能指针啥的,像unique_ptr这个坑,使用一次就失效了。
from yolov5-seg-opencv-onnxruntime-cpp.
那个变量问题,确实是我下面没改过来导致的,但是另外一个诡异的问题是,我吧Getmask2里面的内容,复制出来替换了Getmask2,在这个里面,我使用直接使用params,而不是mask_params中的params,就会崩溃:
for (int i = 0; i < temp_mask_proposals.size(); ++i) {
//GetMask2(cv::Mat(temp_mask_proposals[i]).t(), net_output_img[1], output[i], mask_params);
cv::Mat maskProposals = Mat(temp_mask_proposals[i]).t();
cv::Mat maskProtos = net_output_img[1];
int seg_channels = mask_params.segChannels;
int net_width = mask_params.netWidth;
int seg_width = mask_params.segWidth;
int net_height = mask_params.netHeight;
int seg_height = mask_params.segHeight;
float mask_threshold = mask_params.maskThreshold;
cv::Vec4f maskparams = mask_params.params;
cv::Size src_img_shape = mask_params.srcImgShape;
cv::Rect temp_rect = output[i].box;
//crop from mask_protos
//int rang_x = floor((temp_rect.x * maskparams[0] + maskparams[2]) / net_width * seg_width);
//int rang_y = floor((temp_rect.y * maskparams[1] + maskparams[3]) / net_height * seg_height);
//int rang_w = ceil(((temp_rect.x + temp_rect.width) * maskparams[0] + maskparams[2]) / net_width * seg_width) - rang_x;
//int rang_h = ceil(((temp_rect.y + temp_rect.height) * maskparams[1] + maskparams[3]) / net_height * seg_height) - rang_y;
int rang_x = floor((temp_rect.x * params[0] + params[2]) / net_width * seg_width);
int rang_y = floor((temp_rect.y * params[1] + params[3]) / net_height * seg_height);
int rang_w = ceil(((temp_rect.x + temp_rect.width) * params[0] + params[2]) / net_width * seg_width) - rang_x;
int rang_h = ceil(((temp_rect.y + temp_rect.height) * params[1] + params[3]) / net_height * seg_height) - rang_y;
//int rang_x = floor((temp_rect.x * params[0] + params[2]) / _netWidth * _segWidth);
//int rang_y = floor((temp_rect.y * params[1] + params[3]) / _netHeight * _segHeight);
//int rang_w = ceil(((temp_rect.x + temp_rect.width) * params[0] + params[2]) / _netWidth * _segWidth) - rang_x;
//int rang_h = ceil(((temp_rect.y + temp_rect.height) * params[1] + params[3]) / _netHeight * _segHeight) - rang_y;
rang_w = MAX(rang_w, 1);
rang_h = MAX(rang_h, 1);
if (rang_x + rang_w > seg_width) {
if (seg_width - rang_x > 0)
rang_w = seg_width - rang_x;
else
rang_x -= 1;
}
if (rang_y + rang_h > seg_height) {
if (seg_height - rang_y > 0)
rang_h = seg_height - rang_y;
else
rang_y -= 1;
}
vector<cv::Range> roi_rangs;
roi_rangs.push_back(cv::Range(0, 1));
roi_rangs.push_back(cv::Range::all());
roi_rangs.push_back(cv::Range(rang_y, rang_h + rang_y));
roi_rangs.push_back(cv::Range(rang_x, rang_w + rang_x));
//crop
cv::Mat temp_mask_protos = maskProtos(roi_rangs).clone();
cv::Mat protos = temp_mask_protos.reshape(0, { seg_channels,rang_w * rang_h });
cv::Mat matmul_res = (maskProposals * protos).t();
cv::Mat masks_feature = matmul_res.reshape(1, { rang_h,rang_w });
cv::Mat dest, mask;
//sigmoid
cv::exp(-masks_feature, dest);
dest = 1.0 / (1.0 + dest);
int left = floor((net_width / seg_width * rang_x - params[2]) / params[0]);
int top = floor((net_height / seg_height * rang_y - params[3]) / params[1]);
int width = ceil(net_width / seg_width * rang_w / params[0]);
int height = ceil(net_height / seg_height * rang_h / params[1]);
resize(dest, mask, cv::Size(width, height), INTER_NEAREST);
mask = mask(temp_rect - cv::Point(left, top)) > mask_threshold;
output[i].boxMask = mask;
}
from yolov5-seg-opencv-onnxruntime-cpp.
from yolov5-seg-opencv-onnxruntime-cpp.
这种情况只能debug一下看看你这个变了量从哪里开始变得和params不一致,是什么原因导致的。
from yolov5-seg-opencv-onnxruntime-cpp.
我debug看了,一样的。就是很神奇。
from yolov5-seg-opencv-onnxruntime-cpp.
我昨天看了下你的修改,大概问题是出现在你改完之后,最终的mask和检测框大小不一致的问题,甚至会出现mask比检测框大的情况,你按照这个方向去debug,看下是哪里的问题,不至于说改个参数名就会导致失败,不然就是你改完参数名之后,有些地方没有修改完整等。
from yolov5-seg-opencv-onnxruntime-cpp.
Related Issues (20)
- 错误字符串 HOT 4
- 请问onnxruntime安装是GPU版本的吗?【目前,我使用onnxruntime-cpu 1.12.0可以解决问题了】 HOT 9
- BUG HOT 3
- 预训练模型加载正常,但自训练模型报错 HOT 2
- 怎么使用? HOT 8
- 请问这种情况是哪地方错误了? HOT 5
- 为什么运行不出现结果 HOT 1
- 为什么c++推理时间比python中的推理时间更长? HOT 12
- onnxruntime推理出错 HOT 3
- 引发了异常: 读取访问权限冲突。 **Ort::GetApi**(...) 返回 nullptr。 HOT 2
- 移植问题 HOT 8
- 如何在ubuntu下运行? HOT 2
- undefined reference to `OrtSessionOptionsAppendExecutionProvider_CUDA' HOT 1
- Detect failed! HOT 1
- 运行时间 HOT 1
- mask =mask(temp_rect -Point(left, top)) > mask_threshold;请问这句话是什么意思?我总是在这里报错 HOT 8
- GPU推理内存占用过大 HOT 3
- c++推理结果与python推理结果不一致问题 HOT 16
- Does this software work in a Ubuntu 18.04 machine without GPU? HOT 7
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 yolov5-seg-opencv-onnxruntime-cpp.