Skip to main content

A Python library for object detection format conversion

Project description

VisualFlow

VisualFlow Logo

PyPI version License: MIT

VisualFlow is a Python library for object detection that provides conversion functions between Pascal VOC, YOLO, and COCO formats. It aims to simplify the process of converting annotated datasets between these popular object detection formats.

We have started this library with the vision of providing end to end object detection, from formatting all the way to inferencing multiple types of object detection models.

Our initial version of VisualFlow allows format conversions between PASCAL VOC, COCO and YOLO. Stay tuned for future updates!

Installation

You can install VisualFlow using pip:

pip install visualflow

Usage

Conversions

VisualFlow provides three main conversion functions: to_voc(), to_yolo(), and to_coco(). Here's how you can use them:

Conversion to YOLO Format

To convert from PASCAL VOC or COCO format to YOLO format, use the to_yolo() function.

For VOC to YOLO:

import VisualFlow as vf

vf.to_yolo(in_format='voc',
       images='path/to/images',
       annotations='path/to/annotations',
       out_dir='path/to/output')

For COCO to YOLO:

import VisualFlow as vf

vf.to_yolo(in_format='coco',
       images='path/to/images',
       out_dir='path/to/output',
       json_file='path/to/annotations.json')

Conversion to Pascal VOC Format

To convert from COCO or YOLO format to Pascal VOC format, use the to_voc() function.

For COCO to VOC:

import VisualFlow as vf

vf.to_voc(in_format='coco',
       images='path/to/images',
       out_dir='path/to/output',
       json_file='path/to/annotations.json')

For YOLO to VOC:

import VisualFlow as vf

vf.to_voc(in_format='yolo',
       images='path/to/images',
       annotations='path/to/annotations',
       class_file='path/to/classes.txt',
       out_dir='path/to/output')

Conversion to COCO Format

To convert from PASCAL VOC or YOLO format to COCO format, use the to_coco() function.

For VOC to COCO:

import VisualFlow as vf

vf.to_coco(in_format='voc',
       images='path/to/images',
       annotations='path/to/annotations',
       class_file='path/to/classes.txt',
       output_file_path='path/to/output.json')

For YOLO to COCO:

import VisualFlow as vf

vf.to_coco(in_format='yolo',
       images='path/to/images',
       annotations='path/to/annotations',
       class_file='path/to/classes.txt',
       output_file_path='path/to/output.json')

Make sure to replace 'path/to/images', 'path/to/annotations', 'path/to/classes.txt', and 'path/to/output' with the actual paths to your dataset files and folders.

Augmentations

VisualFlow's powerful data augmentations can enhance your object detection training data. Easily apply these transformations to your dataset with just a few lines of code:

  • Cutout: Create up to three random cutouts to encourage robustness and generalization in your models.
  • Grayscale: Convert images to grayscale, adding diversity to your training data.
  • Brightness: Adjust the brightness of your images, ensuring your models can handle varying lighting conditions.
  • Noise: Introduce noise to diversify your dataset and improve model resilience.
  • Blur: Apply blurring to images, simulating real-world scenarios and enhancing model adaptability.
  • Hue: Adjust the hue of images, enriching color variations and augmenting the dataset.
  • Exposure: Manipulate exposure levels to help models cope with different lighting environments.
  • Flip90: Perform 90-degree flips for data variation and better model generalization.
  • Shear: Apply shear transformations on bounding boxes to augment your dataset and improve model robustness.
  • Rotate: Rotate bounding boxes by a specified angle to create diverse training examples.

Some examples are available below

import VisualFlow as vf

vf.cutout(image_dir='path/to/images', 
          labels_dir='path/to/labels', # optional
          output_dir='path/to/output', 
          max_num_cutouts=3) # optional, set by default

vf.grayscale(image_dir='path/to/images', 
             labels_dir='path/to/labels', # optional
             output_dir='path/to/output')

vf.brightness(image_dir='path/to/images', 
              labels_dir='path/to/labels', # optional
              output_dir='path/to/output', 
              factor=1.5) # optional, set by default

vf.noise(image_dir='path/to/images', 
         labels_dir='path/to/labels', #optional
         output_dir='path/to/output')

vf.blur(image_dir='path/to/images', 
        labels_dir='path/to/labels', # optional
        output_dir='path/to/output')

vf.hue(image_dir='path/to/images', 
       labels_dir='path/to/labels', # optional
       output_dir='path/to/output')

vf.exposure(image_dir='path/to/images', 
            labels_dir='path/to/labels', # optional
            output_dir='path/to/output', 
            factor=2.0) # optional, set by default

vf.flip90(image_dir='path/to/images', 
          labels_dir='path/to/labels', 
          output_dir='path/to/output')

vf.shear(image_dir='path/to/images', 
         labels_dir='path/to/labels', 
         output_dir='path/to/output', 
         shear_factor= 0.2) # optional, set by default

vf.rotate(image_dir='path/to/images', 
          labels_dir='path/to/labels', 
          output_dir='path/to/output', angle=30) # optional, set by default

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

VisualFlow-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

VisualFlow-0.2.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file VisualFlow-0.2.0.tar.gz.

File metadata

  • Download URL: VisualFlow-0.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for VisualFlow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cdc1213fa935bfc81df99a9596ee0c088f5f8f9f95566f8f8d0f16ff16919a9e
MD5 964da838c2db7e53ce8808243ee9c84b
BLAKE2b-256 75d5ab5b1d757faf5206d589b12bac19acc0ff35ab4505691d621ada25958261

See more details on using hashes here.

File details

Details for the file VisualFlow-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: VisualFlow-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for VisualFlow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4085963ce6a3f30823a8e793f647221394bec1e7c19d1e19813760025072745c
MD5 809bae49e9700aabcea7ec5d8b74ebe7
BLAKE2b-256 002045fbcc283a13d6251b7c1a3305c0a2e901dd21d7bb7dd550ac4db3694cf3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page