Skip to content

Commit

Permalink
Update tools.py
Browse files Browse the repository at this point in the history
If you don't use the condition expression speed may be 0 initially

deep-person-reid-master\torchreid\utils\tools.py", line 86, in _reporthook
    speed = int(progress_size / (1024*duration))
ZeroDivisionError: float division by zero
  • Loading branch information
chenghancc authored Aug 15, 2022
1 parent 91b032f commit be55021
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchreid/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _reporthook(count, block_size, total_size):
return
duration = time.time() - start_time
progress_size = int(count * block_size)
speed = int(progress_size / (1024*duration))
speed = 0 if duration == 0 else int(progress_size / (1024*duration))
percent = int(count * block_size * 100 / total_size)
sys.stdout.write(
'\r...%d%%, %d MB, %d KB/s, %d seconds passed' %
Expand Down

0 comments on commit be55021

Please sign in to comment.