Download CARPK/tool/lib/utils/timer.py from ObjEarth/ObjEarth-Data: direct link, hf CLI and curl.
- Browser
- Download file 948 Bytes
-
https://huggingface.co/datasets/ObjEarth/ObjEarth-Data/resolve/main/CARPK/tool/lib/utils/timer.py
- Command line
-
hf download hf://datasets/ObjEarth/ObjEarth-Data/CARPK/tool/lib/utils/timer.py
-
curl -L -o timer.py https://huggingface.co/datasets/ObjEarth/ObjEarth-Data/resolve/main/CARPK/tool/lib/utils/timer.py
948 Bytes
| # -------------------------------------------------------- | |
| # Fast R-CNN | |
| # Copyright (c) 2015 Microsoft | |
| # Licensed under The MIT License [see LICENSE for details] | |
| # Written by Ross Girshick | |
| # -------------------------------------------------------- | |
| import time | |
| class Timer(object): | |
| """A simple timer.""" | |
| def __init__(self): | |
| self.total_time = 0. | |
| self.calls = 0 | |
| self.start_time = 0. | |
| self.diff = 0. | |
| self.average_time = 0. | |
| def tic(self): | |
| # using time.time instead of time.clock because time time.clock | |
| # does not normalize for multithreading | |
| self.start_time = time.time() | |
| def toc(self, average=True): | |
| self.diff = time.time() - self.start_time | |
| self.total_time += self.diff | |
| self.calls += 1 | |
| self.average_time = self.total_time / self.calls | |
| if average: | |
| return self.average_time | |
| else: | |
| return self.diff | |