Added YOLOR native support
YOLOR-CSP YOLOR-CSP* YOLOR-CSP-X YOLOR-CSP-X*
This commit is contained in:
32
nvdsinfer_custom_impl_Yolo/layers/channels_layer.cpp
Normal file
32
nvdsinfer_custom_impl_Yolo/layers/channels_layer.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Created by Marcos Luciano
|
||||
* https://www.github.com/marcoslucianops
|
||||
*/
|
||||
|
||||
#include "channels_layer.h"
|
||||
|
||||
nvinfer1::ILayer* channelsLayer(
|
||||
std::string type,
|
||||
nvinfer1::ITensor* input,
|
||||
nvinfer1::ITensor* implicitTensor,
|
||||
nvinfer1::INetworkDefinition* network)
|
||||
{
|
||||
nvinfer1::ILayer* output;
|
||||
|
||||
if (type == "shift") {
|
||||
nvinfer1::IElementWiseLayer* ew = network->addElementWise(
|
||||
*input, *implicitTensor,
|
||||
nvinfer1::ElementWiseOperation::kSUM);
|
||||
assert(ew != nullptr);
|
||||
output = ew;
|
||||
}
|
||||
else if (type == "control") {
|
||||
nvinfer1::IElementWiseLayer* ew = network->addElementWise(
|
||||
*input, *implicitTensor,
|
||||
nvinfer1::ElementWiseOperation::kPROD);
|
||||
assert(ew != nullptr);
|
||||
output = ew;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
20
nvdsinfer_custom_impl_Yolo/layers/channels_layer.h
Normal file
20
nvdsinfer_custom_impl_Yolo/layers/channels_layer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Created by Marcos Luciano
|
||||
* https://www.github.com/marcoslucianops
|
||||
*/
|
||||
|
||||
#ifndef __CHANNELS_LAYER_H__
|
||||
#define __CHANNELS_LAYER_H__
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "NvInfer.h"
|
||||
|
||||
nvinfer1::ILayer* channelsLayer(
|
||||
std::string type,
|
||||
nvinfer1::ITensor* input,
|
||||
nvinfer1::ITensor* implicitTensor,
|
||||
nvinfer1::INetworkDefinition* network);
|
||||
|
||||
#endif
|
||||
31
nvdsinfer_custom_impl_Yolo/layers/implicit_layer.cpp
Normal file
31
nvdsinfer_custom_impl_Yolo/layers/implicit_layer.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Created by Marcos Luciano
|
||||
* https://www.github.com/marcoslucianops
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "implicit_layer.h"
|
||||
|
||||
nvinfer1::ILayer* implicitLayer(
|
||||
int channels,
|
||||
std::vector<float>& weights,
|
||||
std::vector<nvinfer1::Weights>& trtWeights,
|
||||
int& weightPtr,
|
||||
nvinfer1::INetworkDefinition* network)
|
||||
{
|
||||
nvinfer1::Weights convWt{nvinfer1::DataType::kFLOAT, nullptr, channels};
|
||||
|
||||
float* val = new float[channels];
|
||||
for (int i = 0; i < channels; ++i)
|
||||
{
|
||||
val[i] = weights[weightPtr];
|
||||
weightPtr++;
|
||||
}
|
||||
convWt.values = val;
|
||||
trtWeights.push_back(convWt);
|
||||
|
||||
nvinfer1::IConstantLayer* implicit = network->addConstant(nvinfer1::Dims3{static_cast<int>(channels), 1, 1}, convWt);
|
||||
assert(implicit != nullptr);
|
||||
|
||||
return implicit;
|
||||
}
|
||||
22
nvdsinfer_custom_impl_Yolo/layers/implicit_layer.h
Normal file
22
nvdsinfer_custom_impl_Yolo/layers/implicit_layer.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Created by Marcos Luciano
|
||||
* https://www.github.com/marcoslucianops
|
||||
*/
|
||||
|
||||
#ifndef __IMPLICIT_LAYER_H__
|
||||
#define __IMPLICIT_LAYER_H__
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "NvInfer.h"
|
||||
|
||||
nvinfer1::ILayer* implicitLayer(
|
||||
int channels,
|
||||
std::vector<float>& weights,
|
||||
std::vector<nvinfer1::Weights>& trtWeights,
|
||||
int& weightPtr,
|
||||
nvinfer1::INetworkDefinition* network);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user