Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#1157 from will-jl944/bug_fix
Browse files Browse the repository at this point in the history
[cherry-pick]fix timer bug
  • Loading branch information
will-jl944 authored Sep 23, 2021
2 parents bfa522f + d70ed5c commit dc14077
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions paddlex/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def predict(self,
images=images, topk=topk, transforms=transforms)

self.timer.repeats = repeats
self.timer.img_num = len(images)
self.timer.info(average=True)

return results
5 changes: 3 additions & 2 deletions paddlex/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ def __init__(self):

def info(self, average=False):
total_time = self.preprocess_time_s.value(
) + self.inference_time_s.value() + self.postprocess_time_s.value()
) * self.img_num + self.inference_time_s.value(
) + self.postprocess_time_s.value() * self.img_num
total_time = round(total_time, 4)
print("------------------ Inference Time Info ----------------------")
print("total_time(ms): {}, img_num: {}, batch_size: {}".format(
total_time * 1000, self.img_num, self.img_num / self.repeats))
total_time * 1000, self.img_num, self.img_num))
preprocess_time = round(
self.preprocess_time_s.value() / self.repeats,
4) if average else self.preprocess_time_s.value()
Expand Down

0 comments on commit dc14077

Please sign in to comment.