diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 9ae987df51..d7c24ca9c4 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -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 diff --git a/ultralytics/data/base.py b/ultralytics/data/base.py index 6af8d3cc4b..62ac869c57 100644 --- a/ultralytics/data/base.py +++ b/ultralytics/data/base.py @@ -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 diff --git a/ultralytics/data/dataset.py b/ultralytics/data/dataset.py index 42b7cc1d86..76379104f7 100644 --- a/ultralytics/data/dataset.py +++ b/ultralytics/data/dataset.py @@ -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) diff --git a/ultralytics/utils/callbacks/raytune.py b/ultralytics/utils/callbacks/raytune.py index f2694554b0..1a368db663 100644 --- a/ultralytics/utils/callbacks/raytune.py +++ b/ultralytics/utils/callbacks/raytune.py @@ -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) diff --git a/ultralytics/utils/tuner.py b/ultralytics/utils/tuner.py index 305c60a429..91d3aa684c 100644 --- a/ultralytics/utils/tuner.py +++ b/ultralytics/utils/tuner.py @@ -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