Fix model optimisation

This commit is contained in:
2026-04-09 08:09:02 +10:00
parent 34854d87f4
commit eeb205779a
10 changed files with 688 additions and 160 deletions

View File

@@ -308,7 +308,8 @@ int CustomModelEngine(std::string modelFilePath, std::string videoFilePath) {
int detectorType = 1; // Detection
// Optimise model
std::cout << "Optimizing model, please wait...." << std::endl;
std::string optmizedModelFolder = OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, 1,1);
std::string optmizedModelFolder;
OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, 1,1, optmizedModelFolder);
std::cout << "Optimized model folder: " << optmizedModelFolder << std::endl;
labelMap = CreateANSODHandle(&infHandle, licenseKey.c_str(), modelFilePath.c_str(), modelZipFilePassword.c_str(), detectionScoreThreshold, modelConfThreshold, modelNMSThreshold, 1, modelType, detectorType);
std::stringstream ss(labelMap);
@@ -410,7 +411,8 @@ int TrafficLightEngine(std::string modelFilePath, std::string videoFilePath) {
int detectorType = 1; // Detection
// Optimise model
std::cout << "Optimizing model, please wait...." << std::endl;
std::string optmizedModelFolder = OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType,1, 1);
std::string optmizedModelFolder;
OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType,1, 1, optmizedModelFolder);
std::cout << "Optimized model folder: " << optmizedModelFolder << std::endl;
labelMap = CreateANSODHandle(&infHandle, licenseKey.c_str(), modelFilePath.c_str(), modelZipFilePassword.c_str(), detectionScoreThreshold, modelConfThreshold, modelNMSThreshold, 1, modelType, detectorType,1);
if (labelMap.empty()) {
@@ -612,7 +614,8 @@ int MotionDetectorEngine(std::string modelFilePath, std::string videoFilePath) {
int detectorType = 1; // Detection
// Optimise model
std::cout << "Optimizing model, please wait...." << std::endl;
std::string optmizedModelFolder = OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType,1, 1);
std::string optmizedModelFolder;
OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType,1, 1, optmizedModelFolder);
std::cout << "Optimized model folder: " << optmizedModelFolder << std::endl;
labelMap = CreateANSODHandle(&infHandle, licenseKey.c_str(), modelFilePath.c_str(), modelZipFilePassword.c_str(), detectionScoreThreshold, modelConfThreshold, modelNMSThreshold, 1, modelType, detectorType);
std::stringstream ss(labelMap);
@@ -714,7 +717,8 @@ int ImageDetectionEngine(std::string modelFilePath, std::string imageFilePath,
int detectorType = modelDetectionType; // Detection
// Optimise model
std::cout << "Optimizing model, please wait...." << std::endl;
std::string optmizedModelFolder = OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, modelDetectionType,1);
std::string optmizedModelFolder;
OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, modelDetectionType,1, optmizedModelFolder);
std::cout << "Optimized model folder: " << optmizedModelFolder << std::endl;
labelMap = CreateANSODHandle(&infHandle, licenseKey.c_str(), modelFilePath.c_str(), modelZipFilePassword.c_str(), detectionScoreThreshold, modelConfThreshold, modelNMSThreshold, 1, modelType, detectorType);
std::stringstream ss(labelMap);
@@ -902,7 +906,8 @@ int VideoDetectorEngine(std::string modelFilePath, std::string videoFilePath, in
int detectorType = modelDetectionType; // Detection
// Optimise model
std::cout << "Optimizing model, please wait...." << std::endl;
std::string optmizedModelFolder = OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, modelDetectionType,1);
std::string optmizedModelFolder;
OptimizeModelStr(modelFilePath.c_str(), modelZipFilePassword.c_str(), modelType, modelDetectionType,1, optmizedModelFolder);
std::cout << "Optimized model folder: " << optmizedModelFolder << std::endl;
labelMap = CreateANSODHandle(&infHandle, licenseKey.c_str(), modelFilePath.c_str(), modelZipFilePassword.c_str(), detectionScoreThreshold, modelConfThreshold, modelNMSThreshold, 1, modelType, detectorType,1);
std::stringstream ss(labelMap);
@@ -1560,9 +1565,10 @@ int ElasticGPUTest() {
std::cout << "\n--- Test 1: Handle creation (elastic mode) ---\n" << std::endl;
std::cout << "Optimizing model, please wait..." << std::endl;
std::string optimizedFolder = OptimizeModelStr(
std::string optimizedFolder;
OptimizeModelStr(
modelFilePath.c_str(), modelZipFilePassword.c_str(),
modelType, detectorType, 1);
modelType, detectorType, 1, optimizedFolder);
std::cout << "Optimized model folder: " << optimizedFolder << std::endl;
ANSCENTER::ANSODBase* infHandle = nullptr;