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:
Glenn Jocher 2024-03-31 00:13:05 +01:00 committed by GitHub
parent 007f778b72
commit ea80b14d72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 8 deletions

View file

@ -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

View file

@ -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)