未验证 提交 cdd98d08 编写于 作者: D Double_V 提交者: GitHub

Update predict_det.py

上级 e4d49819
...@@ -175,6 +175,7 @@ class TextDetector(object): ...@@ -175,6 +175,7 @@ class TextDetector(object):
st = time.time() st = time.time()
if args.benchmark:
self.autolog.times.start() self.autolog.times.start()
data = transform(data, self.preprocess_op) data = transform(data, self.preprocess_op)
...@@ -185,6 +186,7 @@ class TextDetector(object): ...@@ -185,6 +186,7 @@ class TextDetector(object):
shape_list = np.expand_dims(shape_list, axis=0) shape_list = np.expand_dims(shape_list, axis=0)
img = img.copy() img = img.copy()
if args.benchmark:
self.autolog.times.stamp() self.autolog.times.stamp()
self.input_tensor.copy_from_cpu(img) self.input_tensor.copy_from_cpu(img)
...@@ -193,7 +195,7 @@ class TextDetector(object): ...@@ -193,7 +195,7 @@ class TextDetector(object):
for output_tensor in self.output_tensors: for output_tensor in self.output_tensors:
output = output_tensor.copy_to_cpu() output = output_tensor.copy_to_cpu()
outputs.append(output) outputs.append(output)
if args.benchmark:
self.autolog.times.stamp() self.autolog.times.stamp()
preds = {} preds = {}
...@@ -218,6 +220,7 @@ class TextDetector(object): ...@@ -218,6 +220,7 @@ class TextDetector(object):
else: else:
dt_boxes = self.filter_tag_det_res(dt_boxes, ori_im.shape) dt_boxes = self.filter_tag_det_res(dt_boxes, ori_im.shape)
if args.benchmark:
self.autolog.times.end(stamp=True) self.autolog.times.end(stamp=True)
et = time.time() et = time.time()
return dt_boxes, et - st return dt_boxes, et - st
...@@ -260,5 +263,6 @@ if __name__ == "__main__": ...@@ -260,5 +263,6 @@ if __name__ == "__main__":
cv2.imwrite(img_path, src_im) cv2.imwrite(img_path, src_im)
logger.info("The visualized image saved in {}".format(img_path)) logger.info("The visualized image saved in {}".format(img_path))
if args.benchmark:
text_detector.autolog.report() text_detector.autolog.report()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册