diff --git a/yolov8/README.md b/yolov8/README.md index 0ceb1b5e..ecc44991 100644 --- a/yolov8/README.md +++ b/yolov8/README.md @@ -141,7 +141,7 @@ python yolov8_pose_trt.py # Pose Estimation 2. unzip it in yolov8/build -3. set the macro `USE_INT8` in config.h and make +3. set the macro `USE_INT8` in config.h, change `kInputQuantizationFolder` into your image folder path and make 4. serialize the model and test diff --git a/yolov8/include/config.h b/yolov8/include/config.h index 66ef7e4c..44773a31 100644 --- a/yolov8/include/config.h +++ b/yolov8/include/config.h @@ -15,6 +15,8 @@ const static float kConfThresh = 0.5f; const static float kConfThreshKeypoints = 0.5f; // keypoints confidence const static int kMaxInputImageSize = 3000 * 3000; const static int kMaxNumOutputBbox = 1000; +//Quantization input image folder path +const static char* kInputQuantizationFolder = "./coco_calib"; // Classfication model's number of classes constexpr static int kClsNumClass = 1000; diff --git a/yolov8/src/model.cpp b/yolov8/src/model.cpp index a5f7e8e5..c9354220 100644 --- a/yolov8/src/model.cpp +++ b/yolov8/src/model.cpp @@ -311,8 +311,8 @@ nvinfer1::IHostMemory* buildEngineYolov8Det(nvinfer1::IBuilder* builder, nvinfer std::cout << "Your platform support int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = - new Int8EntropyCalibrator2(1, kInputW, kInputH, "../coco_calib/", "int8calib.table", kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kInputW, kInputH, kInputQuantizationFolder, "int8calib.table", + kInputTensorName); config->setInt8Calibrator(calibrator); #endif @@ -621,8 +621,8 @@ nvinfer1::IHostMemory* buildEngineYolov8DetP6(nvinfer1::IBuilder* builder, nvinf std::cout << "Your platform support int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = - new Int8EntropyCalibrator2(1, kInputW, kInputH, "../coco_calib/", "int8calib.table", kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kInputW, kInputH, kInputQuantizationFolder, "int8calib.table", + kInputTensorName); config->setInt8Calibrator(calibrator); #endif @@ -931,8 +931,8 @@ nvinfer1::IHostMemory* buildEngineYolov8DetP2(nvinfer1::IBuilder* builder, nvinf std::cout << "Your platform support int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = - new Int8EntropyCalibrator2(1, kInputW, kInputH, "../coco_calib/", "int8calib.table", kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kInputW, kInputH, kInputQuantizationFolder, "int8calib.table", + kInputTensorName); config->setInt8Calibrator(calibrator); #endif @@ -1014,8 +1014,8 @@ nvinfer1::IHostMemory* buildEngineYolov8Cls(nvinfer1::IBuilder* builder, nvinfer std::cout << "Your platform supports int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = new Int8EntropyCalibrator2(1, kClsInputW, kClsInputH, "../coco_calib/", "int8calib.table", - kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kClsInputW, kClsInputH, kInputQuantizationFolder, + "int8calib.table", kInputTensorName); config->setInt8Calibrator(calibrator); #endif @@ -1264,8 +1264,8 @@ nvinfer1::IHostMemory* buildEngineYolov8Seg(nvinfer1::IBuilder* builder, nvinfer std::cout << "Your platform support int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = - new Int8EntropyCalibrator2(1, kInputW, kInputH, "../coco_calib/", "int8calib.table", kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kInputW, kInputH, kInputQuantizationFolder, "int8calib.table", + kInputTensorName); config->setInt8Calibrator(calibrator); #endif @@ -1511,8 +1511,8 @@ nvinfer1::IHostMemory* buildEngineYolov8Pose(nvinfer1::IBuilder* builder, nvinfe std::cout << "Your platform support int8: " << (builder->platformHasFastInt8() ? "true" : "false") << std::endl; assert(builder->platformHasFastInt8()); config->setFlag(nvinfer1::BuilderFlag::kINT8); - auto* calibrator = - new Int8EntropyCalibrator2(1, kInputW, kInputH, "../coco_calib/", "int8calib.table", kInputTensorName); + auto* calibrator = new Int8EntropyCalibrator2(1, kInputW, kInputH, kInputQuantizationFolder, "int8calib.table", + kInputTensorName); config->setInt8Calibrator(calibrator); #endif