fix model manager with various batchsize
This commit is contained in:
parent
334c2055d9
commit
212c9f18fa
|
@ -363,10 +363,16 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
|
||||||
bool with_segmentation = base_->withSegmentation();
|
bool with_segmentation = base_->withSegmentation();
|
||||||
double thrs_conf = base_->getThrsConf();
|
double thrs_conf = base_->getThrsConf();
|
||||||
double thrs_nms = base_->getThrsNms();
|
double thrs_nms = base_->getThrsNms();
|
||||||
|
std::string model = base_->getModel();
|
||||||
|
int bs = base_->getBatchSize();
|
||||||
|
char bs_c[8];
|
||||||
|
itoa(bs, bs_c, 10);
|
||||||
|
std::string bs_s(bs_c);
|
||||||
|
|
||||||
std::string engine_fn = get_home() + SV_MODEL_DIR + dataset + ".engine";
|
std::string engine_fn = get_home() + SV_MODEL_DIR + dataset + ".engine";
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5s_c");
|
|
||||||
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "_b" + bs_s + "_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
@ -376,7 +382,7 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
|
||||||
if (input_w == 1280)
|
if (input_w == 1280)
|
||||||
{
|
{
|
||||||
files.clear();
|
files.clear();
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5s6_");
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "6_b" + bs_s + "_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
@ -392,7 +398,7 @@ bool CommonObjectDetectorCUDAImpl::cudaSetup(CommonObjectDetectorBase* base_, bo
|
||||||
base_->setInputH(640);
|
base_->setInputH(640);
|
||||||
base_->setInputW(640);
|
base_->setInputW(640);
|
||||||
files.clear();
|
files.clear();
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5s_seg_");
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.engine", "Nv-" + dataset + "-yolov5" + model + "_seg_b" + bs_s + "_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
|
|
@ -125,10 +125,11 @@ namespace sv
|
||||||
inpHeight = base_->getInputH();
|
inpHeight = base_->getInputH();
|
||||||
inpWidth = base_->getInputW();
|
inpWidth = base_->getInputW();
|
||||||
with_segmentation = base_->withSegmentation();
|
with_segmentation = base_->withSegmentation();
|
||||||
|
std::string model = base_->getModel();
|
||||||
|
|
||||||
std::string openvino_fn = get_home() + SV_MODEL_DIR + dataset + ".onnx";
|
std::string openvino_fn = get_home() + SV_MODEL_DIR + dataset + ".onnx";
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5s_c");
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
@ -138,7 +139,7 @@ namespace sv
|
||||||
if (inpWidth == 1280)
|
if (inpWidth == 1280)
|
||||||
{
|
{
|
||||||
files.clear();
|
files.clear();
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5s6_");
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "6_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
@ -154,7 +155,7 @@ namespace sv
|
||||||
base_->setInputH(640);
|
base_->setInputH(640);
|
||||||
base_->setInputW(640);
|
base_->setInputW(640);
|
||||||
files.clear();
|
files.clear();
|
||||||
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5s_seg_");
|
_list_dir(get_home() + SV_MODEL_DIR, files, "-online.onnx", "Int-" + dataset + "-yolov5" + model + "_seg_c");
|
||||||
if (files.size() > 0)
|
if (files.size() > 0)
|
||||||
{
|
{
|
||||||
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
std::sort(files.rbegin(), files.rend(), _comp_str_lesser);
|
||||||
|
|
|
@ -916,6 +916,14 @@ void CommonObjectDetectorBase::setInputW(int w_)
|
||||||
{
|
{
|
||||||
this->_input_w = w_;
|
this->_input_w = w_;
|
||||||
}
|
}
|
||||||
|
std::string CommonObjectDetectorBase::getModel()
|
||||||
|
{
|
||||||
|
return this->_model;
|
||||||
|
}
|
||||||
|
int CommonObjectDetectorBase::getBatchSize()
|
||||||
|
{
|
||||||
|
return this->_batch_size;
|
||||||
|
}
|
||||||
|
|
||||||
void CommonObjectDetectorBase::warmUp()
|
void CommonObjectDetectorBase::warmUp()
|
||||||
{
|
{
|
||||||
|
@ -1082,6 +1090,8 @@ void CommonObjectDetectorBase::_load()
|
||||||
this->_thrs_nms = 0.6;
|
this->_thrs_nms = 0.6;
|
||||||
this->_thrs_conf = 0.4;
|
this->_thrs_conf = 0.4;
|
||||||
this->_use_width_or_height = 0;
|
this->_use_width_or_height = 0;
|
||||||
|
this->_batch_size = 1;
|
||||||
|
this->_model = "s";
|
||||||
|
|
||||||
for (auto i : detector_params_value) {
|
for (auto i : detector_params_value) {
|
||||||
|
|
||||||
|
@ -1089,6 +1099,12 @@ void CommonObjectDetectorBase::_load()
|
||||||
this->_dataset = i->value.toString();
|
this->_dataset = i->value.toString();
|
||||||
std::cout << "dataset: " << this->_dataset << std::endl;
|
std::cout << "dataset: " << this->_dataset << std::endl;
|
||||||
}
|
}
|
||||||
|
else if ("batchSize" == std::string(i->key)) {
|
||||||
|
this->_batch_size = i->value.toNumber();
|
||||||
|
}
|
||||||
|
else if ("model" == std::string(i->key)) {
|
||||||
|
this->_model = i->value.toString();
|
||||||
|
}
|
||||||
else if ("inputSize" == std::string(i->key)) {
|
else if ("inputSize" == std::string(i->key)) {
|
||||||
// std::cout << "inputSize (old, new): " << this->_input_w << ", " << i->value.toNumber() << std::endl;
|
// std::cout << "inputSize (old, new): " << this->_input_w << ", " << i->value.toNumber() << std::endl;
|
||||||
this->_input_w = i->value.toNumber();
|
this->_input_w = i->value.toNumber();
|
||||||
|
|
|
@ -140,6 +140,8 @@ public:
|
||||||
double getThrsConf();
|
double getThrsConf();
|
||||||
int useWidthOrHeight();
|
int useWidthOrHeight();
|
||||||
bool withSegmentation();
|
bool withSegmentation();
|
||||||
|
std::string getModel();
|
||||||
|
int getBatchSize();
|
||||||
protected:
|
protected:
|
||||||
virtual bool setupImpl();
|
virtual bool setupImpl();
|
||||||
virtual void detectImpl(
|
virtual void detectImpl(
|
||||||
|
@ -166,6 +168,8 @@ protected:
|
||||||
double _thrs_conf;
|
double _thrs_conf;
|
||||||
int _use_width_or_height;
|
int _use_width_or_height;
|
||||||
bool _with_segmentation;
|
bool _with_segmentation;
|
||||||
|
std::string _model;
|
||||||
|
int _batch_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 1280,
|
"inputSize": 1280,
|
||||||
|
"withSegmentation": false,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": false,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": false,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": false,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 1280,
|
"inputSize": 1280,
|
||||||
|
"withSegmentation": false,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": false,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": false,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"CommonObjectDetector": {
|
"CommonObjectDetector": {
|
||||||
"dataset": "COCO",
|
"dataset": "COCO",
|
||||||
|
"model": "s",
|
||||||
|
"batchSize": 1,
|
||||||
"inputSize": 640,
|
"inputSize": 640,
|
||||||
|
"withSegmentation": true,
|
||||||
"nmsThrs": 0.6,
|
"nmsThrs": 0.6,
|
||||||
"scoreThrs": 0.4,
|
"scoreThrs": 0.4,
|
||||||
"useWidthOrHeight": 1,
|
"useWidthOrHeight": 1,
|
||||||
"withSegmentation": true,
|
|
||||||
"datasetPersonVehicle": {
|
"datasetPersonVehicle": {
|
||||||
"person": [0.5, 1.8],
|
"person": [0.5, 1.8],
|
||||||
"car": [4.1, 1.5],
|
"car": [4.1, 1.5],
|
||||||
|
|
|
@ -51,10 +51,16 @@ def main():
|
||||||
if os.path.exists(model_file):
|
if os.path.exists(model_file):
|
||||||
print("[1] Model:", line, "EXIST!")
|
print("[1] Model:", line, "EXIST!")
|
||||||
if line.startswith('Nv'):
|
if line.startswith('Nv'):
|
||||||
engine_fn = os.path.splitext(model_file)[0] + '.engine'
|
net = line.split('-')[2]
|
||||||
online_fn = os.path.splitext(model_file)[0] + '-online.engine'
|
if len(net.split('_')) == 3:
|
||||||
|
name, seg, ncls = net.split('_')
|
||||||
|
engine_fn = os.path.splitext(model_file)[0].replace(net, name + "_" + seg + '_b1_' + ncls) + '.engine'
|
||||||
|
online_fn = os.path.splitext(model_file)[0].replace(net, name + "_" + seg + '_b1_' + ncls) + '-online.engine'
|
||||||
|
else:
|
||||||
|
name, ncls = net.split('_')
|
||||||
|
engine_fn = os.path.splitext(model_file)[0].replace(net, name + '_b1_' + ncls) + '.engine'
|
||||||
|
online_fn = os.path.splitext(model_file)[0].replace(net, name + '_b1_' + ncls) + '-online.engine'
|
||||||
if not os.path.exists(engine_fn) and not os.path.exists(online_fn):
|
if not os.path.exists(engine_fn) and not os.path.exists(online_fn):
|
||||||
net = line.split('-')[2]
|
|
||||||
if net.startswith("yolov5"):
|
if net.startswith("yolov5"):
|
||||||
if len(net.split('_')) == 3:
|
if len(net.split('_')) == 3:
|
||||||
name, seg, ncls = net.split('_')
|
name, seg, ncls = net.split('_')
|
||||||
|
|
Loading…
Reference in New Issue