From bb157be82cc0b5d4464b4adde82e35fc1d640231 Mon Sep 17 00:00:00 2001 From: Davide Sapienza Date: Mon, 30 Mar 2020 18:55:32 +0200 Subject: [PATCH] Add TKDNN_CALIB_IMG_PATH and TKDNN_CALIB_LABRL_PATH variable This commit adds two variables for the calibration dataset. The first is reffered to .txt file that contains the list of the absolute paths of the images for the INT8 calitration. The second is referred to .txt file that contains the list of the absolute paths of the labels of the same images above. Signed-off-by: Davide Sapienza --- include/tkDNN/Network.h | 3 +++ src/Network.cpp | 6 ++++++ src/NetworkRT.cpp | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/tkDNN/Network.h b/include/tkDNN/Network.h index d21659a..f3b623d 100644 --- a/include/tkDNN/Network.h +++ b/include/tkDNN/Network.h @@ -1,6 +1,7 @@ #ifndef NETWORK_H #define NETWORK_H +#include #include "utils.h" namespace tk { namespace dnn { @@ -62,6 +63,8 @@ public: bool fp16, dla, int8; bool dontLoadWeights; + std::string fileImgList; + std::string fileLabelList; }; }} diff --git a/src/Network.cpp b/src/Network.cpp index 24152ec..2e4833b 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -34,6 +34,12 @@ Network::Network(dataDim_t input_dim) { int8 = true; } } + if(const char* env_p = std::getenv("TKDNN_CALIB_IMG_PATH")) + fileImgList = env_p; + + if(const char* env_p = std::getenv("TKDNN_CALIB_LABEL_PATH")) + fileLabelList = env_p; + if(fp16) std::cout<setInt8Mode(true); configRT->setFlag(BuilderFlag::kINT8); BatchStream calibrationStream(dim, 1, 100, //TODO: check if 100 images are sufficient to the calibration (or 4951) - "/home/xavier/Documents/tkDNN/demo/COCO_val2017/all_images.txt", - "/home/xavier/Documents/tkDNN/demo/COCO_val2017/all_labels.txt"); + net->fileImgList, net->fileLabelList); std::string modelName = name; calibrator.reset(new Int8EntropyCalibrator(calibrationStream, 1, "./" + modelName.substr(0, modelName.find('.')) + "-calibration.table",