Skip to content

Commit 0710cbb

Browse files
committed
reid model path would be taken from cli
1 parent 7e778ce commit 0710cbb

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

botsort/include/BoTSORT.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class BoTSORT
1212
public:
1313
explicit BoTSORT(const std::string &tracker_config_path,
1414
const std::string &gmc_config_path = "",
15-
const std::string &reid_config_path = "");
15+
const std::string &reid_config_path = "",
16+
const std::string &reid_onnx_model_path = "");
1617
~BoTSORT() = default;
1718

1819

botsort/include/ReID.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
class ReIDModel
99
{
1010
public:
11-
ReIDModel(const std::string &config_path);
11+
ReIDModel(const std::string &config_path,
12+
const std::string &onnx_model_path);
1213
~ReIDModel() = default;
1314

1415
void pre_process(cv::Mat &image);

botsort/src/BoTSORT.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
BoTSORT::BoTSORT(const std::string &tracker_config_path,
1414
const std::string &gmc_config_path,
15-
const std::string &reid_config_path)
15+
const std::string &reid_config_path,
16+
const std::string &reid_onnx_model_path)
1617
{
1718
_load_params_from_config(tracker_config_path);
1819

@@ -25,8 +26,10 @@ BoTSORT::BoTSORT(const std::string &tracker_config_path,
2526

2627

2728
// Re-ID module, load visual feature extractor here
28-
if (_reid_enabled && reid_config_path.size() > 0)
29-
_reid_model = std::make_unique<ReIDModel>(reid_config_path);
29+
if (_reid_enabled && reid_config_path.size() > 0 &&
30+
reid_onnx_model_path.size() > 0)
31+
_reid_model = std::make_unique<ReIDModel>(reid_config_path,
32+
reid_onnx_model_path);
3033
else
3134
{
3235
std::cout << "Re-ID module disabled" << std::endl;

botsort/src/ReID.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include "INIReader.h"
44

5-
ReIDModel::ReIDModel(const std::string &config_path)
5+
ReIDModel::ReIDModel(const std::string &config_path,
6+
const std::string &onnx_model_path)
67
{
78
std::cout << "Initializing ReID model" << std::endl;
89
_load_params_from_config(config_path);
10+
11+
_onnx_model_path = onnx_model_path;
912
_trt_inference_engine =
1013
std::make_unique<inference_backend::TensorRTInferenceEngine>(
1114
_model_optimization_params, _trt_logging_level);
@@ -52,7 +55,6 @@ void ReIDModel::_load_params_from_config(const std::string &config_path)
5255
exit(1);
5356
}
5457

55-
_onnx_model_path = reid_config.Get(section_name, "onnx_model_path", "");
5658
_distance_metric =
5759
reid_config.Get(section_name, "distance_metric", "euclidean");
5860
_trt_logging_level =

config/reid.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[ReID]
2-
onnx_model_path = assets/osnet_x0_25_market1501.onnx ; models/reid_model.onnx or models/reid_model_fp16.onnx.
32
enable_TF32 = true ; if ReID is enabled, set this to enable TF32 inference
43
enable_FP16 = true ; if re-id is enabled (i.e. model_path is not commented out), set this to true if you want to use fp16 inference
54
input_layer_name = images ; layer name of the input layer in the ONNX model

examples/botsort_tracking_example.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,13 @@ int main(int argc, char **argv)
207207
std::cout << "Usage eg. 2: ./botsort_tracking_example "
208208
"<tracker_config_path> "
209209
"<gmc_config_path> <reid_config_path> "
210+
"<reid_onnx_model_path> "
210211
"<source> <dir_containing_per_frame_detections> "
211212
"<dir_to_save_mot_format_output> <gt_file>"
212213
<< std::endl;
213214
return -1;
214215
}
215-
else if (4 < argc && argc < 7)
216+
else if (4 < argc && argc < 8)
216217
{
217218
std::cout << "Usage eg. 1: ./botsort_tracking_example <source> "
218219
"<dir_containing_per_frame_detections> "
@@ -221,15 +222,16 @@ int main(int argc, char **argv)
221222
std::cout << "Usage eg. 2: ./botsort_tracking_example "
222223
"<tracker_config_path> "
223224
"<gmc_config_path> <reid_config_path> "
225+
"<reid_onnx_model_path> "
224226
"<source> <dir_containing_per_frame_detections> "
225227
"<dir_to_save_mot_format_output> <gt_file>"
226228
<< std::endl;
227229
return -1;
228230
}
229231

230232

231-
std::string tracker_config_path, gmc_config_path, reid_config_path, source,
232-
labels_dir, output_dir, gt_filepath;
233+
std::string tracker_config_path, gmc_config_path, reid_config_path,
234+
reid_onnx_model_path, source, labels_dir, output_dir, gt_filepath;
233235

234236
if (argc == 4)
235237
{
@@ -242,9 +244,10 @@ int main(int argc, char **argv)
242244
tracker_config_path = argv[1];
243245
gmc_config_path = argv[2];
244246
reid_config_path = argv[3];
245-
source = argv[4];
246-
labels_dir = argv[5];
247-
output_dir = argv[6];
247+
reid_onnx_model_path = argv[4];
248+
source = argv[5];
249+
labels_dir = argv[6];
250+
output_dir = argv[7];
248251
}
249252

250253

@@ -309,7 +312,8 @@ int main(int argc, char **argv)
309312
else
310313
{
311314
tracker = std::make_unique<BoTSORT>(tracker_config_path,
312-
gmc_config_path, reid_config_path);
315+
gmc_config_path, reid_config_path,
316+
reid_onnx_model_path);
313317
}
314318

315319
if (is_video)

0 commit comments

Comments
 (0)