ultralytics 8.1.38 fix deprecated Ray Tune .is_session_enabled() (#9432)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
007f778b72
commit
ea80b14d72
5 changed files with 11 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.1.37"
|
||||
__version__ = "8.1.38"
|
||||
|
||||
from ultralytics.data.explorer.explorer import Explorer
|
||||
from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ class BaseDataset(Dataset):
|
|||
if self.rect:
|
||||
assert self.batch_size is not None
|
||||
self.set_rectangle()
|
||||
if isinstance(cache, str):
|
||||
cache = cache.lower()
|
||||
|
||||
# Buffer thread for mosaic images
|
||||
self.buffer = [] # buffer size = batch size
|
||||
|
|
|
|||
|
|
@ -261,8 +261,8 @@ class ClassificationDataset(torchvision.datasets.ImageFolder):
|
|||
if augment and args.fraction < 1.0: # reduce training fraction
|
||||
self.samples = self.samples[: round(len(self.samples) * args.fraction)]
|
||||
self.prefix = colorstr(f"{prefix}: ") if prefix else ""
|
||||
self.cache_ram = args.cache is True or args.cache == "ram" # cache images into RAM
|
||||
self.cache_disk = args.cache == "disk" # cache images on hard drive as uncompressed *.npy files
|
||||
self.cache_ram = args.cache is True or str(args.cache).lower() == "ram" # cache images into RAM
|
||||
self.cache_disk = str(args.cache).lower() == "disk" # cache images on hard drive as uncompressed *.npy files
|
||||
self.samples = self.verify_images() # filter out bad images
|
||||
self.samples = [list(x) + [Path(x[0]).with_suffix(".npy"), None] for x in self.samples] # file, index, npy, im
|
||||
scale = (1.0 - args.scale, 1.0) # (0.08, 1.0)
|
||||
|
|
@ -285,8 +285,9 @@ class ClassificationDataset(torchvision.datasets.ImageFolder):
|
|||
def __getitem__(self, i):
|
||||
"""Returns subset of data and targets corresponding to given indices."""
|
||||
f, j, fn, im = self.samples[i] # filename, index, filename.with_suffix('.npy'), image
|
||||
if self.cache_ram and im is None:
|
||||
im = self.samples[i][3] = cv2.imread(f)
|
||||
if self.cache_ram:
|
||||
if im is None: # Warning: two separate if statements required here, do not combine this with previous line
|
||||
im = self.samples[i][3] = cv2.imread(f)
|
||||
elif self.cache_disk:
|
||||
if not fn.exists(): # load npy
|
||||
np.save(fn.as_posix(), cv2.imread(f), allow_pickle=False)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ except (ImportError, AssertionError):
|
|||
|
||||
def on_fit_epoch_end(trainer):
|
||||
"""Sends training metrics to Ray Tune at end of each epoch."""
|
||||
if ray.tune.is_session_enabled():
|
||||
if ray.train._internal.session._get_session(): # replacement for deprecated ray.tune.is_session_enabled()
|
||||
metrics = trainer.metrics
|
||||
metrics["epoch"] = trainer.epoch
|
||||
session.report(metrics)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def run_ray_tune(
|
|||
train_args = {}
|
||||
|
||||
try:
|
||||
subprocess.run("pip install ray[tune]<=2.9.3".split(), check=True) # do not add single quotes here
|
||||
subprocess.run("pip install ray[tune]".split(), check=True) # do not add single quotes here
|
||||
|
||||
import ray
|
||||
from ray import tune
|
||||
|
|
@ -48,7 +48,7 @@ def run_ray_tune(
|
|||
from ray.air.integrations.wandb import WandbLoggerCallback
|
||||
from ray.tune.schedulers import ASHAScheduler
|
||||
except ImportError:
|
||||
raise ModuleNotFoundError('Ray Tune required but not found. To install run: pip install "ray[tune]<=2.9.3"')
|
||||
raise ModuleNotFoundError('Ray Tune required but not found. To install run: pip install "ray[tune]"')
|
||||
|
||||
try:
|
||||
import wandb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue