MCPcopy Index your code
hub / github.com/PaddlePaddle/PaddleDetection / predict_image

Method predict_image

deploy/python/infer.py:371–441  ·  view source on GitHub ↗
(self,
                      image_list,
                      run_benchmark=False,
                      repeats=1,
                      visual=True,
                      save_results=False)

Source from the content-addressed store, hash-verified

369 return results
370
371 def predict_image(self,
372 image_list,
373 run_benchmark=False,
374 repeats=1,
375 visual=True,
376 save_results=False):
377 batch_loop_cnt = math.ceil(float(len(image_list)) / self.batch_size)
378 results = []
379 for i in range(batch_loop_cnt):
380 start_index = i * self.batch_size
381 end_index = min((i + 1) * self.batch_size, len(image_list))
382 batch_image_list = image_list[start_index:end_index]
383 if run_benchmark:
384 # preprocess
385 inputs = self.preprocess(batch_image_list) # warmup
386 self.det_times.preprocess_time_s.start()
387 inputs = self.preprocess(batch_image_list)
388 self.det_times.preprocess_time_s.end()
389
390 # model prediction
391 result = self.predict(repeats=50, run_benchmark=True) # warmup
392 self.det_times.inference_time_s.start()
393 result = self.predict(repeats=repeats, run_benchmark=True)
394 self.det_times.inference_time_s.end(repeats=repeats)
395
396 # postprocess
397 result_warmup = self.postprocess(inputs, result) # warmup
398 self.det_times.postprocess_time_s.start()
399 result = self.postprocess(inputs, result)
400 self.det_times.postprocess_time_s.end()
401 self.det_times.img_num += len(batch_image_list)
402
403 cm, gm, gu = get_current_memory_mb()
404 self.cpu_mem += cm
405 self.gpu_mem += gm
406 self.gpu_util += gu
407 else:
408 # preprocess
409 self.det_times.preprocess_time_s.start()
410 inputs = self.preprocess(batch_image_list)
411 self.det_times.preprocess_time_s.end()
412
413 # model prediction
414 self.det_times.inference_time_s.start()
415 result = self.predict()
416 self.det_times.inference_time_s.end()
417
418 # postprocess
419 self.det_times.postprocess_time_s.start()
420 result = self.postprocess(inputs, result)
421 self.det_times.postprocess_time_s.end()
422 self.det_times.img_num += len(batch_image_list)
423
424 if visual:
425 visualize(
426 batch_image_list,
427 result,
428 self.pred_config.labels,

Callers 7

predict_videoMethod · 0.95
predict_with_given_detFunction · 0.45
topdown_unite_predictFunction · 0.45
mainFunction · 0.45

Calls 10

preprocessMethod · 0.95
predictMethod · 0.95
postprocessMethod · 0.95
merge_batch_resultMethod · 0.95
save_coco_resultsMethod · 0.95
get_current_memory_mbFunction · 0.90
appendMethod · 0.80
visualizeFunction · 0.70
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected