Package: imageprep
ImagePrep is a tool for preparing image labels in different formats, primarily for object detection tasks.Deep Learning frameworks expect datasets to be prepared in a structure, style or format that
fits into their workflow. With ImagePrep, you can easily organize labels according to these
requirements. Currently, the tool simplifies the process of preparing labels using COCO,
Pascal VOC and YOLO style format. Conversion to one from another is also supported.Installationstable versionpip install imagepreplatest version:# clone repo
git clone https://github.com/adbeda/imageprep    

# install
cd imageprep && pip install -e .

# or simply with:
python -m pip install 'git+https://github.com/adbeda/imageprep.git'UsageExample 1: Organize images and labels in COCO stylefromimageprepimportcoco"""Folder Structure of a moc datasetdata├── images│   ├── 145_28.jpg│   ├── 79_38.jpg│   ├── 79_45.jpg│   └── 80_7.jpg└── labels├── 145_28.txt├── 79_38.txt├── 79_45.txt└── 80_7.txt"""# folder containing imagesimage_path="data/images/"label_path="data/labels/"# run taskcoco_dict=coco.coco_format_folder(image_path,label_path)print(coco_dict)Output:[{"image":[{"file_name":"data/images/145_28.jpg","height":416,"width":416}],"annotations":[{"bbox":[336,398,416,416],"id":1,"segmentation":[],"area":1440,"category_id":0},{"bbox":[3,91,105,163],"id":2,"segmentation":[],"area":7344,"category_id":0},{"bbox":[134,31,196,95],"id":3,"segmentation":[],"area":3968,"category_id":0}],"image_id":0},{"image":[{"file_name":"data/images/79_38.jpg","height":416,"width":416}],"annotations":[{"bbox":[257,306,325,370],"id":1,"segmentation":[],"area":4352,"category_id":0}],"image_id":1}]Example 2: Convert absolute bounding box values to YOLO style formatsXminYminXmaxYmax----->XcenterYcenterWidth Heightfromimageprepimportyolo"""# Input BBOX in absolute format (Xmin, Ymin, Xmax, Ymax)├── labels├── 145_28.txt│   ├── 336 398 416 416│   ├──   3  91 105 163│   ├── 134  31 196  95├── 79_38.txt│   ├── 257 306 325 370├── 79_45.txt│   ├──   0 399 133 416│   ├── 161 255 239 343│   ├── 336  32 416 108└── 80_7.txt├── 267 223 391 319"""# folder containing imagesimage_path="data/images/"label_path="data/labels/"output_path="data/yolo_labels/"# run task and save textyolo.convert_to_yolo(image_path,label_path,output_path)Output:# Output BBOX in relative format (Xcenter, Ycenter, Width, Height)├──yolo_labels├──145_28.txt│├──0.90384615384615390.97836538461538470.192307692307692320.04326923076923077│├──0.129807692307692320.305288461538461560.24519230769230770.17307692307692307│├──0.39663461538461540.15144230769230770.149038461538461540.15384615384615385├──79_38.txt│├──0.69951923076923080.81250.163461538461538460.15384615384615385├──79_45.txt│├──0.159855769230769250.97956730769230770.31971153846153850.040865384615384616│├──0.48076923076923080.718750.18750.21153846153846156│├──0.90384615384615390.168269230769230780.192307692307692320.1826923076923077└──80_7.txt├──0.79086538461538470.65144230769230770.29807692307692310.23076923076923078Command LineUsage: imageprep [OPTIONS] COMMAND [ARGS]...

  Dataset Preparation Helper

Options:
  -h, --help  Show this message and exit.

Commands:
  convert-to-yolo   Converts absolute bbox values to relative ones
  create-path-file  Writes out the path to images in a folder as a list
  get-image-name    Prints out the names of images in a folder
  resize-images     Resizes Image dimension to a size provided by userThe CLI is still in early stage of development.Use case:The above output can easily be integrated with data registration steps
requried to train a Mask-RCNN model usingDetectron2.
Check out the examplehere.Other functionalities included in the library:Create a  list of all bounding boxesStack and save images as numpy arrayDump labels as JSON objects to a fileResize images within a single or multiple foldersConvert relative (YOLO style) values to absolute onesCustomize a python dictionary of labels to a Detectron2 format
and more ...TODO: current and future workImprove the CLIAdd workflow for VOC styleTest against RCNN familiesCreate a documentationImprove integration for Detectron2 and YOLO