ultralytics 8.3.166 Standardize VisDrone autodownload structure (#21367)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-07-13 19:46:34 +02:00 committed by GitHub
parent 3bb441b944
commit 29cf67de2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 77 additions and 70 deletions

View File

@ -1,6 +1,6 @@
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
__version__ = "8.3.165"
__version__ = "8.3.166"
import os

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── Argoverse ← downloads here (31.5 GB)
# └── Argoverse ← downloads here (31.5 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: Argoverse # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── dota1.5 ← downloads here (2GB)
# └── dota1.5 ← downloads here (2GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: DOTAv1.5 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── dota1 ← downloads here (2GB)
# └── dota1 ← downloads here (2GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: DOTAv1 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── GlobalWheat2020 ← downloads here (7.0 GB)
# └── GlobalWheat2020 ← downloads here (7.0 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: GlobalWheat2020 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── homeobjects-3K ← downloads here (390 MB)
# └── homeobjects-3K ← downloads here (390 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: homeobjects-3K # dataset root dir

View File

@ -7,7 +7,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── imagenet ← downloads here (144 GB)
# └── imagenet ← downloads here (144 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: imagenet # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── Objects365 ← downloads here (712 GB = 367G data + 345G zips)
# └── Objects365 ← downloads here (712 GB = 367G data + 345G zips)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: Objects365 # dataset root dir

View File

@ -6,13 +6,13 @@
# parent
# ├── ultralytics
# └── datasets
# └── SKU-110K ← downloads here (13.6 GB)
# └── SKU-110K ← downloads here (13.6 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: SKU-110K # dataset root dir
train: train.txt # train images (relative to 'path') 8219 images
val: val.txt # val images (relative to 'path') 588 images
test: test.txt # test images (optional) 2936 images
train: train.txt # train images (relative to 'path') 8219 images
val: val.txt # val images (relative to 'path') 588 images
test: test.txt # test images (optional) 2936 images
# Classes
names:

View File

@ -6,16 +6,16 @@
# parent
# ├── ultralytics
# └── datasets
# └── VOC ← downloads here (2.8 GB)
# └── VOC ← downloads here (2.8 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: VOC
train: # train images (relative to 'path') 16551 images
train: # train images (relative to 'path') 16551 images
- images/train2012
- images/train2007
- images/val2012
- images/val2007
val: # val images (relative to 'path') 4952 images
val: # val images (relative to 'path') 4952 images
- images/test2007
test: # test images (optional)
- images/test2007

View File

@ -6,13 +6,13 @@
# parent
# ├── ultralytics
# └── datasets
# └── VisDrone ← downloads here (2.3 GB)
# └── VisDrone ← downloads here (2.3 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: VisDrone # dataset root dir
train: VisDrone2019-DET-train/images # train images (relative to 'path') 6471 images
val: VisDrone2019-DET-val/images # val images (relative to 'path') 548 images
test: VisDrone2019-DET-test-dev/images # test images (optional) 1610 images
train: images/train # train images (relative to 'path') 6471 images
val: images/val # val images (relative to 'path') 548 images
test: images/test # test-dev images (optional) 1610 images
# Classes
names:
@ -31,50 +31,57 @@ names:
download: |
import os
from pathlib import Path
import shutil
from ultralytics.utils.downloads import download
def visdrone2yolo(dir):
"""Convert VisDrone annotations to YOLO format, creating label files with normalized bounding box coordinates."""
def visdrone2yolo(dir, split, source_name=None):
"""Convert VisDrone annotations to YOLO format with images/{split} and labels/{split} structure."""
from PIL import Image
from tqdm import tqdm
def convert_box(size, box):
# Convert VisDrone box to YOLO xywh box
dw = 1.0 / size[0]
dh = 1.0 / size[1]
return (box[0] + box[2] / 2) * dw, (box[1] + box[3] / 2) * dh, box[2] * dw, box[3] * dh
(dir / "labels").mkdir(parents=True, exist_ok=True) # make labels directory
pbar = tqdm((dir / "annotations").glob("*.txt"), desc=f"Converting {dir}")
for f in pbar:
img_size = Image.open((dir / "images" / f.name).with_suffix(".jpg")).size
source_dir = dir / (source_name or f"VisDrone2019-DET-{split}")
images_dir = dir / "images" / split
labels_dir = dir / "labels" / split
labels_dir.mkdir(parents=True, exist_ok=True)
# Move images to new structure
if (source_images_dir := source_dir / "images").exists():
images_dir.mkdir(parents=True, exist_ok=True)
for img in source_images_dir.glob("*.jpg"):
img.rename(images_dir / img.name)
for f in tqdm((source_dir / "annotations").glob("*.txt"), desc=f"Converting {split}"):
img_size = Image.open(images_dir / f.with_suffix(".jpg").name).size
dw, dh = 1.0 / img_size[0], 1.0 / img_size[1]
lines = []
with open(f, encoding="utf-8") as file: # read annotation.txt
for row in [x.split(",") for x in file.read().strip().splitlines()]:
if row[4] == "0": # VisDrone 'ignored regions' class 0
continue
cls = int(row[5]) - 1
box = convert_box(img_size, tuple(map(int, row[:4])))
lines.append(f"{cls} {' '.join(f'{x:.6f}' for x in box)}\n")
label_file = str(f).replace(f"{os.sep}annotations{os.sep}", f"{os.sep}labels{os.sep}")
with open(label_file, "w", encoding="utf-8") as fl:
fl.writelines(lines)
with open(f, encoding="utf-8") as file:
for row in [x.split(",") for x in file.read().strip().splitlines()]:
if row[4] != "0": # Skip ignored regions
x, y, w, h = map(int, row[:4])
cls = int(row[5]) - 1
# Convert to YOLO format
x_center, y_center = (x + w / 2) * dw, (y + h / 2) * dh
w_norm, h_norm = w * dw, h * dh
lines.append(f"{cls} {x_center:.6f} {y_center:.6f} {w_norm:.6f} {h_norm:.6f}\n")
(labels_dir / f.name).write_text("".join(lines), encoding="utf-8")
# Download
# Download (ignores test-challenge split)
dir = Path(yaml["path"]) # dataset root dir
urls = [
"https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-train.zip",
"https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-val.zip",
"https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-test-dev.zip",
"https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-test-challenge.zip",
# "https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-test-challenge.zip",
]
download(urls, dir=dir, curl=True, threads=4)
# Convert
for d in "VisDrone2019-DET-train", "VisDrone2019-DET-val", "VisDrone2019-DET-test-dev":
visdrone2yolo(dir / d) # convert VisDrone annotations to YOLO labels
splits = {"VisDrone2019-DET-train": "train", "VisDrone2019-DET-val": "val", "VisDrone2019-DET-test-dev": "test"}
for folder, split in splits.items():
visdrone2yolo(dir, split, folder) # convert VisDrone annotations to YOLO labels
shutil.rmtree(dir / folder) # cleanup original directory

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── african-wildlife ← downloads here (100 MB)
# └── african-wildlife ← downloads here (100 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: african-wildlife # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── brain-tumor ← downloads here (4.21 MB)
# └── brain-tumor ← downloads here (4.21 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: brain-tumor # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── carparts-seg ← downloads here (133 MB)
# └── carparts-seg ← downloads here (133 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: carparts-seg # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco-pose ← downloads here (20.1 GB)
# └── coco-pose ← downloads here (20.1 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco-pose # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco ← downloads here (20.1 GB)
# └── coco ← downloads here (20.1 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco128-seg ← downloads here (7 MB)
# └── coco128-seg ← downloads here (7 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco128-seg # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco128 ← downloads here (7 MB)
# └── coco128 ← downloads here (7 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco128 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco8-grayscale ← downloads here (1 MB)
# └── coco8-grayscale ← downloads here (1 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8-grayscale # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco8-multispectral ← downloads here (20.2 MB)
# └── coco8-multispectral ← downloads here (20.2 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8-multispectral # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco8-pose ← downloads here (1 MB)
# └── coco8-pose ← downloads here (1 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8-pose # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco8-seg ← downloads here (1 MB)
# └── coco8-seg ← downloads here (1 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8-seg # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── coco8 ← downloads here (1 MB)
# └── coco8 ← downloads here (1 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── crack-seg ← downloads here (91.6 MB)
# └── crack-seg ← downloads here (91.6 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: crack-seg # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── dog-pose ← downloads here (337 MB)
# └── dog-pose ← downloads here (337 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: dog-pose # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── dota8-multispectral ← downloads here (37.3MB)
# └── dota8-multispectral ← downloads here (37.3MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: dota8-multispectral # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── dota8 ← downloads here (1MB)
# └── dota8 ← downloads here (1MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: dota8 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── hand-keypoints ← downloads here (369 MB)
# └── hand-keypoints ← downloads here (369 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: hand-keypoints # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── lvis ← downloads here (20.1 GB)
# └── lvis ← downloads here (20.1 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: lvis # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── medical-pills ← downloads here (8.19 MB)
# └── medical-pills ← downloads here (8.19 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: medical-pills # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── open-images-v7 ← downloads here (561 GB)
# └── open-images-v7 ← downloads here (561 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: open-images-v7 # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── package-seg ← downloads here (103 MB)
# └── package-seg ← downloads here (103 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: package-seg # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── signature ← downloads here (11.3 MB)
# └── signature ← downloads here (11.3 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: signature # dataset root dir

View File

@ -6,7 +6,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── tiger-pose ← downloads here (49.8 MB)
# └── tiger-pose ← downloads here (49.8 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: tiger-pose # dataset root dir

View File

@ -7,7 +7,7 @@
# parent
# ├── ultralytics
# └── datasets
# └── xView ← downloads here (20.7 GB)
# └── xView ← downloads here (20.7 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: xView # dataset root dir