ultralytics 8.2.52 fix CenterCrop transforms for PIL Image inputs (#14308)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Lucas Buligon Antunes <lukasbuligonantunes@gmail.com>
This commit is contained in:
parent
755dcd6ca0
commit
997f2c92cd
20 changed files with 38 additions and 30 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.2.51"
|
||||
__version__ = "8.2.52"
|
||||
|
||||
import os
|
||||
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ names:
|
|||
3: zebra
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/african-wildlife.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/african-wildlife.zip
|
||||
|
|
|
|||
|
|
@ -19,4 +19,4 @@ names:
|
|||
1: positive
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/brain-tumor.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/brain-tumor.zip
|
||||
|
|
|
|||
|
|
@ -40,4 +40,4 @@ names:
|
|||
22: wheel
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/carparts-seg.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/carparts-seg.zip
|
||||
|
|
|
|||
|
|
@ -97,4 +97,4 @@ names:
|
|||
79: toothbrush
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/coco128-seg.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128-seg.zip
|
||||
|
|
|
|||
|
|
@ -97,4 +97,4 @@ names:
|
|||
79: toothbrush
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/coco128.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ names:
|
|||
0: person
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/coco8-pose.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco8-pose.zip
|
||||
|
|
|
|||
|
|
@ -97,4 +97,4 @@ names:
|
|||
79: toothbrush
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/coco8-seg.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco8-seg.zip
|
||||
|
|
|
|||
|
|
@ -97,4 +97,4 @@ names:
|
|||
79: toothbrush
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/coco8.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco8.zip
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ names:
|
|||
0: crack
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/crack-seg.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/crack-seg.zip
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ names:
|
|||
0: package
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/package-seg.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/package-seg.zip
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ names:
|
|||
0: signature
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/signature.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/signature.zip
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ names:
|
|||
0: tiger
|
||||
|
||||
# Download script/URL (optional)
|
||||
download: https://ultralytics.com/assets/tiger-pose.zip
|
||||
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/tiger-pose.zip
|
||||
|
|
|
|||
|
|
@ -1401,6 +1401,8 @@ class CenterCrop:
|
|||
Returns:
|
||||
(numpy.ndarray): The center-cropped and resized image as a numpy array.
|
||||
"""
|
||||
if isinstance(im, Image.Image): # convert from PIL to numpy array if required
|
||||
im = np.asarray(im)
|
||||
imh, imw = im.shape[:2]
|
||||
m = min(imh, imw) # min dimension
|
||||
top, left = (imh - m) // 2, (imw - m) // 2
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from torch.utils.data import ConcatDataset
|
|||
|
||||
from ultralytics.utils import LOCAL_RANK, NUM_THREADS, TQDM, colorstr
|
||||
from ultralytics.utils.ops import resample_segments
|
||||
from ultralytics.utils.torch_utils import TORCH_1_13
|
||||
|
||||
from .augment import (
|
||||
Compose,
|
||||
|
|
@ -263,7 +264,7 @@ class YOLOMultiModalDataset(YOLODataset):
|
|||
super().__init__(*args, data=data, task=task, **kwargs)
|
||||
|
||||
def update_labels_info(self, label):
|
||||
"""Add texts information for multi modal model training."""
|
||||
"""Add texts information for multi-modal model training."""
|
||||
labels = super().update_labels_info(label)
|
||||
# NOTE: some categories are concatenated with its synonyms by `/`.
|
||||
labels["texts"] = [v.split("/") for _, v in self.data["names"].items()]
|
||||
|
|
@ -296,10 +297,10 @@ class GroundingDataset(YOLODataset):
|
|||
with open(self.json_file, "r") as f:
|
||||
annotations = json.load(f)
|
||||
images = {f'{x["id"]:d}': x for x in annotations["images"]}
|
||||
imgToAnns = defaultdict(list)
|
||||
img_to_anns = defaultdict(list)
|
||||
for ann in annotations["annotations"]:
|
||||
imgToAnns[ann["image_id"]].append(ann)
|
||||
for img_id, anns in TQDM(imgToAnns.items(), desc=f"Reading annotations {self.json_file}"):
|
||||
img_to_anns[ann["image_id"]].append(ann)
|
||||
for img_id, anns in TQDM(img_to_anns.items(), desc=f"Reading annotations {self.json_file}"):
|
||||
img = images[f"{img_id:d}"]
|
||||
h, w, f = img["height"], img["width"], img["file_name"]
|
||||
im_file = Path(self.img_path) / f
|
||||
|
|
@ -416,7 +417,10 @@ class ClassificationDataset:
|
|||
import torchvision # scope for faster 'import ultralytics'
|
||||
|
||||
# Base class assigned as attribute rather than used as base class to allow for scoping slow torchvision import
|
||||
self.base = torchvision.datasets.ImageFolder(root=root, allow_empty=True)
|
||||
if TORCH_1_13: # 'allow_empty' argument first introduced in torch 1.13
|
||||
self.base = torchvision.datasets.ImageFolder(root=root, allow_empty=True)
|
||||
else:
|
||||
self.base = torchvision.datasets.ImageFolder(root=root)
|
||||
self.samples = self.base.samples
|
||||
self.root = self.base.root
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ class RF100Benchmark:
|
|||
(shutil.rmtree("rf-100"), os.mkdir("rf-100")) if os.path.exists("rf-100") else os.mkdir("rf-100")
|
||||
os.chdir("rf-100")
|
||||
os.mkdir("ultralytics-benchmarks")
|
||||
safe_download("https://ultralytics.com/assets/datasets_links.txt")
|
||||
safe_download("https://github.com/ultralytics/yolov5/releases/download/v1.0/datasets_links.txt")
|
||||
|
||||
with open(ds_link_txt, "r") as file:
|
||||
for line in file:
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ def check_font(font="Arial.ttf"):
|
|||
return matches[0]
|
||||
|
||||
# Download to USER_CONFIG_DIR if missing
|
||||
url = f"https://ultralytics.com/assets/{name}"
|
||||
url = f"https://github.com/ultralytics/yolov5/releases/download/v1.0/{name}"
|
||||
if downloads.is_url(url, check=True):
|
||||
downloads.safe_download(url=url, file=file)
|
||||
return file
|
||||
|
|
|
|||
|
|
@ -194,12 +194,14 @@ def unzip_file(file, path=None, exclude=(".DS_Store", "__MACOSX"), exist_ok=Fals
|
|||
return path # return unzip dir
|
||||
|
||||
|
||||
def check_disk_space(url="https://ultralytics.com/assets/coco128.zip", path=Path.cwd(), sf=1.5, hard=True):
|
||||
def check_disk_space(
|
||||
url="https://github.com/ultralytics/yolov5/releases/download/v1.0/coco8.zip", path=Path.cwd(), sf=1.5, hard=True
|
||||
):
|
||||
"""
|
||||
Check if there is sufficient disk space to download and store a file.
|
||||
|
||||
Args:
|
||||
url (str, optional): The URL to the file. Defaults to 'https://ultralytics.com/assets/coco128.zip'.
|
||||
url (str, optional): The URL to the file. Defaults to 'https://ultralytics.com/assets/coco8.zip'.
|
||||
path (str | Path, optional): The path or drive to check the available free space on.
|
||||
sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 2.0.
|
||||
hard (bool, optional): Whether to throw an error or not on insufficient disk space. Defaults to True.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue