yolo-to-voc: Convert YOLO to Pascal VOC Format¶
The yolo-to-voc command converts YOLO format annotations (text files) to Pascal VOC XML format. Since YOLO annotations don't include image dimensions, corresponding images must be provided to extract this information.
Usage¶
Parameters¶
YOLO_DIR: Directory containing YOLO annotation text filesIMAGE_DIR: Directory containing corresponding images (PNG or JPG)NAMES_FILE: File containing class names, one per lineOUTPUT_DIR: Directory where VOC XML files will be saved--verbose, -v: (Optional) Display additional information about file matching
How It Works¶
- The command matches annotation files with image files by their filename stems
- For each matched pair, it:
- Reads the image dimensions using the
imagesizelibrary - Converts YOLO's normalized coordinates to absolute pixel coordinates
- Creates a Pascal VOC XML using the
pascal_voc_writerlibrary - Saves the XML to the output directory
- Reads the image dimensions using the
Notes¶
File Requirements
- YOLO annotations must have the
.txtfile extension - Image files must have
.pngor.jpgfile extensions - Files are matched based on filename stem (name without extension)
Missing Matches
If an annotation file has no matching image file or vice versa, a warning will be displayed and those files will be skipped.
Examples¶
Basic conversion:
Verbose output to debug file matching issues: