Closed xjsxujingsong closed 3 years ago
Same is the case with scaled_yolov4, if you were able to solve it, please share the code snippet here. TIY
@chandu1263 The main problem is image width/height switch. I have quickly solved this problem, but have not tested throughtly. There are three places you need to change. In yolov5.cpp
grids = { {3, int(IMAGE_HEIGHT / stride[0]), int(IMAGE_WIDTH / stride[0])}, {3, int(IMAGE_HEIGHT / stride[1]), int(IMAGE_WIDTH / stride[1])}, {3, int(IMAGE_HEIGHT / stride[2]), int(IMAGE_WIDTH / stride[2])}, };
std::vector
box.x = (row[0] 2 - 0.5 + w) / grids[n][2] IMAGE_WIDTH ratio; box.y = (row[1] 2 - 0.5 + h) / grids[n][1] IMAGE_HEIGHT ratio;
@chandu1263 The main problem is image width/height switch. I have quickly solved this problem, but have not tested throughtly. There are three places you need to change. In yolov5.cpp 1. grids = { {3, int(IMAGE_HEIGHT / stride[0]), int(IMAGE_WIDTH / stride[0])}, {3, int(IMAGE_HEIGHT / stride[1]), int(IMAGE_WIDTH / stride[1])}, {3, int(IMAGE_HEIGHT / stride[2]), int(IMAGE_WIDTH / stride[2])}, };
std::vectorcv::Mat split_img = { cv::Mat(IMAGE_HEIGHT, IMAGE_WIDTH, CV_32FC1, data + channelLength (index + 2)), cv::Mat(IMAGE_HEIGHT, IMAGE_WIDTH, CV_32FC1, data + channelLength (index + 1)), cv::Mat(IMAGE_HEIGHT, IMAGE_WIDTH, CV_32FC1, data + channelLength * index) };
box.x = (row[0] 2 - 0.5 + w) / grids[n][2] IMAGE_WIDTH ratio; box.y = (row[1] 2 - 0.5 + h) / grids[n][1] IMAGE_HEIGHT ratio;
you are right!
solved and support yolov5 4.0
Thanks for your repo. I can successfully run yolov5 with 640x640 or 416x416. But it cannot detect anything with rectangle input image size. In export_onnx.py, I set default=[416, 640]. In config.yaml, I set IMAGE_WIDTH: 640, IMAGE_HEIGHT: 416.