diff --git a/chainercv/utils/iterator/progress_hook.py b/chainercv/utils/iterator/progress_hook.py index 4835752a33..deabdba4ce 100644 --- a/chainercv/utils/iterator/progress_hook.py +++ b/chainercv/utils/iterator/progress_hook.py @@ -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(