Intermediate Representation
The Intermediate Representation (IR) is Panlabel’s canonical, format-agnostic representation of object detection datasets. All format conversions flow through the IR, similar to how Pandoc uses an internal AST for document conversion.Design Principles
The IR follows three key principles:- Type Safety: Uses newtypes and marker types to prevent common errors at compile time (e.g., mixing pixel and normalized coordinates)
- Canonical Format: Uses a single, well-defined coordinate system (XYXY in pixel space) to avoid ambiguity
- Permissive Construction: Allows “invalid” data to be represented (e.g., negative coordinates), so validation can report issues rather than panic during parsing
Core Types
Dataset
The top-level structure representing a complete annotation dataset:DatasetInfo
Metadata about the dataset:Image
Represents an image in the dataset:Category
Represents a class label:Annotation
Represents a bounding box annotation:License
Represents a license that can be associated with images:Bounding Box Types
BBoxXYXY
The canonical bounding box representation using XYXY format (xmin, ymin, xmax, ymax):TSpace parameter enforces coordinate space safety:
BBoxXYXY<Pixel>: Absolute pixel coordinatesBBoxXYXY<Normalized>: Normalized coordinates (0.0-1.0)
Coordinate System
Panlabel uses pixel-based XYXY coordinates as the canonical representation:- Origin: Top-left corner (0, 0)
- X-axis: Increases to the right
- Y-axis: Increases downward
- Format:
(xmin, ymin, xmax, ymax)in absolute pixel coordinates - Type:
f64for all coordinates (allows sub-pixel precision)
- Width: 90 pixels
- Height: 60 pixels
- Area: 5,400 square pixels
Type Safety
Panlabel uses newtype wrappers to prevent ID confusion:ImageId where a CategoryId is expected:
Complete Example
Next Steps
- Learn how to read and write formats in Format I/O
- Validate your datasets with the Validation API
- Understand format compatibility with Conversion