Initialize traffic light classify parameters.
31 {
32 AINFO <<
"Enter Classify init";
33 net_inputs_.clear();
34 net_outputs_.clear();
35 AINFO <<
"clear success";
38
39 AINFO << net_inputs_.size();
40 AINFO << net_outputs_.size();
41
42 for (auto name : net_inputs_) {
43 AINFO <<
"net input blobs: " << name;
44 }
45 for (auto name : net_outputs_) {
46 AINFO <<
"net output blobs: " << name;
47 }
48
49 std::string model_path =
GetModelPath(model_config.info().name());
50
51 std::string proto_file =
GetModelFile(model_path, model_config.info().proto_file().file());
52 AINFO <<
"proto_file " << proto_file;
53
54 std::string weight_file =
GetModelFile(model_path, model_config.info().weight_file().file());
55
56 AINFO <<
"weight_file" << weight_file;
57
58 const auto& model_type = model_config.info().framework();
60 model_type, proto_file, weight_file, net_outputs_, net_inputs_, model_path));
61
62 rt_net_->set_gpu_id(gpu_id);
63 gpu_id_ = gpu_id;
64
65 resize_height_ = model_config.classify_resize_height();
66 resize_width_ = model_config.classify_resize_width();
67 unknown_threshold_ = model_config.classify_threshold();
68 mean_.reset(new base::Blob<float>(1, 3, 1, 1));
69 float* p = mean_->mutable_cpu_data();
70 if (model_config.is_bgr()) {
72 p[0] = model_config.mean_b();
73 p[1] = model_config.mean_g();
74 p[2] = model_config.mean_r();
75 } else {
77 p[0] = model_config.mean_r();
78 p[1] = model_config.mean_g();
79 p[2] = model_config.mean_b();
80 }
81 scale_ = model_config.scale();
82
83 std::vector<int> shape = {1, resize_height_, resize_width_, 3};
84 mean_buffer_.reset(new base::Blob<float>(shape));
85
86 std::map<std::string, std::vector<int>> input_reshape;
88
89 AINFO <<
"input_reshape: " << input_reshape[net_inputs_[0]][0] <<
", " << input_reshape[net_inputs_[0]][1] <<
", "
90 << input_reshape[net_inputs_[0]][2] << ", " << input_reshape[net_inputs_[0]][3];
91
92 if (!rt_net_->Init(input_reshape)) {
93 AWARN <<
"net init fail.";
94 }
95
96 image_.reset(
new base::Image8U(resize_height_, resize_width_,
base::Color::BGR));
97}
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)
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 GetModelPath(const std::string &model_name)
Get the model path by model name, search from APOLLO_MODEL_PATH