41 {
42 sensor_name_ = options.sensor_name;
43 std::string config_file =
46
47
48 const cnnseg::FeatureParam& feature_param = model_param_.
feature_param();
49 range_ = feature_param.point_cloud_range();
50 width_ = feature_param.width();
51 height_ = feature_param.height();
52 min_height_ = feature_param.min_height();
53 max_height_ = feature_param.max_height();
54
55 const auto& model_info = model_param_.
info();
56 std::string model_path =
GetModelPath(model_info.name());
57 std::string proto_file =
58 GetModelFile(model_path, model_info.proto_file().file());
59 std::string weight_file =
60 GetModelFile(model_path, model_info.weight_file().file());
61
62
63 std::vector<std::string> input_names =
65 std::vector<std::string> output_names =
67
69 model_param_.
info().framework(), proto_file, weight_file, output_names,
70 input_names));
71 CHECK_NOTNULL(inference_.get());
72
73 gpu_id_ = model_param_.
preprocess().has_gpu_id()
75 : -1;
76 BASE_GPU_CHECK(cudaSetDevice(gpu_id_));
77 inference_->set_gpu_id(gpu_id_);
78
79 std::map<std::string, std::vector<int>> input_shapes;
81 auto& input_shape = input_shapes[input_names.at(0)];
82 if (!feature_param.use_intensity_feature()) {
83 input_shape[1] -= 2;
84 }
85 if (!feature_param.use_constant_feature()) {
86 input_shape[1] -= 2;
87 }
88 ACHECK(inference_->Init(input_shapes)) <<
"Failed to init inference.";
89
90
91 instance_pt_blob_ = inference_->get_blob(output_names.at(0));
92 CHECK_NOTNULL(instance_pt_blob_.get());
93 category_pt_blob_ = inference_->get_blob(output_names.at(1));
94 CHECK_NOTNULL(category_pt_blob_.get());
95 confidence_pt_blob_ = inference_->get_blob(output_names.at(2));
96 CHECK_NOTNULL(confidence_pt_blob_.get());
97 height_pt_blob_ = inference_->get_blob(output_names.at(3));
98 CHECK_NOTNULL(height_pt_blob_.get());
99 feature_blob_ = inference_->get_blob(input_names.at(0));
100 CHECK_NOTNULL(feature_blob_.get());
102 classify_pt_blob_ = inference_->get_blob(output_names.at(5));
103 CHECK_NOTNULL(classify_pt_blob_.get());
104 }
106 heading_pt_blob_ = inference_->get_blob(output_names.at(4));
107 CHECK_NOTNULL(heading_pt_blob_.get());
108 }
109
110
111 feature_generator_.reset(new FeatureGenerator);
112 ACHECK(feature_generator_->Init(feature_param, feature_blob_.get()))
113 << "Failed to init feature generator.";
114
115 point2grid_.reserve(kDefaultPointCloudSize);
116
117
118 ACHECK(InitClusterAndBackgroundSegmentation());
119
120 return true;
121}
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)
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
optional FeatureParam feature_param
optional common::PointCloudPreProcess preprocess
optional bool do_classification
optional common::ModelInfo info