Init ObstacleDetector constructor.
118 {
119 options_ = options;
120 gpu_id_ = options.gpu_id;
121 BASE_GPU_CHECK(cudaSetDevice(gpu_id_));
122 BASE_GPU_CHECK(cudaStreamCreate(&stream_));
123
124 std::string config_file =
126 std::cout << " config file is " << config_file << std::endl;
128 AERROR <<
"Read model param failed!";
129 return false;
130 }
131
132 InitTypes(model_param_);
133 InitImageSize(model_param_);
134
135 common::Normalize normalize = model_param_.
normalize();
136 mean_bgr_ = {normalize.mean()[0], normalize.mean()[1], normalize.mean()[2]};
137 std_bgr_ = {normalize.std()[0], normalize.std()[1], normalize.std()[2]};
138
139 const auto &model_info = model_param_.
info();
140 std::string model_path =
GetModelPath(model_info.name());
141
143 AERROR <<
"Init network failed!";
144 return false;
145 }
146 std::cout << "bevformer model init success from "
147 << model_info.proto_file().file() << std::endl;
148
149 auto model_outputs = model_param_.
info().outputs();
150 num_decoder_layer_ = model_outputs[1].shape()[0];
151 num_queries_ = model_outputs[1].shape()[2];
152 num_classes_det_ = model_outputs[1].shape()[3];
153 code_size_ = model_outputs[2].shape()[3];
154 class_blob_start_index_ =
155 (num_decoder_layer_ - 1) * num_queries_ * num_classes_det_;
156 class_blob_end_index_ =
157 (num_decoder_layer_)*num_queries_ * num_classes_det_;
158 box_blob_start_index_ =
159 (num_decoder_layer_ - 1) * num_queries_ * code_size_;
160 AINFO <<
"number of decoder layer:" << num_decoder_layer_
161 << " number of query: " << num_queries_
162 << " number of classes: " << num_classes_det_
163 << " code size: " << code_size_
164 << " class blob start index: " << class_blob_start_index_
165 << " class blob end index: " << class_blob_end_index_
166 << " box blob start index: " << box_blob_start_index_;
167
168 num_voxels_ = model_outputs[occ_blob_index_].shape()[1];
169 num_classes_occ_ = model_outputs[occ_blob_index_].shape()[2];
170 AINFO <<
" number of occ voxels " << num_voxels_
171 << " number of occ classes " << num_classes_occ_;
172 occ_xmin_ = model_param_.
occ_xmin();
173 occ_xmax_ = model_param_.
occ_xmax();
174 occ_ymin_ = model_param_.
occ_ymin();
175 occ_ymax_ = model_param_.
occ_ymax();
176 occ_zmin_ = model_param_.
occ_zmin();
177 occ_zmax_ = model_param_.
occ_zmax();
179 occ_x_grid_ = (occ_xmax_ - occ_xmin_) / voxel_size_;
180 occ_y_grid_ = (occ_ymax_ - occ_ymin_) / voxel_size_;
181 occ_z_grid_ = (occ_zmax_ - occ_zmin_) / voxel_size_;
182
183
184 auto model_inputs = model_param_.
info().inputs();
185 auto prev_bev_shape = model_inputs[1].shape();
186 for (auto size : prev_bev_shape) {
187 prev_bev_size_ *= size;
188 }
189 use_prev_bev_ = new float(0.0);
190
193 CHECK(no_pad_image_width <= model_inputs[0].shape()[3]);
194 CHECK(no_pad_image_height <= model_inputs[0].shape()[4]);
195 no_pad_image_shape_[0] = no_pad_image_width;
196 no_pad_image_shape_[1] = no_pad_image_height;
198
199 trans_wrapper_.reset(new onboard::TransformWrapper());
200
201 trans_wrapper_->Init("CAM_FRONT");
202 return true;
203}
virtual bool InitNetwork(const common::ModelInfo &model_info, const std::string &model_root)
Interface for network initialization
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::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