Overview
- Path type: Directory with
images/andlabels/ - Lossiness: Lossy (see below)
- Bbox format: Normalized center-width-height
[cx, cy, w, h](0..1) - Use case: YOLO model training, Ultralytics ecosystem
Directory Structure
Key Components
images/: Contains image files (.jpg,.png,.jpeg,.bmp,.webp)labels/: Contains label files (.txt), one per imagedata.yaml: Class map configuration (written by Panlabel)classes.txt: Alternative class map format (read by Panlabel)
Label File Format
Each.txt file in labels/ contains one line per bounding box:
class_id: Integer class index (0-based)x_center: Center X coordinate (0..1)y_center: Center Y coordinate (0..1)width: Box width (0..1)height: Box height (0..1)
Example Label File
labels/train/img1.txt:
- Line 1: Class 0, center at (50%, 50%), size 30% × 20%
- Line 2: Class 1, center at (25%, 75%), size 15% × 10%
Class Map
YOLO uses integer class IDs. Panlabel supports three class map sources:1. data.yaml (preferred)
2. classes.txt (fallback)
3. Inferred from labels (last resort)
If neitherdata.yaml nor classes.txt exists, Panlabel infers class names as class_0, class_1, etc.
Precedence: data.yaml → classes.txt → inferred
Bounding Box Format
YOLO uses normalized center-width-height coordinates:Conversion Example
YOLO label:cx = 0.5 × 640 = 320cy = 0.5 × 480 = 240w = 0.3 × 640 = 192h = 0.2 × 480 = 96xmin = cx - w/2 = 320 - 96 = 224ymin = cy - h/2 = 240 - 48 = 192xmax = cx + w/2 = 320 + 96 = 416ymax = cy + h/2 = 240 + 48 = 288
[224.0, 192.0, 416.0, 288.0]
Reader Behavior
Input Path
Accepts:- Dataset root containing
images/andlabels/ labels/directory directly (expects sibling../images/)
Reading Process
- Discover directory layout
- Read class map (
data.yaml→classes.txt→ inferred) - Scan all images in
images/(recursively) - Read image dimensions from file headers
- Match each label file to corresponding image (same stem)
- Parse label lines (reject segmentation/pose formats with >5 tokens)
- Assign deterministic IDs:
- Image IDs: by filename (lexicographic)
- Category IDs: by class name (lexicographic)
- Annotation IDs: by row order
Expected Image Extensions
Lookup order:jpg, png, jpeg, bmp, webp
Validation
- Each label file must map to a matching image file
- Label lines with >5 tokens are rejected (segmentation/pose not supported)
- Class IDs must be within range of class map
Writer Behavior
Output Structure
Writing Process
- Create
images/andlabels/directories - Write
data.yamlwith class map (sorted by category ID) - For each image:
- Create label file at
labels/<stem>.txt - Write annotations sorted by annotation ID
- Write empty
.txtfile for images without annotations
- Create label file at
- Does not copy image binaries (images must be placed manually)
Coordinate Precision
Normalized floats written with 6 decimal places:Subdirectories
Preserves image subdirectory structure:- Image:
train/img1.jpg→ Label:labels/train/img1.txt
Lossiness
YOLO format is lossy. Not preserved:- Dataset-level metadata/licenses
- Image-level license/date metadata
- Annotation confidence/attributes
- Category supercategory
- Custom attributes
- Image filenames and dimensions
- Category names (via
data.yaml) - Bounding box coordinates
Usage
Read YOLO
labels/ directly:
Write YOLO
Limitations
- Segmentation/pose annotations not supported (lines with >5 tokens rejected)
- Image binaries not copied during conversion
- No dataset-level metadata
- No annotation confidence/attributes
See Also
Pascal VOC
Another directory-based format
Format Overview
Compare all supported formats