35 std::string config_file =
38 AERROR <<
"Read config failed: " << config_file;
42 AINFO <<
"Load config Success: " << model_param_.ShortDebugString();
44 const auto &model_info = model_param_.
info();
45 std::string model_path =
GetModelPath(model_info.name());
46 std::string proto_file =
47 GetModelFile(model_path, model_info.proto_file().file());
48 std::string weight_file =
49 GetModelFile(model_path, model_info.weight_file().file());
52 std::vector<std::string> input_names =
54 std::vector<std::string> output_names =
61 model_info.framework(), proto_file, weight_file, output_names,
62 input_names, model_path));
63 ACHECK(
nullptr != net_) <<
"Failed to init CNNAdapter";
65 gpu_id_ = GlobalConfig::Instance()->track_feature_gpu_id;
66 net_->set_gpu_id(gpu_id_);
68 std::map<std::string, std::vector<int>> shape_map;
71 if (!net_->Init(shape_map)) {
72 AERROR << model_info.name() <<
"init failed!";
78 InitFeatureExtractor(options);
83bool ExternalFeatureExtractor::InitFeatureExtractor(
88 feat_options.
gpu_id = gpu_id_;
90 auto feat_blob_name = model_param_.
info().outputs(0).name();
91 feat_options.
feat_blob = net_->get_blob(feat_blob_name);
94 feature_extractor_.reset(BaseFeatureExtractorRegisterer::GetInstanceByName(
95 "TrackingFeatureExtractor"));
96 feature_extractor_->Init(feat_options);
104 auto input_blob = net_->get_blob(model_param_.
info().inputs(0).name());
107 auto offset_y_ =
static_cast<int>(
108 model_param_.
offset_ratio() *
static_cast<float>(raw_height) + 0.5f);
110 base::RectI(0, offset_y_, raw_width, raw_height - offset_y_);
118 feature_extractor_->set_roi(
121 feature_extractor_->Extract(feat_options, frame);
122 AINFO <<
"Extract Done";
A wrapper around Blob holders serving as the basic computational unit for images.
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
std::vector< std::string > GetBlobNames(const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
void AddShape(std::map< std::string, std::vector< int > > *shape_map, const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
Inference * CreateInferenceByName(const std::string &frame_work, const std::string &proto_file, const std::string &weight_file, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const std::string &model_root)
bool ResizeGPU(const base::Image8U &src, std::shared_ptr< apollo::perception::base::Blob< float > > dst, int stepwidth, int start_axis)
std::string GetModelFile(const std::string &model_name, const std::string &file_name)
Get the model file path by model path and file name
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
std::string GetModelPath(const std::string &model_name)
Get the model path by model name, search from APOLLO_MODEL_PATH
std::shared_ptr< camera::DataProvider > data_provider
optional common::Resize resize
optional common::ModelInfo info
optional float offset_ratio