MCPcopy Create free account
hub / github.com/OAID/Tengine / run_RNet

Method run_RNet

examples/mtcnn/mtcnn.cpp:148–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148int mtcnn::run_RNet(image img, std::vector<face_box>& pnet_boxes, std::vector<face_box>& output_boxes)
149{
150 int batch = pnet_boxes.size();
151 int channel = 3;
152 int height = 24;
153 int width = 24;
154 static bool first_run = true;
155
156 tensor_t input_tensor = get_graph_tensor(RNet_graph, "data");
157 int dims[] = {batch, channel, height, width};
158 set_tensor_shape(input_tensor, dims, 4);
159 int img_size = channel * height * width;
160 int in_mem = sizeof(float) * batch * img_size;
161 float* input_data = ( float* )malloc(in_mem);
162 float* input_ptr = input_data;
163 set_tensor_buffer(input_tensor, input_ptr, in_mem);
164
165 for(int i = 0; i < batch; i++)
166 {
167 copy_one_patch(img, pnet_boxes[i], input_ptr, width, height);
168 input_ptr += img_size;
169 }
170
171 if(first_run)
172 {
173 if(prerun_graph(RNet_graph) != 0)
174 {
175 std::cout << "Prerun RNet graph failed, errno: " << get_tengine_errno() << "\n";
176 return 1;
177 }
178 first_run = false;
179 }
180
181 if(run_graph(RNet_graph, 1) != 0)
182 {
183 std::cout << "Run RNet graph failed, errno: " << get_tengine_errno() << "\n";
184 return 1;
185 }
186 free(input_data);
187 // std::cout<<"run done ------\n";
188 //
189 /* output */
190 tensor_t tensor = get_graph_tensor(RNet_graph, "conv5-2");
191 float* reg_data = ( float* )get_tensor_buffer(tensor);
192
193 tensor = get_graph_tensor(RNet_graph, "prob1");
194 float* confidence_data = ( float* )get_tensor_buffer(tensor);
195
196 int conf_page_size = 2;
197 int reg_page_size = 4;
198
199 for(int i = 0; i < batch; i++)
200 {
201 if(*(confidence_data + 1) > conf_r_threshold_)
202 {
203 face_box output_box;
204 face_box& input_box = pnet_boxes[i];
205

Callers

nothing calls this directly

Calls 10

get_graph_tensorFunction · 0.85
set_tensor_shapeFunction · 0.85
set_tensor_bufferFunction · 0.85
copy_one_patchFunction · 0.85
prerun_graphFunction · 0.85
get_tengine_errnoFunction · 0.85
run_graphFunction · 0.85
get_tensor_bufferFunction · 0.85
release_graph_tensorFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected