提交 227f4fdd 编写于 作者: D dongshuilong

update benchmark

上级 7ac12a94
...@@ -47,7 +47,7 @@ class ClsPredictor(Predictor): ...@@ -47,7 +47,7 @@ class ClsPredictor(Predictor):
import auto_log import auto_log
import os import os
pid = os.getpid() pid = os.getpid()
self.auto_log = auto_log.AutoLogger( self.auto_logger = auto_log.AutoLogger(
model_name=config["Global"].get("model_name", "cls"), model_name=config["Global"].get("model_name", "cls"),
model_precision='fp16' model_precision='fp16'
if config["Global"]["use_fp16"] else 'fp32', if config["Global"]["use_fp16"] else 'fp32',
...@@ -73,7 +73,7 @@ class ClsPredictor(Predictor): ...@@ -73,7 +73,7 @@ class ClsPredictor(Predictor):
0]) 0])
if self.benchmark: if self.benchmark:
self.auto_log.times.start() self.auto_logger.times.start()
if not isinstance(images, (list, )): if not isinstance(images, (list, )):
images = [images] images = [images]
for idx in range(len(images)): for idx in range(len(images)):
...@@ -81,17 +81,17 @@ class ClsPredictor(Predictor): ...@@ -81,17 +81,17 @@ class ClsPredictor(Predictor):
images[idx] = ops(images[idx]) images[idx] = ops(images[idx])
image = np.array(images) image = np.array(images)
if self.benchmark: if self.benchmark:
self.auto_log.times.stamp() self.auto_logger.times.stamp()
input_tensor.copy_from_cpu(image) input_tensor.copy_from_cpu(image)
self.paddle_predictor.run() self.paddle_predictor.run()
batch_output = output_tensor.copy_to_cpu() batch_output = output_tensor.copy_to_cpu()
if self.benchmark: if self.benchmark:
self.auto_log.times.stamp() self.auto_logger.times.stamp()
if self.postprocess is not None: if self.postprocess is not None:
batch_output = self.postprocess(batch_output) batch_output = self.postprocess(batch_output)
if self.benchmark: if self.benchmark:
self.auto_log.times.end(stamp=True) self.auto_logger.times.end(stamp=True)
return batch_output return batch_output
...@@ -131,7 +131,8 @@ def main(config): ...@@ -131,7 +131,8 @@ def main(config):
format(filename, clas_ids, scores_str, label_names)) format(filename, clas_ids, scores_str, label_names))
batch_imgs = [] batch_imgs = []
batch_names = [] batch_names = []
cls_predictor.auto_log.report() if cls_predictor.benchmark:
cls_predictor.auto_logger.report()
return return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册