更新 detacttracking
This commit is contained in:
27
detecttracking/tracking/utils/gen.py
Normal file
27
detecttracking/tracking/utils/gen.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Tue Jan 16 10:36:38 2024
|
||||
|
||||
@author: ym
|
||||
"""
|
||||
import contextlib
|
||||
import time
|
||||
|
||||
class Profile(contextlib.ContextDecorator):
|
||||
# YOLOv5 Profile class. Usage: @Profile() decorator or 'with Profile():' context manager
|
||||
def __init__(self, t=0.0):
|
||||
self.t = t
|
||||
# self.cuda = torch.cuda.is_available()
|
||||
|
||||
def __enter__(self):
|
||||
self.start = self.time()
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.dt = self.time() - self.start # delta-time
|
||||
self.t += self.dt # accumulate dt
|
||||
|
||||
def time(self):
|
||||
# if self.cuda:
|
||||
# torch.cuda.synchronize()
|
||||
return time.time()
|
Reference in New Issue
Block a user