Skip to content

Commit

Permalink
yolov5-v4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
enazoe committed Feb 7, 2021
1 parent 858bd63 commit c0288e2
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ api/
*.onnx
.ipynb_checkpoints
*.idea
Dockerfile
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![GitHub stars](https://img.shields.io/github/stars/enazoe/yolo-tensorrt) ![GitHub forks](https://img.shields.io/github/forks/enazoe/yolo-tensorrt) ![GitHub watchers](https://img.shields.io/github/watchers/enazoe/yolo-tensorrt) [![Gitter](https://badges.gitter.im/yolo-tensorrt/community.svg)](https://gitter.im/yolo-tensorrt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

__news:__ yolov5 support
__news:__ yolov5-v4.0 support

![](./configs/result.jpg)
## INTRODUCTION
Expand Down
2 changes: 1 addition & 1 deletion configs/yolov5-4.0/yolov5l.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
width=640
height=640
channels=3
batch=2
batch=1
nc=80
depth_multiple=1.0
width_multiple=1.0
Expand Down
2 changes: 1 addition & 1 deletion configs/yolov5-4.0/yolov5m.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
width=640
height=640
channels=3
batch=2
batch=1
nc=80
depth_multiple=0.67
width_multiple=0.75
Expand Down
2 changes: 1 addition & 1 deletion configs/yolov5-4.0/yolov5s.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
width=640
height=640
channels=3
batch=2
batch= 1
nc=80
depth_multiple=0.33
width_multiple=0.5
Expand Down
2 changes: 1 addition & 1 deletion configs/yolov5-4.0/yolov5x.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
width=640
height=640
channels=3
batch=2
batch=1
nc=80
depth_multiple=1.33
width_multiple=1.25
Expand Down
2 changes: 1 addition & 1 deletion modules/trt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ nvinfer1::ILayer * layer_bottleneck_csp(std::vector<nvinfer1::Weights> &trtWeigh
concatInputs[1] = cv2->getOutput(0);
auto cat = layer_concate(concatInputs, 2, 0,network_);
auto bn = layer_bn(trtWeights_, s_model_name_, map_wts_, cat->getOutput(0), 2 * c_, network_);
auto act = layer_act(bn->getOutput(0), network_,"leaky");
auto act = layer_act(bn->getOutput(0), network_,"silu");
//cv4
auto cv4 = layer_conv_bn_act(trtWeights_, s_model_name_ + ".cv4", map_wts_, act->getOutput(0), network_, c2_, 1);
return cv4;
Expand Down
4 changes: 2 additions & 2 deletions modules/trt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ nvinfer1::ILayer * layer_conv_bn_act(std::vector<nvinfer1::Weights> &trtWeights_
const int group_ =1,
const bool b_padding_ = true,
const bool b_bn_ = true,
const std::string s_act_ = "hardswish");
const std::string s_act_ = "silu");

nvinfer1::ILayer * layer_act(nvinfer1::ITensor* input_,
nvinfer1::INetworkDefinition* network_,
const std::string s_act_ = "hardswish");
const std::string s_act_ = "silu");

nvinfer1::ILayer * C3(std::vector<nvinfer1::Weights> &trtWeights_,
std::string s_model_name_,
Expand Down
6 changes: 3 additions & 3 deletions samples/sample_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ int main()
Config config_v5;
config_v5.net_type = YOLOV5;
config_v5.detect_thresh = 0.5;
config_v5.file_model_cfg = "../configs/yolov5-3.0/yolov5s.cfg";
config_v5.file_model_weights = "../configs/yolov5-3.0/yolov5s.weights";
config_v5.file_model_cfg = "../configs/yolov5-4.0/yolov5s.cfg";
config_v5.file_model_weights = "../configs/yolov5-4.0/yolov5s.weights";
config_v5.inference_precison = FP32;

std::unique_ptr<Detector> detector(new Detector());
detector->init(config_v4);
detector->init(config_v5);
cv::Mat image0 = cv::imread("../configs/dog.jpg", cv::IMREAD_UNCHANGED);
cv::Mat image1 = cv::imread("../configs/person.jpg", cv::IMREAD_UNCHANGED);
std::vector<BatchResult> batch_res;
Expand Down
12 changes: 10 additions & 2 deletions yolov5_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ This is tensorrt c++ api implementation of yolov5.
```shell
cp yolo-tensorrt/scripts/yaml2cfg.py yolov5/
python yaml2cfg.py
mv yolov5/models/yolov5.cfg yolo-tensorrt/configs/yolov5-3.0
mv yolov5/weights/yolov5.weights yolo-tensorrt/configs/yolov5-3.0
mv yolov5/models/yolov5.cfg yolo-tensorrt/configs/yolov5-4.0
mv yolov5/weights/yolov5.weights yolo-tensorrt/configs/yolov5-4.0
```

transformed models

| model | .yaml | .pt | .cfg | .weights |
| :----------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
| yolov5s-v4.0 | [yolov5s.yaml](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5s.pt](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5s.cfg](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) | [yolov5s.weights](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) |
| yolov5m-v4.0 | [yolov5m.yaml](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5m.pt](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5m.cfg](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) | [yolov5m.weights](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) |
| yolov5l-v4.0 | [yolov5l.yaml](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5l.pt](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5l.cfg](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) | [yolov5l.weights](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) |
| yolov5x-v4.0 | [yolov5x.yaml](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5x.pt](https://github.com/ultralytics/yolov5/releases/tag/v4.0) | [yolov5x.cfg](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) | [yolov5x.weights](https://mega.nz/folder/7iYTSARZ#-T3xXHBjRAUhOwdEe_ajKw) |


| model | .yaml | .pt | .cfg | .weights |
| :----------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
Expand Down

0 comments on commit c0288e2

Please sign in to comment.