|
|
|
|
|
from ultralytics.yolo.utils import LOGGER |
|
|
|
try: |
|
from ray import tune |
|
from ray.air import RunConfig, session |
|
from ray.air.integrations.wandb import WandbLoggerCallback |
|
from ray.tune.schedulers import ASHAScheduler |
|
from ray.tune.schedulers import AsyncHyperBandScheduler as AHB |
|
|
|
except ImportError: |
|
LOGGER.info("Tuning hyperparameters requires ray/tune. Install using `pip install 'ray[tune]'`") |
|
tune = None |
|
|
|
default_space = { |
|
|
|
'lr0': tune.uniform(1e-5, 1e-1), |
|
'lrf': tune.uniform(0.01, 1.0), |
|
'momentum': tune.uniform(0.6, 0.98), |
|
'weight_decay': tune.uniform(0.0, 0.001), |
|
'warmup_epochs': tune.uniform(0.0, 5.0), |
|
'warmup_momentum': tune.uniform(0.0, 0.95), |
|
'box': tune.uniform(0.02, 0.2), |
|
'cls': tune.uniform(0.2, 4.0), |
|
'hsv_h': tune.uniform(0.0, 0.1), |
|
'hsv_s': tune.uniform(0.0, 0.9), |
|
'hsv_v': tune.uniform(0.0, 0.9), |
|
'degrees': tune.uniform(0.0, 45.0), |
|
'translate': tune.uniform(0.0, 0.9), |
|
'scale': tune.uniform(0.0, 0.9), |
|
'shear': tune.uniform(0.0, 10.0), |
|
'perspective': tune.uniform(0.0, 0.001), |
|
'flipud': tune.uniform(0.0, 1.0), |
|
'fliplr': tune.uniform(0.0, 1.0), |
|
'mosaic': tune.uniform(0.0, 1.0), |
|
'mixup': tune.uniform(0.0, 1.0), |
|
'copy_paste': tune.uniform(0.0, 1.0)} |
|
|
|
task_metric_map = { |
|
'detect': 'metrics/mAP50-95(B)', |
|
'segment': 'metrics/mAP50-95(M)', |
|
'classify': 'metrics/accuracy_top1', |
|
'pose': 'metrics/mAP50-95(P)'} |
|
|