> 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/annotate/annotate/ai-labeling/auto-label-size-filter.md).

# Auto Label Size Filter

Drop Auto Label results that are too small or too large, in image pixels or real units.

"Filter by size" drops [Auto Label](https://docs.roboflow.com/datasets/annotate/annotate/ai-labeling/auto-label.md) labels that are too small or too large to be the object you want (ex: specks of dust, or one box around a whole part when you want each defect). You set a minimum and maximum width and height. The preview hides labels outside them as you type, and "Label batch" does not save them. Classification projects do not have the filter.

## Filter Labels by Size

The filter shows under the class list, before you run a preview. Sizes you set first apply to the preview when it runs.

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-a565bb8f712953a0b8577d232afc20ca85c7fba4%2Fauto-label-size-filter-off.png?alt=media" alt="The Auto Label page after a preview, with every shape labeled and the Filter by size control turned off."><figcaption><p>"Filter by size" is off: every shape the model found is labeled.</p></figcaption></figure>

1. Turn on "Filter by size".
2. Enter a "Min" or "Max" for "Width" and "Height". Sizes are in image pixels, and a label that is exactly at a limit is kept. Leave a field blank to allow any size.
3. Check the preview. Labels outside the sizes disappear as you type. The filter shows how many labels it removed on the current image, and the count above the preview shows how many are left (ex: "4 of 8 predictions shown"). The class list counts the same labels.
4. Click "Label batch". The job uses the same sizes and does not save labels outside them.

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-1b043fe28c3d7e44dcb24f9f91a00b11a5659011%2Fauto-label-size-filter-pixels.png?alt=media" alt="The same preview with Width set to a minimum of 50 and a maximum of 150 pixels. The smallest and largest shapes have no label."><figcaption><p>A width of 50 to 150 pixels keeps 4 of the 8 shapes.</p></figcaption></figure>

If a minimum is more than its maximum, the filter shows an error and "Label batch" is off until you fix it.

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-fb053607ed14f29c3953a3d6869593fd9ca60d15%2Fauto-label-size-filter-error.png?alt=media" alt="The Filter by size control with a minimum width of 5 and a maximum of 3, showing the error: A minimum must not be more than its maximum." width="304"><figcaption><p>A minimum above its maximum turns the filter off and blocks "Label batch".</p></figcaption></figure>

## Enter Sizes in Real Units

To enter sizes in a real unit instead of pixels, set a scale:

1. Under "Scale", enter how many image pixels span a known length, then pick a unit (mm, cm, m, in, or ft). For example, if a 1 cm part is 50 pixels wide in your images, enter 50 px = 1 cm.
2. Pick "Sizes in cm" (or your unit) above the size fields.

Switching between pixels and your unit converts the sizes you entered, so the filter does not move. If you change the scale later, sizes in your unit keep their length, and the pixel limits follow the new scale. To go back to pixels only, clear both scale fields.

<figure><img src="https://2252499186-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNVfRxNsvCh4GOyqrjmzX%2Fuploads%2Fgit-blob-01155ebe64305896a80c11ad35f9baa16331e4ee%2Fauto-label-size-filter-scale.png?alt=media" alt="The Filter by size control with a scale of 50 px = 1 cm, Sizes in cm selected, and Width from 1 to 3." width="304"><figcaption><p>With a scale of 50 px = 1 cm, a width of 1 to 3 cm is the same filter as 50 to 150 pixels.</p></figcaption></figure>

The scale is saved in your browser and shared with the [Measurement Guide](https://docs.roboflow.com/datasets/annotate/annotate/use-roboflow-annotate.md#measurement-guide) in the annotation editor: a scale you set in one shows in the other. Jobs always receive the sizes in pixels.

## How Labels Are Measured

The filter measures the box around each label. For a polygon, a mask, or a keypoint instance, that is the box around its outline. When a label has more than one polygon or mask, the filter measures the first one, which is the one Auto Label saves.

## HTTP API

Pass `sizeFilter` when you [create an Auto Label job](https://docs.roboflow.com/datasets/annotate/annotate/ai-labeling/auto-label.md#create-an-auto-label-job). It takes any of `minWidth`, `maxWidth`, `minHeight`, and `maxHeight`, in image pixels (ex: `{"minWidth": 20, "maxWidth": 400}`). A request with a minimum above its maximum fails with `errorType` `INVALID_SIZE_FILTER`, and no job is created.

The [Python SDK](https://docs.roboflow.com/datasets/annotate/annotate/ai-labeling/auto-label.md#python-sdk), the [CLI](https://docs.roboflow.com/datasets/annotate/annotate/ai-labeling/auto-label.md#cli), and the [MCP Server](https://docs.roboflow.com/datasets/annotate/annotate/ai-labeling/auto-label.md#mcp-server) take the same sizes.
