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