Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

add left time in progress hook #817

Merged
merged 3 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions chainercv/utils/iterator/progress_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ def __init__(self, n_total=None):
def __call__(self, in_values, out_values, rest_values):
self.n_processed += len(in_values[0])
fps = self.n_processed / (time.time() - self.start)
if self.n_total is not None:
if self.n_total is not None and fps > 0:
eta = int((self.n_total - self.n_processed) / fps)
sys.stdout.write(
'\r{:d} of {:d} samples, {:.2f} samples/sec'.format(
self.n_processed, self.n_total, fps))
'\r{:d} of {:d} samples, {:.2f} samples/sec,'
' ETA {:4d}:{:02d}:{:02d}'.format(
self.n_processed, self.n_total, fps,
eta // 60 // 60, (eta // 60) % 60, eta % 60))
else:
sys.stdout.write(
'\r{:d} samples, {:.2f} samples/sec'.format(
Expand Down