Add Hyperparameter evolution Tuner() class (#4599)
This commit is contained in:
parent
7e99804263
commit
4bd62a299c
15 changed files with 403 additions and 91 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue