Skip to content

onurrtosunn/Data_Convertion

Repository files navigation

Data Conversion Toolkit (CSV, YOLO TXT, Pascal VOC XML)

Installation

pip install -r requirements.txt

Supported Formats

  • CSV: filename, width, height, class, xmin, ymin, xmax, ymax
  • YOLO TXT: one .txt per image with normalized rows: class_id x_center y_center width height
  • Pascal VOC XML: annotation/object/bndbox structure

Commands

  • Convert CSV to YOLO TXT
python3 csv_to_txt.py -i annotations.csv -o yolo_txt_output
  • Convert CSV to Pascal VOC XML
python3 csv_to_xml.py -i annotations.csv -o voc_xml_output
  • Convert YOLO TXT to CSV
python3 txt_to_csv.py -i txt_dir -img images_dir -o annotations.csv --classes classes.json --image-ext .jpg
  • Convert YOLO TXT to Pascal VOC XML
python3 txt_to_xml.py -i txt_dir -img images_dir -o voc_xml_output --classes classes.json --image-ext .jpg
  • Convert Pascal VOC XML to CSV
python3 xml_to_csv.py -i xml_dir -o annotations.csv

Class Mappings

  • When reading YOLO TXT, you may pass --classes with a JSON mapping such as { "0": "person", "1": "car" }.
  • When writing YOLO TXT, class names are enumerated to integer identifiers starting from zero.

Architecture

  • conversion/models.py: data models ImageAnnotation, ObjectAnnotation, BoundingBox, ImageSize
  • conversion/protocols.py: interfaces AnnotationReader, AnnotationWriter
  • conversion/readers_*.py: readers for CSV, YOLO TXT, Pascal VOC XML
  • conversion/writers_*.py: writers for CSV, YOLO TXT, Pascal VOC XML

Each CLI tool composes readers and writers. The design follows single responsibility, clear dependencies, and extensibility principles.

Releases

No releases published

Packages

No packages published

Languages