Download UnOpticalFlow/core/visualize/profiler.py from doanh25032004/models_animerun: direct link, hf CLI and curl.
- Browser
- Download file 887 Bytes
-
https://huggingface.co/doanh25032004/models_animerun/resolve/main/UnOpticalFlow/core/visualize/profiler.py
- Command line
-
hf download hf://doanh25032004/models_animerun/UnOpticalFlow/core/visualize/profiler.py
-
curl -L -o profiler.py https://huggingface.co/doanh25032004/models_animerun/resolve/main/UnOpticalFlow/core/visualize/profiler.py
887 Bytes
| import os | |
| import time | |
| import torch | |
| import pdb | |
| class Profiler(object): | |
| def __init__(self, silent=False): | |
| self.silent = silent | |
| torch.cuda.synchronize() | |
| self.start = time.time() | |
| self.cache_time = self.start | |
| def reset(self, silent=None): | |
| if silent is None: | |
| silent = self.silent | |
| self.__init__(silent=silent) | |
| def report_process(self, process_name): | |
| if self.silent: | |
| return None | |
| torch.cuda.synchronize() | |
| now = time.time() | |
| print('{0}\t: {1:.4f}'.format(process_name, now - self.cache_time)) | |
| self.cache_time = now | |
| def report_all(self, whole_process_name): | |
| if self.silent: | |
| return None | |
| torch.cuda.synchronize() | |
| now = time.time() | |
| print('{0}\t: {1:.4f}'.format(whole_process_name, now - self.start)) | |
| pdb.set_trace() | |