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

Method run_ONet

examples/mtcnn/mtcnn.cpp:234–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234int mtcnn::run_ONet(image img, std::vector<face_box>& rnet_boxes, std::vector<face_box>& output_boxes)
235{
236 int batch = rnet_boxes.size();
237
238 int channel = 3;
239 int height = 48;
240 int width = 48;
241 tensor_t input_tensor = get_graph_tensor(ONet_graph, "data");
242 int dims[] = {batch, channel, height, width};
243 set_tensor_shape(input_tensor, dims, 4);
244 int img_size = channel * height * width;
245 int in_mem = sizeof(float) * batch * img_size;
246 float* input_data = ( float* )malloc(in_mem);
247 float* input_ptr = input_data;
248 static bool first_run = true;
249
250 set_tensor_buffer(input_tensor, input_ptr, in_mem);
251 for(int i = 0; i < batch; i++)
252 {
253 copy_one_patch(img, rnet_boxes[i], input_ptr, width, height);
254
255 input_ptr += img_size;
256 }
257
258 if(first_run)
259 {
260 if(prerun_graph(ONet_graph) != 0)
261 {
262 std::cout << "Prerun ONet graph failed, errno: " << get_tengine_errno() << "\n";
263 return 1;
264 }
265 first_run = false;
266 }
267
268 if(run_graph(ONet_graph, 1) != 0)
269 {
270 std::cout << "Run ONet graph failed, errno: " << get_tengine_errno() << "\n";
271 return 1;
272 }
273 free(input_data);
274 /* output */
275 tensor_t tensor = get_graph_tensor(ONet_graph, "conv6-3");
276 float* points_data = ( float* )get_tensor_buffer(tensor);
277
278 tensor = get_graph_tensor(ONet_graph, "prob1");
279 float* confidence_data = ( float* )get_tensor_buffer(tensor);
280
281 tensor = get_graph_tensor(ONet_graph, "conv6-2");
282 float* reg_data = ( float* )get_tensor_buffer(tensor);
283
284 int conf_page_size = 2;
285 int reg_page_size = 4;
286 int points_page_size = 10;
287 for(int i = 0; i < batch; i++)
288 {
289 if(*(confidence_data + 1) > conf_o_threshold_)
290 {
291 face_box output_box;

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