New YOLOv5 conversion and support (>= v2.0)

This commit is contained in:
Marcos Luciano
2022-07-14 13:58:55 -03:00
parent ea31a54bbb
commit 8983e7e99e
2 changed files with 4 additions and 11 deletions

View File

@@ -18,18 +18,14 @@ nvinfer1::ILayer* maxpoolLayer(
int size = std::stoi(block.at("size"));
int stride = std::stoi(block.at("stride"));
int pad = 0;
if (block.find("pad") != block.end())
{
pad = std::stoi(block.at("pad"));
}
nvinfer1::IPoolingLayer* pool
= network->addPoolingNd(*input, nvinfer1::PoolingType::kMAX, nvinfer1::Dims{2, {size, size}});
assert(pool);
std::string maxpoolLayerName = "maxpool_" + std::to_string(layerIdx);
pool->setStrideNd(nvinfer1::Dims{2, {stride, stride}});
pool->setPaddingNd(nvinfer1::Dims{2, {pad, pad}});
if (stride == 1) {
pool->setPaddingNd(nvinfer1::Dims{2, {size / 2, size / 2}});
}
pool->setName(maxpoolLayerName.c_str());
return pool;

View File

@@ -210,16 +210,13 @@ class Layers(object):
stride = m.stride
size = m.kernel_size
pad = m.padding
mode = m.ceil_mode
m = 'maxpool_up' if mode else 'maxpool'
p = 'pad=%d\n' % pad if pad > 0 else ''
self.fc.write('\n[%s]\n' % m +
'stride=%d\n' % stride +
'size=%d\n' % size +
p)
'size=%d\n' % size)
def upsample(self, child):
self.blocks[self.current] += 1