Skip to content

Commit c6499ac

Browse files
committed
Update README.md
1 parent 85cfd1b commit c6499ac

11 files changed

Lines changed: 30 additions & 14 deletions

File tree

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# TensorRT_Inference_Demo
22
<div align="center">
3-
<img src="assets/000000005001.jpg" height="200px" >
4-
<img src="assets/000000007816.jpg" height="200px" >
3+
<img src="assets/000000005001.jpg" height="200px" width="240px" >
4+
<img src="assets/000000142324.jpg" height="200px" width="240px" >
5+
<img src="assets/000000007816.jpg" height="200px" width="240px" >
6+
<img src="assets/000000017899.jpg" height="200px" width="150px" >
7+
8+
<img src="assets/000000157807.jpg" height="200px" width="240px" >
9+
<img src="assets/000000294695.jpg" height="200px"
10+
width="240px" >
11+
<img src="assets/000000579158.jpg" height="200px"
12+
width="240px" >
13+
<img src="assets/000000007977.jpg" height="200px" width="150px" >
514

615
</div>
716

@@ -38,7 +47,7 @@ This repo use TensorRT-8.x to deploy well-trained models, both image preprocessi
3847
- [x] [YOLOv8](https://github.com/ultralytics/ultralytics)<br>
3948
- [x] [YOLOv8-seg](https://github.com/ultralytics/ultralytics)<br>
4049
- [x] [RT-DETR](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/rtdetr)<br>
41-
- [ ] [YOLOv6](https://github.com/meituan/YOLOv6)<br>
50+
- [x] [YOLOv6](https://github.com/meituan/YOLOv6)<br>
4251
- [ ] [YOLO-NAS](https://github.com/Deci-AI/super-gradients) (to be continued)<br>
4352
</details>
4453

assets/000000017899.jpg

171 KB
Loading

assets/000000142324.jpg

169 KB
Loading

assets/000000157807.jpg

80 KB
Loading

assets/000000294695.jpg

115 KB
Loading

assets/000000579158.jpg

144 KB
Loading

include/basemodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Model {
1919
std::string onnx_file;
2020
std::string engine_file;
2121
std::string mode;
22-
AffineMatrix dst2src;
22+
std::vector<AffineMatrix> dst2src;
2323
int batchSize;
2424
int imageWidth;
2525
int imageHeight;

src/basemodel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void Model::LoadEngine(){
107107
}
108108

109109
void Model::PreProcess(std::vector<cv::Mat>& img_batch) {
110+
dst2src.reserve(batchSize);
110111
for (size_t i = 0; i < img_batch.size(); i++) {
111112
int height = img_batch[i].rows;
112113
int width = img_batch[i].cols;
@@ -115,9 +116,10 @@ void Model::PreProcess(std::vector<cv::Mat>& img_batch) {
115116
0.f, scale, (-scale * height + imageHeight + scale - 1) * 0.5);
116117
cv::Mat d2s = cv::Mat::zeros(2, 3, CV_32FC1);
117118
cv::invertAffineTransform(s2d, d2s);
118-
119-
memcpy(&dst2src, d2s.ptr(), sizeof(dst2src));
120-
preprocess(img_batch[i].ptr(), dst2src, width, height, &gpu_buffers[0][bufferSize[0] * i], imageWidth, imageHeight, stream);
119+
AffineMatrix mat;
120+
memcpy(&mat, d2s.ptr(), sizeof(mat));
121+
dst2src.emplace_back(mat);
122+
preprocess(img_batch[i].ptr(), mat, width, height, &gpu_buffers[0][bufferSize[0] * i], imageWidth, imageHeight, stream);
121123
CUDA_CHECK(cudaStreamSynchronize(stream));
122124
}
123125
}

src/rtdetr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ std::vector<Detections> RTDETR::PostProcess(const std::vector<cv::Mat> &imgBatch
3939
float* score_per_img = output2 + index * predscoreSize;
4040
cuda_postprocess_init(6, imageWidth, imageHeight);
4141
rtdetr_postprocess_box(box_per_img, score_per_img, num_bboxes, num_classes, 6,
42-
conf_thr, imageWidth, imageHeight, dst2src, stream, cpu_buffers[2]);
42+
conf_thr, imageWidth, imageHeight, dst2src[index], stream, cpu_buffers[2]);
4343
int num_boxes = std::min((int)cpu_buffers[2][0], 300);
4444
for (int i = 0; i < num_boxes; i++) {
4545
Box box;
@@ -56,5 +56,6 @@ std::vector<Detections> RTDETR::PostProcess(const std::vector<cv::Mat> &imgBatch
5656
index++;
5757
// cuda_postprocess_destroy();
5858
}
59+
dst2src.clear();
5960
return vec_result;
6061
}

src/yolo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::vector<Detections> YOLO::PostProcess(const std::vector<cv::Mat> &imgBatch,
4343
Detections result;
4444
float* pred_per_img = output + index * predSize;
4545
cuda_postprocess_init(7, imageWidth, imageHeight);
46-
postprocess_box(pred_per_img, num_bboxes, num_classes, 7, conf_thr, nms_thr, dst2src, stream, cpu_buffers[1]);
46+
postprocess_box(pred_per_img, num_bboxes, num_classes, 7, conf_thr, nms_thr, dst2src[index], stream, cpu_buffers[1]);
4747
int num_boxes = std::min((int)cpu_buffers[1][0], 1000);
4848
for (int i = 0; i < num_boxes; i++) {
4949
Box box;
@@ -59,7 +59,8 @@ std::vector<Detections> YOLO::PostProcess(const std::vector<cv::Mat> &imgBatch,
5959
}
6060
vec_result.emplace_back(result);
6161
index++;
62-
}
62+
}
63+
dst2src.clear();
6364
return vec_result;
6465
}
6566

@@ -107,7 +108,7 @@ std::vector<Segmentations> YOLO_seg::PostProcess(const std::vector<cv::Mat> &img
107108
Segmentations result;
108109
float* proto = output1 + index * protoSize;
109110
float* pred_per_img = output2 + index * predSize;
110-
postprocess_box_mask(pred_per_img, num_bboxes, num_classes, 39, conf_thr, nms_thr, dst2src, stream, cpu_buffers[1]);
111+
postprocess_box_mask(pred_per_img, num_bboxes, num_classes, 39, conf_thr, nms_thr, dst2src[index], stream, cpu_buffers[1]);
111112
int num_boxes = std::min((int)cpu_buffers[1][0], 1000);
112113
for (int i = 0; i < num_boxes; i++) {
113114
Instance ins;
@@ -130,5 +131,6 @@ std::vector<Segmentations> YOLO_seg::PostProcess(const std::vector<cv::Mat> &img
130131
index++;
131132
}
132133
// cuda_postprocess_destroy();
134+
dst2src.clear();
133135
return vec_result;
134136
}

0 commit comments

Comments
 (0)