diff --git a/README.md b/README.md
index 84e0037..d9927c0 100644
--- a/README.md
+++ b/README.md
@@ -353,7 +353,8 @@ This demo also creates a json file named ```net_name_COCO_res.json``` containing
| yolo4 | Yolov4 8 | [COCO 2017](http://cocodataset.org/) | 80 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/d97CFzYqCPCp5Hg/download) |
| yolo4_berkeley | Yolov4 8 | [BDD100K ](https://bair.berkeley.edu/blog/2018/05/30/bdd/) | 10 | 540x320 | [weights](https://cloud.hipert.unimore.it/s/nkWFa5fgb4NTdnB/download) |
| yolo4tiny | Yolov4 tiny 9 | [COCO 2017](http://cocodataset.org/) | 80 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/iRnc4pSqmx78gJs/download) |
-| yolo4x | Yolov4x-mish 9 | [COCO 2017](http://cocodataset.org/) | 80 | 672x672 | [weights](https://cloud.hipert.unimore.it/s/BLPpiAigZJLorQD/download) |
+| yolo4x | Yolov4x-mish 9 | [COCO 2017](http://cocodataset.org/) | 80 | 640x640 | [weights](https://cloud.hipert.unimore.it/s/5MFjtNtgbDGdJEo/download) |
+| yolo4x-cps | Scaled Yolov4 10 | [COCO 2017](http://cocodataset.org/) | 80 | 512x512 | [weights](https://cloud.hipert.unimore.it/s/AfzHE4BfTeEm2gH/download) |
## References
@@ -367,3 +368,4 @@ This demo also creates a json file named ```net_name_COCO_res.json``` containing
7. Wang, Chien-Yao, et al. "CSPNet: A New Backbone that can Enhance Learning Capability of CNN." arXiv preprint arXiv:1911.11929 (2019).
8. Bochkovskiy, Alexey, Chien-Yao Wang, and Hong-Yuan Mark Liao. "YOLOv4: Optimal Speed and Accuracy of Object Detection." arXiv preprint arXiv:2004.10934 (2020).
9. Bochkovskiy, Alexey, "Yolo v4, v3 and v2 for Windows and Linux" (https://github.com/AlexeyAB/darknet)
+10. Wang, Chien-Yao, Alexey Bochkovskiy, and Hong-Yuan Mark Liao. "Scaled-YOLOv4: Scaling Cross Stage Partial Network." arXiv preprint arXiv:2011.08036 (2020).
diff --git a/include/tkDNN/Layer.h b/include/tkDNN/Layer.h
index 25c4565..e097372 100644
--- a/include/tkDNN/Layer.h
+++ b/include/tkDNN/Layer.h
@@ -19,6 +19,7 @@ enum layerType_t {
LAYER_ACTIVATION_CRELU,
LAYER_ACTIVATION_LEAKY,
LAYER_ACTIVATION_MISH,
+ LAYER_ACTIVATION_LOGISTIC,
LAYER_FLATTEN,
LAYER_RESHAPE,
LAYER_MULADD,
@@ -68,6 +69,7 @@ public:
case LAYER_ACTIVATION_CRELU: return "ActivationCReLU";
case LAYER_ACTIVATION_LEAKY: return "ActivationLeaky";
case LAYER_ACTIVATION_MISH: return "ActivationMish";
+ case LAYER_ACTIVATION_LOGISTIC: return "ActivationLogistic";
case LAYER_FLATTEN: return "Flatten";
case LAYER_RESHAPE: return "Reshape";
case LAYER_MULADD: return "MulAdd";
@@ -212,7 +214,8 @@ public:
typedef enum {
ACTIVATION_ELU = 100,
ACTIVATION_LEAKY = 101,
- ACTIVATION_MISH = 102
+ ACTIVATION_MISH = 102,
+ ACTIVATION_LOGISTIC = 103
} tkdnnActivationMode_t;
/**
@@ -233,6 +236,8 @@ public:
return LAYER_ACTIVATION_LEAKY;
else if (act_mode == ACTIVATION_MISH)
return LAYER_ACTIVATION_MISH;
+ else if (act_mode == ACTIVATION_LOGISTIC)
+ return LAYER_ACTIVATION_LOGISTIC;
else
return LAYER_ACTIVATION;
};
diff --git a/include/tkDNN/NetworkRT.h b/include/tkDNN/NetworkRT.h
index 4c6c816..4fe2e0e 100644
--- a/include/tkDNN/NetworkRT.h
+++ b/include/tkDNN/NetworkRT.h
@@ -24,6 +24,7 @@ template T readBUF(const char*& buffer)
using namespace nvinfer1;
#include "pluginsRT/ActivationLeakyRT.h"
+#include "pluginsRT/ActivationLogisticRT.h"
#include "pluginsRT/ActivationReLUCeilingRT.h"
#include "pluginsRT/ActivationMishRT.h"
#include "pluginsRT/ReorgRT.h"
diff --git a/include/tkDNN/pluginsRT/ActivationLogisticRT.h b/include/tkDNN/pluginsRT/ActivationLogisticRT.h
new file mode 100644
index 0000000..a1ceb6b
--- /dev/null
+++ b/include/tkDNN/pluginsRT/ActivationLogisticRT.h
@@ -0,0 +1,60 @@
+#include
+#include "../kernels.h"
+
+class ActivationLogisticRT : public IPlugin {
+
+public:
+ ActivationLogisticRT() {
+
+
+ }
+
+ ~ActivationLogisticRT(){
+
+ }
+
+ int getNbOutputs() const override {
+ return 1;
+ }
+
+ Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) override {
+ return inputs[0];
+ }
+
+ void configure(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, int maxBatchSize) override {
+ size = 1;
+ for(int i=0; i(inputs[0]),
+ reinterpret_cast(outputs[0]), batchSize*size, stream);
+ return 0;
+ }
+
+
+ virtual size_t getSerializationSize() override {
+ return 1*sizeof(int);
+ }
+
+ virtual void serialize(void* buffer) override {
+ char *buf = reinterpret_cast(buffer);
+ tk::dnn::writeBUF(buf, size);
+ }
+
+ int size;
+};
diff --git a/include/tkDNN/pluginsRT/YoloRT.h b/include/tkDNN/pluginsRT/YoloRT.h
index 9af8587..f2bdaa1 100644
--- a/include/tkDNN/pluginsRT/YoloRT.h
+++ b/include/tkDNN/pluginsRT/YoloRT.h
@@ -67,15 +67,17 @@ public:
for (int b = 0; b < batchSize; ++b){
for(int n = 0; n < n_masks; ++n){
int index = entry_index(b, n*w*h, 0);
- if (new_coords == 1)
- activationLOGISTICForward(srcData + index, dstData + index, 4*w*h, stream); //x,y,w,h
- else
+ if (new_coords == 1){
+ if (this->scaleXY != 1) scalAdd(dstData + index, 2 * w*h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
+ }
+ else{
activationLOGISTICForward(srcData + index, dstData + index, 2*w*h, stream); //x,y
- if (this->scaleXY != 1) scalAdd(dstData + index, 2 * w*h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
+ if (this->scaleXY != 1) scalAdd(dstData + index, 2 * w*h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
- index = entry_index(b, n*w*h, 4);
- activationLOGISTICForward(srcData + index, dstData + index, (1+classes)*w*h, stream);
+ index = entry_index(b, n*w*h, 4);
+ activationLOGISTICForward(srcData + index, dstData + index, (1+classes)*w*h, stream);
+ }
}
}
diff --git a/scripts/test_all_tests.sh b/scripts/test_all_tests.sh
index af04aff..6aab775 100644
--- a/scripts/test_all_tests.sh
+++ b/scripts/test_all_tests.sh
@@ -69,10 +69,11 @@ do
echo -e "${ORANGE}Batch $TKDNN_BATCHSIZE ${NC}"
test_net mnist
- ./test_imuodom &>> $out_file
- print_output $? imuodom
+ # ./test_imuodom &>> $out_file
+ # print_output $? imuodom
test_net yolo4
+ test_net yolo4-csp
test_net yolo4x
test_net yolo4_berkeley
test_net yolo4tiny
diff --git a/src/Activation.cpp b/src/Activation.cpp
index 28c7624..a8642e7 100644
--- a/src/Activation.cpp
+++ b/src/Activation.cpp
@@ -52,6 +52,10 @@ dnnType* Activation::infer(dataDim_t &dim, dnnType* srcData) {
else if(act_mode == ACTIVATION_MISH) {
activationMishForward(srcData, dstData, dim.tot());
+ }
+ else if(act_mode == ACTIVATION_LOGISTIC) {
+ activationLOGISTICForward(srcData, dstData, dim.tot());
+
} else {
dnnType alpha = dnnType(1);
dnnType beta = dnnType(0);
diff --git a/src/DarknetParser.cpp b/src/DarknetParser.cpp
index 7b5410c..69b6b29 100644
--- a/src/DarknetParser.cpp
+++ b/src/DarknetParser.cpp
@@ -187,6 +187,7 @@ namespace tk { namespace dnn {
if(f.activation == "relu") act = tkdnnActivationMode_t(CUDNN_ACTIVATION_RELU);
else if(f.activation == "leaky") act = tk::dnn::ACTIVATION_LEAKY;
else if(f.activation == "mish") act = tk::dnn::ACTIVATION_MISH;
+ else if(f.activation == "logistic") act = tk::dnn::ACTIVATION_LOGISTIC;
else { FatalError("activation not supported: " + f.activation); }
netLayers[netLayers.size()-1] = new tk::dnn::Activation(net, act);
};
diff --git a/src/NetworkRT.cpp b/src/NetworkRT.cpp
index 501ade4..c915ba5 100644
--- a/src/NetworkRT.cpp
+++ b/src/NetworkRT.cpp
@@ -226,7 +226,7 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Layer *l) {
return convert_layer(input, (Conv2d*) l);
if(type == LAYER_POOLING)
return convert_layer(input, (Pooling*) l);
- if(type == LAYER_ACTIVATION || type == LAYER_ACTIVATION_CRELU || type == LAYER_ACTIVATION_LEAKY || type == LAYER_ACTIVATION_MISH)
+ if(type == LAYER_ACTIVATION || type == LAYER_ACTIVATION_CRELU || type == LAYER_ACTIVATION_LEAKY || type == LAYER_ACTIVATION_MISH || type == LAYER_ACTIVATION_LOGISTIC)
return convert_layer(input, (Activation*) l);
if(type == LAYER_SOFTMAX)
return convert_layer(input, (Softmax*) l);
@@ -421,6 +421,12 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Activation *l) {
checkNULL(lRT);
return lRT;
}
+ else if(l->act_mode == ACTIVATION_LOGISTIC) {
+ IPlugin *plugin = new ActivationLogisticRT();
+ IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
+ checkNULL(lRT);
+ return lRT;
+ }
else {
FatalError("this Activation mode is not yet implemented");
return NULL;
@@ -653,6 +659,11 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa
a->size = readBUF(buf);
return a;
}
+ if(name.find("ActivationLogistic") == 0) {
+ ActivationLogisticRT *a = new ActivationLogisticRT();
+ a->size = readBUF(buf);
+ return a;
+ }
if(name.find("ActivationCReLU") == 0) {
ActivationReLUCeiling *a = new ActivationReLUCeiling(readBUF(buf));
a->size = readBUF(buf);
diff --git a/src/Yolo.cpp b/src/Yolo.cpp
index 9737e74..61ed3cf 100644
--- a/src/Yolo.cpp
+++ b/src/Yolo.cpp
@@ -72,8 +72,8 @@ Yolo::box get_yolo_box(float *x, float *biases, int n, int index, int i, int j,
b.h = exp(x[index + 3*stride]) * biases[2*n+1] / h;
}
else{
- b.x = (i + x[index + 0 * stride] * 2 - 0.5) / lw;
- b.y = (j + x[index + 1 * stride] * 2 - 0.5) / lh;
+ b.x = (i + x[index + 0 * stride] ) / lw;
+ b.y = (j + x[index + 1 * stride] ) / lh;
b.w = x[index + 2 * stride] * x[index + 2 * stride] * 4 * biases[2 * n] / w;
b.h = x[index + 3 * stride] * x[index + 3 * stride] * 4 * biases[2 * n + 1] / h;
}
@@ -87,15 +87,18 @@ dnnType* Yolo::infer(dataDim_t &dim, dnnType* srcData) {
for (int b = 0; b < dim.n; ++b){
for(int n = 0; n < n_masks; ++n){
int index = entry_index(b, n*dim.w*dim.h, 0, classes, input_dim, output_dim);
- if (new_coords == 1)
- activationLOGISTICForward(srcData + index, dstData + index, 4*dim.w*dim.h);
- else
+ std::cout<<"new_coords"<scaleXY != 1) scalAdd(dstData + index, 2 * dim.w*dim.h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
+ }
+ else{
activationLOGISTICForward(srcData + index, dstData + index, 2*dim.w*dim.h);
- if (this->scaleXY != 1) scalAdd(dstData + index, 2 * dim.w*dim.h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
-
- index = entry_index(b, n*dim.w*dim.h, 4, classes, input_dim, output_dim);
- activationLOGISTICForward(srcData + index, dstData + index, (1+classes)*dim.w*dim.h);
+ if (this->scaleXY != 1) scalAdd(dstData + index, 2 * dim.w*dim.h, this->scaleXY, -0.5*(this->scaleXY - 1), 1);
+
+ index = entry_index(b, n*dim.w*dim.h, 4, classes, input_dim, output_dim);
+ activationLOGISTICForward(srcData + index, dstData + index, (1+classes)*dim.w*dim.h);
+ }
}
}
diff --git a/tests/darknet/cfg/yolo4-csp.cfg b/tests/darknet/cfg/yolo4-csp.cfg
new file mode 100644
index 0000000..691ec03
--- /dev/null
+++ b/tests/darknet/cfg/yolo4-csp.cfg
@@ -0,0 +1,1279 @@
+[net]
+# Testing
+#batch=1
+#subdivisions=1
+# Training
+batch=64
+subdivisions=8
+width=512
+height=512
+channels=3
+momentum=0.949
+decay=0.0005
+angle=0
+saturation = 1.5
+exposure = 1.5
+hue=.1
+
+learning_rate=0.001
+burn_in=1000
+max_batches = 500500
+policy=steps
+steps=400000,450000
+scales=.1,.1
+
+mosaic=1
+
+letter_box=1
+
+ema_alpha=0.9998
+
+#optimized_memory=1
+
+#23:104x104 54:52x52 85:26x26 104:13x13 for 416
+
+
+
+[convolutional]
+batch_normalize=1
+filters=32
+size=3
+stride=1
+pad=1
+activation=mish
+
+# Downsample
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=3
+stride=2
+pad=1
+activation=mish
+
+#[convolutional]
+#batch_normalize=1
+#filters=64
+#size=1
+#stride=1
+#pad=1
+#activation=mish
+
+#[route]
+#layers = -2
+
+#[convolutional]
+#batch_normalize=1
+#filters=64
+#size=1
+#stride=1
+#pad=1
+#activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=32
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+#[convolutional]
+#batch_normalize=1
+#filters=64
+#size=1
+#stride=1
+#pad=1
+#activation=mish
+
+#[route]
+#layers = -1,-7
+
+#[convolutional]
+#batch_normalize=1
+#filters=64
+#size=1
+#stride=1
+#pad=1
+#activation=mish
+
+# Downsample
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=2
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=64
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1,-10
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+# Downsample
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=2
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1,-28
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+# Downsample
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=3
+stride=2
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1,-28
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+# Downsample
+
+[convolutional]
+batch_normalize=1
+filters=1024
+size=3
+stride=2
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=3
+stride=1
+pad=1
+activation=mish
+
+[shortcut]
+from=-3
+activation=linear
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1,-16
+
+[convolutional]
+batch_normalize=1
+filters=1024
+size=1
+stride=1
+pad=1
+activation=mish
+
+##########################
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=512
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+### SPP ###
+[maxpool]
+stride=1
+size=5
+
+[route]
+layers=-2
+
+[maxpool]
+stride=1
+size=9
+
+[route]
+layers=-4
+
+[maxpool]
+stride=1
+size=13
+
+[route]
+layers=-1,-3,-5,-6
+### End SPP ###
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=512
+activation=mish
+
+[route]
+layers = -1, -13
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[upsample]
+stride=2
+
+[route]
+layers = 79
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1, -3
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=256
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=256
+activation=mish
+
+[route]
+layers = -1, -6
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[upsample]
+stride=2
+
+[route]
+layers = 48
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -1, -3
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=128
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=128
+activation=mish
+
+[route]
+layers = -1, -6
+
+[convolutional]
+batch_normalize=1
+filters=128
+size=1
+stride=1
+pad=1
+activation=mish
+
+##########################
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=256
+activation=mish
+
+[convolutional]
+size=1
+stride=1
+pad=1
+filters=255
+activation=logistic
+
+
+[yolo]
+mask = 0,1,2
+anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
+classes=80
+num=9
+jitter=.1
+scale_x_y = 2.0
+objectness_smooth=0
+ignore_thresh = .7
+truth_thresh = 1
+#random=1
+resize=1.5
+iou_thresh=0.2
+iou_normalizer=0.05
+cls_normalizer=0.5
+obj_normalizer=4.0
+iou_loss=ciou
+nms_kind=diounms
+beta_nms=0.6
+new_coords=1
+max_delta=5
+
+[route]
+layers = -4
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=2
+pad=1
+filters=256
+activation=mish
+
+[route]
+layers = -1, -20
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=256
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=256
+activation=mish
+
+[route]
+layers = -1,-6
+
+[convolutional]
+batch_normalize=1
+filters=256
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=512
+activation=mish
+
+[convolutional]
+size=1
+stride=1
+pad=1
+filters=255
+activation=logistic
+
+
+[yolo]
+mask = 3,4,5
+anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
+classes=80
+num=9
+jitter=.1
+scale_x_y = 2.0
+objectness_smooth=1
+ignore_thresh = .7
+truth_thresh = 1
+#random=1
+resize=1.5
+iou_thresh=0.2
+iou_normalizer=0.05
+cls_normalizer=0.5
+obj_normalizer=1.0
+iou_loss=ciou
+nms_kind=diounms
+beta_nms=0.6
+new_coords=1
+max_delta=5
+
+[route]
+layers = -4
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=2
+pad=1
+filters=512
+activation=mish
+
+[route]
+layers = -1, -49
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[route]
+layers = -2
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=512
+activation=mish
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=512
+activation=mish
+
+[route]
+layers = -1,-6
+
+[convolutional]
+batch_normalize=1
+filters=512
+size=1
+stride=1
+pad=1
+activation=mish
+
+[convolutional]
+batch_normalize=1
+size=3
+stride=1
+pad=1
+filters=1024
+activation=mish
+
+[convolutional]
+size=1
+stride=1
+pad=1
+filters=255
+activation=logistic
+
+
+[yolo]
+mask = 6,7,8
+anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
+classes=80
+num=9
+jitter=.1
+scale_x_y = 2.0
+objectness_smooth=1
+ignore_thresh = .7
+truth_thresh = 1
+#random=1
+resize=1.5
+iou_thresh=0.2
+iou_normalizer=0.05
+cls_normalizer=0.5
+obj_normalizer=0.4
+iou_loss=ciou
+nms_kind=diounms
+beta_nms=0.6
+new_coords=1
+max_delta=2
diff --git a/tests/darknet/cfg/yolo4x.cfg b/tests/darknet/cfg/yolo4x.cfg
index 89f2564..2ff854f 100644
--- a/tests/darknet/cfg/yolo4x.cfg
+++ b/tests/darknet/cfg/yolo4x.cfg
@@ -5,8 +5,8 @@
# Training
batch=64
subdivisions=8
-width=672
-height=672
+width=640
+height=640
channels=3
momentum=0.949
decay=0.0005
@@ -15,7 +15,7 @@ saturation = 1.5
exposure = 1.5
hue=.1
-learning_rate=0.00261
+learning_rate=0.001
burn_in=1000
max_batches = 500500
policy=steps
@@ -26,6 +26,8 @@ mosaic=1
letter_box=1
+#optimized_memory=1
+
[convolutional]
batch_normalize=1
filters=32
@@ -1131,6 +1133,7 @@ size=1
stride=1
pad=1
activation=mish
+stopbackward=800
##########################
@@ -1147,7 +1150,7 @@ size=1
stride=1
pad=1
filters=255
-activation=linear
+activation=logistic
[yolo]
@@ -1156,6 +1159,7 @@ anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 4
classes=80
num=9
jitter=.1
+scale_x_y = 2.0
objectness_smooth=0
ignore_thresh = .7
truth_thresh = 1
@@ -1169,6 +1173,7 @@ iou_loss=ciou
nms_kind=diounms
beta_nms=0.6
new_coords=1
+max_delta=5
[route]
layers = -4
@@ -1275,7 +1280,7 @@ size=1
stride=1
pad=1
filters=255
-activation=linear
+activation=logistic
[yolo]
@@ -1284,6 +1289,7 @@ anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 4
classes=80
num=9
jitter=.1
+scale_x_y = 2.0
objectness_smooth=1
ignore_thresh = .7
truth_thresh = 1
@@ -1297,6 +1303,7 @@ iou_loss=ciou
nms_kind=diounms
beta_nms=0.6
new_coords=1
+max_delta=5
[route]
layers = -4
@@ -1403,7 +1410,7 @@ size=1
stride=1
pad=1
filters=255
-activation=linear
+activation=logistic
[yolo]
@@ -1412,6 +1419,7 @@ anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 4
classes=80
num=9
jitter=.1
+scale_x_y = 2.0
objectness_smooth=1
ignore_thresh = .7
truth_thresh = 1
@@ -1425,3 +1433,4 @@ iou_loss=ciou
nms_kind=diounms
beta_nms=0.6
new_coords=1
+max_delta=2
diff --git a/tests/darknet/yolo4-csp.cpp b/tests/darknet/yolo4-csp.cpp
new file mode 100644
index 0000000..af8a7fc
--- /dev/null
+++ b/tests/darknet/yolo4-csp.cpp
@@ -0,0 +1,36 @@
+#include
+#include
+#include "tkdnn.h"
+#include "test.h"
+#include "DarknetParser.h"
+
+int main() {
+ std::string bin_path = "yolo4-csp";
+ std::vector input_bins = {
+ bin_path + "/layers/input.bin"
+ };
+ std::vector output_bins = {
+ bin_path + "/debug/layer144_out.bin",
+ bin_path + "/debug/layer159_out.bin",
+ bin_path + "/debug/layer174_out.bin"
+ };
+ std::string wgs_path = bin_path + "/layers";
+ std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo4-csp.cfg";
+ std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
+ downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/AfzHE4BfTeEm2gH/download");
+
+
+
+ // parse darknet network
+ tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path);
+ net->print();
+
+ //convert network to tensorRT
+ tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
+
+ int ret = testInference(input_bins, output_bins, net, netRT);
+ net->releaseLayers();
+ delete net;
+ delete netRT;
+ return ret;
+}
diff --git a/tests/darknet/yolo4x.cpp b/tests/darknet/yolo4x.cpp
index b9ad003..8df1aef 100644
--- a/tests/darknet/yolo4x.cpp
+++ b/tests/darknet/yolo4x.cpp
@@ -17,7 +17,7 @@ int main() {
std::string wgs_path = bin_path + "/layers";
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo4x.cfg";
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
- downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/BLPpiAigZJLorQD/download");
+ downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/5MFjtNtgbDGdJEo/download");