---
title: Detection transforms must update boxes along with images
slug: hf-datasets-object-detection
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://iinventedlight.com/library/notes/hf-datasets-object-detection.md
source_license: Apache-2.0
attribution: Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources
  below.
author: Librarian
client: Librarian
date: '2026-11-05'
checked_on: '2026-11-05'
as_of: '2026-11-05'
status: published
confidence: medium
category: coding-references
tags:
- hf
- datasets
- object
untested: Reference note. No code or commands were run to validate behavior.
sources:
- id: S1
  title: Object detection
  publisher: Hugging Face contributors
  url: https://raw.githubusercontent.com/huggingface/datasets/main/docs/source/object_detection.mdx
  accessed: '2026-11-05'
  license: Apache-2.0
  license_url: https://raw.githubusercontent.com/huggingface/datasets/main/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Hugging Face contributors; Object detection; Apache-2.0
  snapshot: _fetched/hf-obj.txt
- id: S2
  title: Create an image dataset
  publisher: Hugging Face contributors
  url: https://raw.githubusercontent.com/huggingface/datasets/main/docs/source/image_dataset.mdx
  accessed: '2026-11-05'
  license: Apache-2.0
  license_url: https://raw.githubusercontent.com/huggingface/datasets/main/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Hugging Face contributors; Create an image dataset; Apache-2.0
  snapshot: _fetched/hf-imagefolder.txt
---
# Detection transforms must update boxes along with images

## Summary
An object-detection dataset associates images with object annotations, including boxes and categories. Image geometry and box geometry must stay aligned during preprocessing. [S1]

## Details
The detection guide demonstrates a transform that resizes and flips an image while updating its boxes. Its example identifies the incoming box format as COCO and converts boxes before visualization. ImageFolder can store detection annotations in metadata beside image files, with `file_name` linking an annotation row to its image. Metadata is therefore part of the dataset, not an inferred substitute for boxes. [S1, S2]

## Claims
- id: C1
  claim: "The detection example stores box annotations under objects."
  source: S1
  evidence: "`objects`: A dictionary containing bounding box metadata"
- id: C2
  claim: "The demonstrated transform updates boxes with the image."
  source: S1
  evidence: "while also updating the `bboxes` accordingly"
- id: C3
  claim: "ImageFolder metadata can carry captions or bounding boxes."
  source: S2
  evidence: "text captions or bounding boxes"

## Sources
- [S1] Object detection. Hugging Face contributors. https://raw.githubusercontent.com/huggingface/datasets/main/docs/source/object_detection.mdx. Apache-2.0; license: https://raw.githubusercontent.com/huggingface/datasets/main/LICENSE. Accessed 2026-11-05.
- [S2] Create an image dataset. Hugging Face contributors. https://raw.githubusercontent.com/huggingface/datasets/main/docs/source/image_dataset.mdx. Apache-2.0; license: https://raw.githubusercontent.com/huggingface/datasets/main/LICENSE. Accessed 2026-11-05.

## Attribution and notices
This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

Hugging Face Datasets documentation is Apache-2.0. This note restates the documentation and includes only short evidence excerpts. See the accompanying source license.
