> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/datasets/versions/dataset-versions/create-a-dataset-version.md).

# Create a Dataset Version

Create a dataset version for use in training a model.

## About

A version is a point-in-time snapshot of your dataset: its images, annotations, train/valid/test splits, and the preprocessing and augmentation steps applied to them. Because each version records exactly which data and steps a model used, you can reproduce results and compare models fairly. When a new model performs differently, you know the change came from the model or the steps you picked, not from a hidden change in your data. Each version belongs to a Project in your Workspace. Learn more about [Workspaces and Projects](https://docs.roboflow.com/platform/workspaces/key-concepts).

{% hint style="info" %}
Once a version is created, it does not change. Adding or removing images, annotations, or other data in the project does not affect versions created before.
{% endhint %}

### Train, Valid, and Test Splits

Every image in a version belongs to one split. Each split has a different job:

<table data-search="false"><thead><tr><th></th><th>Train</th><th>Valid</th><th>Test</th></tr></thead><tbody><tr><td>Purpose</td><td>The model learns from these images.</td><td>Checked after every epoch, to tune settings and pick the best checkpoint.</td><td>Scored once at the end, for an unbiased estimate of real-world performance.</td></tr><tr><td>Model trains on it</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>Augmented</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>Recommended share</td><td>70%</td><td>20%</td><td>10%</td></tr></tbody></table>

Splits protect you from overfitting. An overfit model memorizes its training images instead of learning patterns that carry over to new ones: its loss on the Train set keeps falling while its loss on the Valid set starts to rise. Valid metrics show you when that happens. Because you make choices based on Valid metrics, your choices can slowly overfit to the Valid set too, so the Test set stays untouched until the end to give you an honest final score.

[Preprocessing](https://docs.roboflow.com/datasets/versions/dataset-versions/image-preprocessing.md) applies to all three splits. [Augmentations](https://docs.roboflow.com/datasets/versions/dataset-versions/image-augmentation.md) apply only to Train, so Valid and Test metrics reflect real, unaltered images.

To get trustworthy metrics:

* Start with 70/20/10. For very large datasets (tens of thousands of images), 80/10/10 also works. Keep at least a few hundred images in Valid and Test when you can: metrics from a handful of images are noisy.
* Make sure every class appears in all three splits.
* Avoid leakage, where near-identical images land in different splits (ex: consecutive video frames, burst photos, the same object shot twice from the same spot). The model then gets tested on images it has already seen, and metrics look better than real performance. Keep related images in the same split, for example by shuffling per upload batch when you rebalance.
* After you rebalance, train from a public checkpoint (ex: one pretrained on MS COCO), not from a model trained on your old splits. That model has already seen images that may now be in Valid or Test.

## Web App

### How To Create a Dataset Version

To create a dataset version, click "Versions" in your project's sidebar, then click "New Version".

The "Create New Version" page walks through these sections: "Source Images", "Train/Test Split", "Preprocessing", "Augmentation", and "Create". Set your splits, add [preprocessing steps](https://docs.roboflow.com/datasets/versions/dataset-versions/image-preprocessing.md) and [augmentations](https://docs.roboflow.com/datasets/versions/dataset-versions/image-augmentation/add-augmentations-to-images.md), then click "Create". You can then train a model on the version in Roboflow, or [export your dataset](https://docs.roboflow.com/datasets/versions/dataset-versions/exporting-data.md) to train a model yourself.

When you train from "Current Dataset" in training setup, Roboflow creates the version for you when training starts. See [Train a Model](https://docs.roboflow.com/models/train/train-a-model).

### Readjusting Train/Validation/Test Splits

Rebalancing moves images between splits in your project. New versions use the new splits; versions you already created stay unchanged.

On the "Create New Version" page, go to the "Train/Test Split" section and click "Rebalance" ("Choose Splits" if your images have no splits yet). Drag the slider to set the train, valid, and test percentages, then click "Save".

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-2d52b02e2ecfeab8434d6121246244480ffc1837%2Fversion-train-test-split-step.png?alt=media" alt="The Train/Test Split section showing 67% Train, 15% Valid, and 18% Test with a Rebalance button"><figcaption><p>The "Train/Test Split" section on the "Create New Version" page.</p></figcaption></figure>

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-449e5fb13f450a2417da5154a40dee741fcdc11b%2Fversion-rebalance-splits-modal.png?alt=media" alt="The Rebalance Splits dialog with a warning that adjusting splits affects this and all future versions, a two-handle split slider, and Cancel and Save buttons"><figcaption><p>Drag the two handles to set the split, then click "Save".</p></figcaption></figure>

In training setup, click the "Adjust split" button on "Current Dataset" to open "Adjust Train/Test Split". Click "Reset" to restore the recommended 70/20/10 split at any time, then click "Save".

To choose how images move, or to rebalance only some classes, open the "Rebalance Splits" dialog: click "Open Analytics" under "Balance specific classes" in "Adjust Train/Test Split", or click "Rebalance" on the "Classes" card of the [Dataset Health Check](https://docs.roboflow.com/datasets/versions/dataset-health-check.md). Set the percentages, then choose a "Method":

* "Move as few as possible" keeps images in their current split and only moves enough to reach the target percentages.
* "Random shuffle" randomly reassigns every image across the splits.
* "Random shuffle per upload batch or annotation job" shuffles each upload batch or completed annotation job separately, so every batch and job matches the target percentages.

The method starts as "Random shuffle". Use "Classes to Rebalance" to limit moves to images that contain only the selected classes. Images that also contain other classes stay in their current split. Selecting classes switches the method to "Move as few as possible", unless you already picked a method. Check "I understand that this will permanently update my dataset splits." and click "Rebalance Splits".

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-d36154f8edf01a133fcf4b09fdf7926794d525e8%2Fanalytics-classes-split-card.png?alt=media" alt="The Classes card in Dataset Analytics with per-class bars split into Train, Valid, and Test, and Rebalance and Download CSV buttons"><figcaption><p>The "Classes" card shows how each class is spread across splits.</p></figcaption></figure>

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-f393b21023b9334b9d63a865ae7d507dc8e330f5%2Fanalytics-rebalance-splits-modal.png?alt=media" alt="The Rebalance Splits dialog from Dataset Analytics with the split slider, Method set to Random shuffle, Classes to Rebalance set to All classes, and the confirmation checkbox"><figcaption><p>The "Rebalance Splits" dialog from Dataset Analytics.</p></figcaption></figure>

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-d41d7b83f38f1d2b76558caab32fe2a0f719e40c%2Fanalytics-rebalance-method-options.png?alt=media" alt="The Method dropdown open with Move as few as possible, Random shuffle, and Random shuffle per upload batch or annotation job"><figcaption><p>The three rebalance methods.</p></figcaption></figure>

For large datasets, the rebalance runs as a background task with per-phase progress. You can dismiss the dialog while it continues, and track it in the Activity Center.

## HTTP API

### Rebalance Train/Validation/Test Splits

Rebalance a Project's splits by making a POST request to the `/:workspace/:project/splits/rebalance` endpoint. This changes the splits on the Project itself, so the next version you generate uses the new balance.

The rebalance always runs as a background task. The request returns `202 Accepted` with a task ID and a polling URL. Poll the returned `url`, or call `GET /:workspace/asynctasks/:id` with the `taskId`, until the task completes.

The calling API key must have the `project:update` scope and permission to edit splits in the Workspace.

**Example Request**

```bash
$ curl --location "https://api.roboflow.com/my-workspace/my-project/splits/rebalance?api_key=$ROBOFLOW_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "splits": { "train": 70, "valid": 20, "test": 10 }
}'
```

**Parameters**

```
- splits (object) - Required. Target train, valid, and test values, each a non-negative integer. Values are relative, so 70/20/10 means 70%/20%/10%. At least one must be greater than 0.
- mode (string) - "rebalance" (default) moves as few images as possible. "shuffle" randomly reassigns every image.
- grouping (string) - Only used with "shuffle" mode. "global" (default) shuffles the whole Project. "batch" shuffles each upload batch and completed annotation job separately.
- classes (array of strings) - Limit the rebalance to images that contain only these classes. Images with other classes stay in their current split.
```

**Example Response**

```json
{
    "taskId": "abc123",
    "url": "https://api.roboflow.com/my-workspace/asynctasks/abc123"
}
```

## Python SDK

A version freezes a snapshot of the project's labeled data with a chosen set of preprocessing and augmentation steps applied. Train against a version, not against the project directly.

`Project.generate_version()` returns the new version number, which you can pass to `project.version(...)` to get a `Version` handle.

```python
import roboflow

rf = roboflow.Roboflow(api_key="YOUR_API_KEY")
project = rf.workspace().project("my-detector")

new_version = project.generate_version(settings={
    "preprocessing": {
        "auto-orient": True,
        "resize": {"width": 640, "height": 640, "format": "Stretch to"},
    },
    "augmentation": {},
})
version = project.version(new_version)
```

`augmentation.image.versions` is the maximum version size multiplier, and your plan caps it. Generation fails if you set it higher. See [Limiting Augmentations](https://docs.roboflow.com/datasets/versions/dataset-versions/image-augmentation.md#limiting-augmentations).

Here is a full example of the settings. There is a detailed explanation for each property below.

```json
{
    "versionName": "Raccoons",
    "augmentation": {
        "bbblur": { "pixels": 1.5 },
        "bbbrightness": { "brighten": true, "darken": false, "percent": 91 },
        "bbcrop": { "min": 12, "max": 71 },
        "bbexposure": { "percent": 30 },
        "bbflip": { "horizontal": true, "vertical": false },
        "bbnoise": { "percent": 50 },
        "bbninety": { "clockwise": true, "counter-clockwise": false, "upside-down": false },
        "bbrotate": { "degrees": 45 },
        "bbshear": { "horizontal": 45, "vertical": 45 },
        "blur": { "pixels": 1.5 },
        "brightness": { "brighten": true, "darken": false, "percent": 91 },
        "crop": { "min": 12, "max": 71 },
        "cutout": { "count": 26, "percent": 71 },
        "exposure": { "percent": 30 },
        "flip": { "horizontal": true, "vertical": false },
        "hue": { "degrees": 180 },
        "image": { "versions": 32 },
        "mosaic": true,
        "ninety": { "clockwise": true, "counter-clockwise": false, "upside-down": false },
        "noise": { "percent": 50 },
        "rgrayscale": { "percent": 50 },
        "rotate": { "degrees": 45 },
        "saturation": { "percent": 50 },
        "shear": { "horizontal": 45, "vertical": 45 }
    },
    "preprocessing": {
        "auto-orient": true,
        "contrast": { "type": "Contrast Stretching" },
        "filter-null": { "percent": 50 },
        "filter-tags": { "tag_name": true, "other_tag": false },
        "grayscale": true,
        "isolate": true,
        "remap": { "original_class_name": "new_class_name" },
        "resize": { "width": 200, "height": 200, "format": "Stretch to" },
        "static-crop": { "x_min": 10, "x_max": 90, "y_min": 10, "y_max": 90 },
        "tile": { "rows": 2, "columns": 2 }
    }
}
```

`tile` also takes the fixed tile modes: `{"mode": "fixed_size", "tileWidth": 640, "tileHeight": 640, "overlap": 5, "padding": "black"}` or `{"mode": "fixed_aspect", "aspectRatio": 1, "span": "width", "overlap": 5, "padding": "black"}`. See [Tile](https://docs.roboflow.com/datasets/versions/dataset-versions/image-preprocessing.md#tile).

## MCP Server

Connect your AI agent to the [MCP Server](https://docs.roboflow.com/agents/mcp-server) and it can generate a dataset version with these tools:

<table data-search="false"><thead><tr><th width="290">Tool</th><th>Description</th></tr></thead><tbody><tr><td><code>versions_generate</code></td><td>Create a version with optional preprocessing and augmentation.</td></tr><tr><td><code>versions_get</code></td><td>Get version info including splits and its trainings.</td></tr><tr><td><code>datasets_rebalance_splits</code></td><td>Enqueue an async rebalance of the train, valid, and test splits.</td></tr><tr><td><code>async_tasks_get</code></td><td>Poll the rebalance task until it finishes.</td></tr></tbody></table>
