Overview
- Path type: XML file (
.xml) or directory withannotations.xml - Lossiness: Lossy (see below)
- Bbox format: Pixel-space top-left/bottom-right
[xtl, ytl, xbr, ybr] - Use case: CVAT integration, annotation workflows
Key Features
✓ Supports “for images” task exports✓ Box annotations only (
<box> elements)✓ Preserves
occluded, z_order, source attributes✓ Preserves custom
<attribute> elements✓ Validates labels against metadata (if present)
✓ Writes minimal XML with referenced categories only
⚠️ Project exports not supported (task exports only)
⚠️ Non-box shapes (
<polygon>, <polyline>, etc.) cause errors
Structure
CVAT uses a single XML file with<annotations> root:
Bounding Box Format
CVAT uses pixel-space top-left/bottom-right coordinates:xtl: Top-left X (xmin)ytl: Top-left Y (ymin)xbr: Bottom-right X (xmax)ybr: Bottom-right Y (ymax)
Box Attributes
CVAT supports several standard attributes:Standard Attributes
label: Category name (required)occluded:0or1(default:0)z_order: Integer stacking order (default:0)source: Annotation source (e.g.,"manual","auto")
Custom Attributes
CVAT allows custom<attribute> elements:
Annotation.attributes["cvat_attr_<name>"].
Attribute Mapping
Reading:- Retrieves
occludedfrom attributes (normalizes to0or1) - Retrieves
z_orderfrom attributes (default:0) - Retrieves
sourcefrom attributes (default:"manual") - Writes custom attributes with
cvat_attr_prefix
Metadata Labels
CVAT XML may include label metadata in<meta><task><labels>:
Reader Behavior
If metadata labels are present:- Keeps labels with
<type>bbox</type>or no<type>(default: bbox) - Verifies every
<box label="...">exists in metadata labels - Ignores non-bbox labels (e.g.,
polygon)
- Infers categories from
<box label="...">attributes
Reader Behavior
Input Path
Accepts:- XML file (
.xml) - Directory containing
annotations.xml
Reading Process
- Parse XML and validate
<annotations>root - Extract metadata labels (if present)
- Parse each
<image>element:- Extract
id,name,width,height - Parse all
<box>elements - Reject unsupported shapes (
<polygon>,<polyline>, etc.)
- Extract
- Assign deterministic IDs:
- Image IDs: by
<image name>(lexicographic) - Category IDs: by label name (lexicographic)
- Annotation IDs: by image order then
<box>order
- Image IDs: by
Validation
- Rejects project exports (only task exports supported)
- Rejects non-box shapes with hard error
- Validates box labels against metadata (if present)
- Requires unique image names
Image ID Preservation
Stores CVAT’s<image id> as Image.attributes["cvat_image_id"].
Writer Behavior
Output Structure
- If path ends with
.xml: writes directly to that file - Otherwise: creates
annotations.xmlinside directory
Writing Process
- Create minimal
<meta><task>withname='panlabel export' - Write labels only for referenced categories (not all categories)
- Write all images (including unannotated images)
- Write boxes sorted by annotation ID per image
- Normalize
occludedvalues (true/yes/1 → 1, false/no/0 → 0, else → 0)
Task Metadata
Writes minimal task metadata:Empty Images
Writes image entries without boxes:Lossiness
CVAT format is lossy:Preserved ✓
- Image names and dimensions
- CVAT image IDs (as attribute)
- Category names
- Bounding boxes (pixel XYXY)
occluded,z_order,sourceattributes- Custom
<attribute>elements (ascvat_attr_*)
Not Preserved ✗
- Dataset-level metadata/licenses
- Annotation confidence
- Category supercategory
- Custom image attributes (except
cvat_image_id) - Custom annotation attributes (except standard CVAT attrs)
Usage
Read CVAT
cvat-xml
Write CVAT
Unsupported Shapes
Panlabel only supports<box> elements. Other shapes cause errors:
Boolean Normalization
Writes normalizedoccluded values:
| Input | Output |
|---|---|
true, yes, 1 | 1 |
false, no, 0 | 0 |
| Other or missing | 0 |
See Also
Label Studio
Another annotation tool format
Format Overview
Compare all supported formats