Skip to content

Commit

Permalink
add YOLOv9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Melody-Zhou committed Mar 5, 2024
1 parent e56b38f commit 0315b15
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/application/app_yolo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,6 @@ int app_yolo(){
// test(Yolo::Type::V5, TRT::Mode::FP32, "yolov5s");
// test(Yolo::Type::V6, TRT::Mode::FP32, "yolov6s");
// test(Yolo::Type::V7, TRT::Mode::FP32, "yolov7");
// test(Yolo::Type::V9, TRT::Mode::FP32, "yolov9c");
return 0;
}
7 changes: 4 additions & 3 deletions src/application/app_yolo/yolo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Yolo{
case Type::V6: return "YoloV6";
case Type::V8: return "YoloV8";
case Type::X: return "YoloX";
case Type::V9: return "YoloV9";
default: return "Unknow";
}
}
Expand Down Expand Up @@ -169,7 +170,7 @@ namespace Yolo{
NMSMethod nms_method, int max_objects,
bool use_multi_preprocess_stream
){
if(type == Type::V5 || type == Type::V3 || type == Type::V7 || type == Type::V8 || type == Type::V6){
if(type == Type::V5 || type == Type::V3 || type == Type::V7 || type == Type::V8 || type == Type::V6 || type == Type::V9){
normalize_ = CUDAKernel::Norm::alpha_beta(1 / 255.0f, 0.0f, CUDAKernel::ChannelType::Invert);
}else if(type == Type::X){
//float mean[] = {0.485, 0.456, 0.406};
Expand Down Expand Up @@ -211,7 +212,7 @@ namespace Yolo{
int max_batch_size = engine->get_max_batch_size();
auto input = engine->tensor("images");
auto output = engine->tensor("output");
int num_classes = (type_ == Type::V8) ? output->size(2) - 4 : output->size(2) - 5;
int num_classes = (type_ == Type::V8 || type_ == Type::V9) ? output->size(2) - 4 : output->size(2) - 5;

input_width_ = input->size(3);
input_height_ = input->size(2);
Expand Down Expand Up @@ -406,7 +407,7 @@ namespace Yolo{
void image_to_tensor(const cv::Mat& image, shared_ptr<TRT::Tensor>& tensor, Type type, int ibatch){

CUDAKernel::Norm normalize;
if(type == Type::V5 || type == Type::V3 || type == Type::V7 || type == Type::V8 || type == Type::V6){
if(type == Type::V5 || type == Type::V3 || type == Type::V7 || type == Type::V8 || type == Type::V6 || type == Type::V9){
normalize = CUDAKernel::Norm::alpha_beta(1 / 255.0f, 0.0f, CUDAKernel::ChannelType::Invert);
}else if(type == Type::X){
//float mean[] = {0.485, 0.456, 0.406};
Expand Down
3 changes: 2 additions & 1 deletion src/application/app_yolo/yolo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace Yolo{
V3 = 2,
V7 = 3,
V8 = 4,
V6 = 5
V6 = 5,
V9 = 6
};

enum class NMSMethod : int{
Expand Down
2 changes: 1 addition & 1 deletion src/application/app_yolo/yolo_decode.cu
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace Yolo{

auto grid = CUDATools::grid_dims(num_bboxes);
auto block = CUDATools::block_dims(num_bboxes);
if(type == Type::V8){
if(type == Type::V8 || type == Type::V9){
checkCudaKernel(decode_kernel_v8<<<grid, block, 0, stream>>>(predict, num_bboxes, num_classes, confidence_threshold, invert_affine_matrix, parray, max_objects));
}else{
checkCudaKernel(decode_kernel<<<grid, block, 0, stream>>>(predict, num_bboxes, num_classes, confidence_threshold, invert_affine_matrix, parray, max_objects));
Expand Down

0 comments on commit 0315b15

Please sign in to comment.