ultralytics 8.0.56 PyTorch 2.0 support and minor fixes (#1538)

Co-authored-by: N-Friederich <127681326+N-Friederich@users.noreply.github.com>
Co-authored-by: Uhrendoktor <36703334+Uhrendoktor@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Aman Agarwal <amanag.11@gmail.com>
Co-authored-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
Co-authored-by: Nadav Eidelstein <30617226+nodeav@users.noreply.github.com>
This commit is contained in:
Glenn Jocher
2023-03-24 00:22:20 +01:00
committed by GitHub
parent 8c8c43922c
commit 28e48be5b6
18 changed files with 149 additions and 88 deletions

View File

@ -284,6 +284,7 @@ class LoadPilAndNumpy:
def __init__(self, im0, imgsz=640, stride=32, auto=True, transforms=None):
if not isinstance(im0, list):
im0 = [im0]
self.paths = [getattr(im, 'filename', f'image{i}.jpg') for i, im in enumerate(im0)]
self.im0 = [self._single_check(im) for im in im0]
self.imgsz = imgsz
self.stride = stride
@ -291,7 +292,6 @@ class LoadPilAndNumpy:
self.transforms = transforms
self.mode = 'image'
# generate fake paths
self.paths = [getattr(im, 'filename', f'image{i}.jpg') for i, im in enumerate(self.im0)]
self.bs = len(self.im0)
@staticmethod

View File

@ -125,7 +125,10 @@ class YOLODataset(BaseDataset):
self.label_files = img2label_paths(self.im_files)
cache_path = Path(self.label_files[0]).parent.with_suffix('.cache')
try:
import gc
gc.disable() # reduce pickle load time https://github.com/ultralytics/ultralytics/pull/1585
cache, exists = np.load(str(cache_path), allow_pickle=True).item(), True # load dict
gc.enable()
assert cache['version'] == self.cache_version # matches current version
assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical hash
except (FileNotFoundError, AssertionError, AttributeError):