update yolov5s model, according to its v2.0 release
This commit is contained in:
parent
f5519c9fb8
commit
eadfd2e29f
@ -15,6 +15,7 @@ All the models are implemented in pytorch or mxnet first, and export a weights f
|
||||
- `2 June 2020`. yolov3 and yolov3-spp migrated to TensorRT 7 API. The new yolov3 is using pytorch implementation [ultralytics/yolov3](https://github.com/ultralytics/yolov3), the yolov3 in branch `trt4` was using pytorch implementation [ayooshkathuria/pytorch-yolo-v3](https://github.com/ayooshkathuria/pytorch-yolo-v3).
|
||||
- `23 June 2020`. Update yolov5-s model according to [ultralytics/yolov5](https://github.com/ultralytics/yolov5)'s PANet updates on 22 June 2020.
|
||||
- `6 July 2020`. Add yolov3-tiny, and got 333fps on GTX1080.
|
||||
- `1 Aug 2020`. Update yolov5-s model, according to its July 23, 2020: v2.0 release.
|
||||
|
||||
## Tutorials
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
The Pytorch implementation is [ultralytics/yolov5](https://github.com/ultralytics/yolov5).
|
||||
|
||||
I was using [ultralytics/yolov5](https://github.com/ultralytics/yolov5)(Commits on Jun 23, 2020). And I made a copy of [yolov5s.pt(google drive)](https://drive.google.com/file/d/1w38DgmrP3iwiJi_AOdabuuE_zanMhO5_/view?usp=sharing). Just in case the yolov5 model updated.
|
||||
I made a copy of [yolov5s.pt(google drive)](https://drive.google.com/drive/folders/1Yaamfa-t_V3ImxYRBESqGzy7k4Arlt95?usp=sharing). Just in case the yolov5 model updated.
|
||||
|
||||
## How to Run
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ ILayer* convBnLeaky(INetworkDefinition *network, std::map<std::string, Weights>&
|
||||
conv1->setStrideNd(DimsHW{s, s});
|
||||
conv1->setPaddingNd(DimsHW{p, p});
|
||||
conv1->setNbGroups(g);
|
||||
IScaleLayer* bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + ".bn", 1e-4);
|
||||
IScaleLayer* bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + ".bn", 1e-3);
|
||||
auto lr = network->addActivation(*bn1->getOutput(0), ActivationType::kLEAKY_RELU);
|
||||
lr->setAlpha(0.1);
|
||||
return lr;
|
||||
|
||||
@ -40,9 +40,9 @@ ICudaEngine* createEngine(unsigned int maxBatchSize, IBuilder* builder, IBuilder
|
||||
auto bottleneck_csp6 = bottleneckCSP(network, weightMap, *conv5->getOutput(0), 256, 256, 3, true, 1, 0.5, "model.6");
|
||||
auto conv7 = convBnLeaky(network, weightMap, *bottleneck_csp6->getOutput(0), 512, 3, 2, 1, "model.7");
|
||||
auto spp8 = SPP(network, weightMap, *conv7->getOutput(0), 512, 512, 5, 9, 13, "model.8");
|
||||
auto bottleneck_csp9 = bottleneckCSP(network, weightMap, *spp8->getOutput(0), 512, 512, 1, false, 1, 0.5, "model.9");
|
||||
|
||||
// yolov5 head
|
||||
auto bottleneck_csp9 = bottleneckCSP(network, weightMap, *spp8->getOutput(0), 512, 512, 1, false, 1, 0.5, "model.9");
|
||||
auto conv10 = convBnLeaky(network, weightMap, *bottleneck_csp9->getOutput(0), 256, 1, 1, 1, "model.10");
|
||||
|
||||
float *deval = reinterpret_cast<float*>(malloc(sizeof(float) * 256 * 2 * 2));
|
||||
@ -68,24 +68,24 @@ ICudaEngine* createEngine(unsigned int maxBatchSize, IBuilder* builder, IBuilder
|
||||
ITensor* inputTensors16[] = {deconv15->getOutput(0), bottleneck_csp4->getOutput(0)};
|
||||
auto cat16 = network->addConcatenation(inputTensors16, 2);
|
||||
auto bottleneck_csp17 = bottleneckCSP(network, weightMap, *cat16->getOutput(0), 256, 128, 1, false, 1, 0.5, "model.17");
|
||||
IConvolutionLayer* conv18 = network->addConvolutionNd(*bottleneck_csp17->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.18.weight"], weightMap["model.18.bias"]);
|
||||
IConvolutionLayer* det0 = network->addConvolutionNd(*bottleneck_csp17->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.24.m.0.weight"], weightMap["model.24.m.0.bias"]);
|
||||
|
||||
auto conv19 = convBnLeaky(network, weightMap, *bottleneck_csp17->getOutput(0), 128, 3, 2, 1, "model.19");
|
||||
ITensor* inputTensors20[] = {conv19->getOutput(0), conv14->getOutput(0)};
|
||||
auto cat20 = network->addConcatenation(inputTensors20, 2);
|
||||
auto bottleneck_csp21 = bottleneckCSP(network, weightMap, *cat20->getOutput(0), 256, 256, 1, false, 1, 0.5, "model.21");
|
||||
IConvolutionLayer* conv22 = network->addConvolutionNd(*bottleneck_csp21->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.22.weight"], weightMap["model.22.bias"]);
|
||||
auto conv18 = convBnLeaky(network, weightMap, *bottleneck_csp17->getOutput(0), 128, 3, 2, 1, "model.18");
|
||||
ITensor* inputTensors19[] = {conv18->getOutput(0), conv14->getOutput(0)};
|
||||
auto cat19 = network->addConcatenation(inputTensors19, 2);
|
||||
auto bottleneck_csp20 = bottleneckCSP(network, weightMap, *cat19->getOutput(0), 256, 256, 1, false, 1, 0.5, "model.20");
|
||||
IConvolutionLayer* det1 = network->addConvolutionNd(*bottleneck_csp20->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.24.m.1.weight"], weightMap["model.24.m.1.bias"]);
|
||||
|
||||
auto conv23 = convBnLeaky(network, weightMap, *bottleneck_csp21->getOutput(0), 256, 3, 2, 1, "model.23");
|
||||
ITensor* inputTensors24[] = {conv23->getOutput(0), conv10->getOutput(0)};
|
||||
auto cat24 = network->addConcatenation(inputTensors24, 2);
|
||||
auto bottleneck_csp25 = bottleneckCSP(network, weightMap, *cat24->getOutput(0), 512, 512, 1, false, 1, 0.5, "model.25");
|
||||
IConvolutionLayer* conv26 = network->addConvolutionNd(*bottleneck_csp25->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.26.weight"], weightMap["model.26.bias"]);
|
||||
auto conv21 = convBnLeaky(network, weightMap, *bottleneck_csp20->getOutput(0), 256, 3, 2, 1, "model.21");
|
||||
ITensor* inputTensors22[] = {conv21->getOutput(0), conv10->getOutput(0)};
|
||||
auto cat22 = network->addConcatenation(inputTensors22, 2);
|
||||
auto bottleneck_csp23 = bottleneckCSP(network, weightMap, *cat22->getOutput(0), 512, 512, 1, false, 1, 0.5, "model.23");
|
||||
IConvolutionLayer* det2 = network->addConvolutionNd(*bottleneck_csp23->getOutput(0), 3 * (Yolo::CLASS_NUM + 5), DimsHW{1, 1}, weightMap["model.24.m.2.weight"], weightMap["model.24.m.2.bias"]);
|
||||
|
||||
auto creator = getPluginRegistry()->getPluginCreator("YoloLayer_TRT", "1");
|
||||
const PluginFieldCollection* pluginData = creator->getFieldNames();
|
||||
IPluginV2 *pluginObj = creator->createPlugin("yololayer", pluginData);
|
||||
ITensor* inputTensors_yolo[] = {conv26->getOutput(0), conv22->getOutput(0), conv18->getOutput(0)};
|
||||
ITensor* inputTensors_yolo[] = {det2->getOutput(0), det1->getOutput(0), det0->getOutput(0)};
|
||||
auto yolo = network->addPluginV2(inputTensors_yolo, 3, *pluginObj);
|
||||
|
||||
yolo->getOutput(0)->setName(OUTPUT_BLOB_NAME);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user