|
@@ -362,7 +362,7 @@ void YoloModelImpl::preprocess(int ibatch, affine::LetterBoxMatrix &affine, void
|
|
|
}
|
|
|
|
|
|
|
|
|
-bool YoloModelImpl::load(const std::string &engine_file, ModelType model_type, float confidence_threshold, float nms_threshold)
|
|
|
+bool YoloModelImpl::load(const std::string &engine_file, ModelType model_type, const std::vector<std::string>& names, float confidence_threshold, float nms_threshold)
|
|
|
{
|
|
|
trt_ = TensorRT::load(engine_file);
|
|
|
if (trt_ == nullptr) return false;
|
|
@@ -372,6 +372,7 @@ bool YoloModelImpl::load(const std::string &engine_file, ModelType model_type, f
|
|
|
this->confidence_threshold_ = confidence_threshold;
|
|
|
this->nms_threshold_ = nms_threshold;
|
|
|
this->model_type_ = model_type;
|
|
|
+ this->class_names_ = names;
|
|
|
|
|
|
auto input_dim = trt_->static_dims(0);
|
|
|
bbox_head_dims_ = trt_->static_dims(1);
|
|
@@ -527,6 +528,7 @@ data::BoxArray YoloModelImpl::forwards(void *stream)
|
|
|
if (keepflag == 1)
|
|
|
{
|
|
|
data::Box result_object_box(pbox[0], pbox[1], pbox[2], pbox[3], pbox[4], label);
|
|
|
+ result_object_box.label = class_names_[label];
|
|
|
if (model_type_ == ModelType::YOLO11POSE)
|
|
|
{
|
|
|
result_object_box.keypoints.reserve(KEY_POINT_NUM);
|
|
@@ -542,11 +544,11 @@ data::BoxArray YoloModelImpl::forwards(void *stream)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Infer *loadraw(const std::string &engine_file, ModelType model_type, float confidence_threshold,
|
|
|
+Infer *loadraw(const std::string &engine_file, ModelType model_type, const std::vector<std::string>& names, float confidence_threshold,
|
|
|
float nms_threshold)
|
|
|
{
|
|
|
YoloModelImpl *impl = new YoloModelImpl();
|
|
|
- if (!impl->load(engine_file, model_type, confidence_threshold, nms_threshold))
|
|
|
+ if (!impl->load(engine_file, model_type, names, confidence_threshold, nms_threshold))
|
|
|
{
|
|
|
delete impl;
|
|
|
impl = nullptr;
|
|
@@ -555,10 +557,10 @@ Infer *loadraw(const std::string &engine_file, ModelType model_type, float confi
|
|
|
return impl;
|
|
|
}
|
|
|
|
|
|
-std::shared_ptr<Infer> load_yolo(const std::string &engine_file, ModelType model_type, int gpu_id, float confidence_threshold, float nms_threshold)
|
|
|
+std::shared_ptr<Infer> load_yolo(const std::string &engine_file, ModelType model_type, const std::vector<std::string>& names, int gpu_id, float confidence_threshold, float nms_threshold)
|
|
|
{
|
|
|
checkRuntime(cudaSetDevice(gpu_id));
|
|
|
- return std::shared_ptr<YoloModelImpl>((YoloModelImpl *)loadraw(engine_file, model_type, confidence_threshold, nms_threshold));
|
|
|
+ return std::shared_ptr<YoloModelImpl>((YoloModelImpl *)loadraw(engine_file, model_type, names, confidence_threshold, nms_threshold));
|
|
|
}
|
|
|
|
|
|
}
|