From 74fcd74f3f85890cd4c91c29fe06d7e3095249b5 Mon Sep 17 00:00:00 2001
From: Glenn Jocher
Date: Sun, 20 Apr 2025 17:46:47 +0200
Subject: [PATCH] Refactor `autosplit` and implement `split_classify_dataset`
(#20245)
Signed-off-by: Glenn Jocher
Co-authored-by: UltralyticsAssistant
---
docs/en/datasets/classify/caltech101.md | 15 +++
docs/en/datasets/classify/caltech256.md | 4 +
docs/en/datasets/detect/xview.md | 9 ++
docs/en/reference/data/split.md | 20 ++++
docs/en/reference/data/utils.md | 4 -
docs/en/usage/simple-utilities.md | 2 +-
tests/test_python.py | 3 +-
ultralytics/cfg/__init__.py | 4 +-
ultralytics/data/base.py | 24 +++--
ultralytics/data/split.py | 123 ++++++++++++++++++++++++
ultralytics/data/utils.py | 42 +++-----
11 files changed, 197 insertions(+), 53 deletions(-)
create mode 100644 docs/en/reference/data/split.md
create mode 100644 ultralytics/data/split.py
diff --git a/docs/en/datasets/classify/caltech101.md b/docs/en/datasets/classify/caltech101.md
index af0158a6..550e1f4e 100644
--- a/docs/en/datasets/classify/caltech101.md
+++ b/docs/en/datasets/classify/caltech101.md
@@ -8,6 +8,21 @@ keywords: Caltech-101, dataset, object recognition, machine learning, computer v
The [Caltech-101](https://data.caltech.edu/records/mzrjq-6wc02) dataset is a widely used dataset for object recognition tasks, containing around 9,000 images from 101 object categories. The categories were chosen to reflect a variety of real-world objects, and the images themselves were carefully selected and annotated to provide a challenging benchmark for object recognition algorithms.
+
+
+
+
+ Watch: How to Train Image Classification Model using Caltech-256 Dataset with Ultralytics HUB
+
+
+!!! note "Automatic Data Splitting"
+
+ The Caltech-101 dataset, as provided, does not come with pre-defined train/validation splits. However, when you use the training commands provided in the usage examples below, the Ultralytics framework will automatically split the dataset for you. The default split used is 80% for the training set and 20% for the validation set.
+
## Key Features
- The Caltech-101 dataset comprises around 9,000 color images divided into 101 categories.
diff --git a/docs/en/datasets/classify/caltech256.md b/docs/en/datasets/classify/caltech256.md
index b3dac996..a8ed3c81 100644
--- a/docs/en/datasets/classify/caltech256.md
+++ b/docs/en/datasets/classify/caltech256.md
@@ -19,6 +19,10 @@ The [Caltech-256](https://data.caltech.edu/records/nyy15-4j048) dataset is an ex
Watch: How to Train Image Classification Model using Caltech-256 Dataset with Ultralytics HUB
+!!! note "Automatic Data Splitting"
+
+ The Caltech-256 dataset, as provided, does not come with pre-defined train/validation splits. However, when you use the training commands provided in the usage examples below, the Ultralytics framework will automatically split the dataset for you. The default split used is 80% for the training set and 20% for the validation set.
+
## Key Features
- The Caltech-256 dataset comprises around 30,000 color images divided into 257 categories.
diff --git a/docs/en/datasets/detect/xview.md b/docs/en/datasets/detect/xview.md
index 9aae550b..df80952a 100644
--- a/docs/en/datasets/detect/xview.md
+++ b/docs/en/datasets/detect/xview.md
@@ -15,6 +15,15 @@ The [xView](http://xviewdataset.org/) dataset is one of the largest publicly ava
xView builds on the success of challenges like [Common Objects in Context (COCO)](../detect/coco.md) and aims to leverage computer vision to analyze the growing amount of available imagery from space in order to understand the visual world in new ways and address a range of important applications.
+!!! warning "Manual Download Required"
+
+ The xView dataset is **not** automatically downloaded by Ultralytics scripts. You **must** manually download the dataset first from the official source:
+
+ - **Source:** DIUx xView 2018 Challenge by U.S. National Geospatial-Intelligence Agency (NGA)
+ - **URL:** [https://challenge.xviewdataset.org](https://challenge.xviewdataset.org)
+
+ **Important:** After downloading the necessary files (e.g., `train_images.tif`, `val_images.tif`, `xView_train.geojson`), you need to extract them and place them into the correct directory structure, typically expected under a `datasets/xView/` folder, **before** running the training commands provided below. Ensure the dataset is properly set up as per the challenge instructions.
+
## Key Features
- xView contains over 1 million object instances across 60 classes.
diff --git a/docs/en/reference/data/split.md b/docs/en/reference/data/split.md
new file mode 100644
index 00000000..c60bfb7f
--- /dev/null
+++ b/docs/en/reference/data/split.md
@@ -0,0 +1,20 @@
+---
+description: Learn how to split datasets into train, validation, and test subsets using Ultralytics utilities for efficient data preparation.
+keywords: dataset splitting, autosplit dataset, training dataset preparation, validation set creation, Ultralytics data tools
+---
+
+# Reference for `ultralytics/data/split.py`
+
+!!! note
+
+ This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/split.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/split.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/data/split.py) 🛠️. Thank you 🙏!
+
+
+
+## ::: ultralytics.data.split.split_classify_dataset
+
+