Add Hyperparameter evolution Tuner() class (#4599)

This commit is contained in:
Glenn Jocher 2023-08-29 02:42:01 +02:00 committed by GitHub
parent 7e99804263
commit 4bd62a299c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 403 additions and 91 deletions

View file

@ -17,6 +17,16 @@ from ultralytics.utils import LOGGER
class Profile(contextlib.ContextDecorator):
"""
YOLOv8 Profile class. Use as a decorator with @Profile() or as a context manager with 'with Profile():'.
Example:
```python
from ultralytics.utils.ops import Profile
with Profile() as dt:
pass # slow operation here
print(dt) # prints "Elapsed time is 9.5367431640625e-07 s"
```
"""
def __init__(self, t=0.0):
@ -39,6 +49,9 @@ class Profile(contextlib.ContextDecorator):
self.dt = self.time() - self.start # delta-time
self.t += self.dt # accumulate dt
def __str__(self):
return f'Elapsed time is {self.t} s'
def time(self):
"""Get current time."""
if self.cuda: