Closed PaRowsome closed 2 years ago
When I export my yolov7.onnx file with the following command
python3 ./export.py --onnx ../model/yolov7.onnx --engine model.trt -p int8 -v --calib_input ../data/images/ --calib_batch_size 256
When I run the resulting
model.trt
I get no output. I have tried on several images, and none have produced an output.The one thing i changed in the export python script was to uncomment this line https://github.com/Linaom1214/TensorRT-For-YOLO-Series/blob/main/export.py#L234 and comment on the following line.
Any help would be appreciated.
thanks!
This is mistake is fixed,
now you can git pull the newest code .
Hi! how it could be infer on python faster than in c++? I used your python and c++ examples? And when i'm trying to do infer on c++ with web cam it never be faster then 115 in average? when i put video file in capture in c++ its fps about 370 and when i'm doing the same in python it shows me 460 ?
`fps = 0 import time t_tick = 0 while True: ret, frame = cap.read() if not ret: break blob, ratio = preproc(frame, imgsz, mean, std) t1 = time.time() start_time = cv2.getTickCount() data = infer(blob)
if end2end:
num, final_boxes, final_scores, final_cls_inds = data
final_boxes = np.reshape(final_boxes / ratio, (-1, 4))
dets = np.concatenate([final_boxes[:num[0]], np.array(final_scores)[:num[0]].reshape(-1, 1),
np.array(final_cls_inds)[:num[0]].reshape(-1, 1)], axis=-1)
else:
predictions = np.reshape(data, (1, -1, int(5 + n_classes)))[0]
dets = postprocess(predictions, ratio)
if dets is not None:
final_boxes, final_scores, final_cls_inds = dets[:,
:4], dets[:, 4], dets[:, 5]
frame = vis(frame, final_boxes, final_scores, final_cls_inds,
conf=conf, class_names= class_names)
t_tick = (cv2.getTickCount() - start_time) / cv2.getTickFrequency()
fps = 1 / t_tick
frame = cv2.putText(frame, "FPS:%d " % fps, (0, 40), cv2.FONT_HERSHEY_SIMPLEX, 1,
(0, 0, 255), 2)
cv2.imshow('frame', frame)`
fps = 409.18522628556786 fps = 426.4994333955027 fps = 437.3316819689022 fps = 394.09115486048387 fps = 449.33419905055683
` double t_tick = 0; double fps = 0;
cv::Mat img;
while (cap.isOpened())
{
cap >> img;
double t_start = cv::getTickCount();
if(img.empty()){
std::cout << "Can't read frame or end of file " << std::endl;
break;
}
yolo.Infer(img.cols, img.rows, img.channels(), img.data, Boxes, ClassIndexs, Scores, BboxNum);
yolo.draw_objects(img, Boxes, ClassIndexs, Scores, BboxNum, t_tick, t_start, fps);
t_tick = ((double)cv::getTickCount()-t_start)/cv::getTickFrequency();
fps = 1/t_tick;
cv::putText(img, cv::format("fps :%.3f", fps), cv::Point(10, 20), cv::FONT_HERSHEY_COMPLEX, 0.7, cv::Scalar(0,255,0), 2, 5);
// myvideo.write(img);
cv::imshow("result", img);`
fps =356.763 fps =359.59 fps =360.613 fps =341.521 fps =368.212
` double t_tick = 0; double fps = 0;
cv::Mat img; while (cap.isOpened()) { cap >> img; double t_start = cv::getTickCount(); if(img.empty()){ std::cout << "Can't read frame or end of file " << std::endl; break; } yolo.Infer(img.cols, img.rows, img.channels(), img.data, Boxes, ClassIndexs, Scores, BboxNum); yolo.draw_objects(img, Boxes, ClassIndexs, Scores, BboxNum, t_tick, t_start, fps); t_tick = ((double)cv::getTickCount()-t_start)/cv::getTickFrequency(); fps = 1/t_tick; cv::putText(img, cv::format("fps :%.3f", fps), cv::Point(10, 20), cv::FONT_HERSHEY_COMPLEX, 0.7, cv::Scalar(0,255,0), 2, 5);
// myvideo.write(img);
cv::imshow("result", img);`
fps =330.664
fps =356.763 fps =359.59 fps =360.613 fps =341.521 fps =368.212
the image process function is different between c++ and python. C++ https://github.com/Linaom1214/TensorRT-For-YOLO-Series/blob/8c9189ef6d50ea1c36b1232b172f3221847e5791/cpp/end2end/main.cpp#L81 meanwhile, I think the c++ code needs more optim.
When I export my yolov7.onnx file with the following command
python3 ./export.py --onnx ../model/yolov7.onnx --engine model.trt -p int8 -v --calib_input ../data/images/ --calib_batch_size 256
When I run the resulting
model.trt
I get no output. I have tried on several images, and none have produced an output.The one thing i changed in the export python script was to uncomment this line https://github.com/Linaom1214/TensorRT-For-YOLO-Series/blob/main/export.py#L234 and comment on the following line.
Any help would be appreciated.