Skip to main content

ModeYOLO is a versatile Python package designed for efficient color space transformations and simplified dataset modification for deep learning applications. Seamlessly integrating into your workflow, this package empowers users to effortlessly perform diverse color operations and streamline the creation of modified datasets, enhancing the flexibility and convenience of machine learning model training processes.

Project description

ModeYOLO Python Package

Introduction

ModeYOLO is a Python package designed to perform color space transformations on images and facilitate the creation of modified datasets for training deep learning models. The package consists of two main modules: ColorOperation.py and Operation.py.

Folder Structure

Before using the package, ensure that your source dataset follows the following folder structure:

dataset/
|-- train/
|   |-- images/
|   |-- labels/
|-- test/
|   |-- images/
|   |-- labels/
|-- val/
|   |-- images/
|   |-- labels/
|-- data.yaml

ColorOperation Module (ColorOperation.py)

Class: colorcng

Constructor

def __init__(self, path: str, mode: str = 'all') -> None:
    """
    Initializes the colorcng object.

    Parameters:
    - path: str, path to the target directory.
    - mode: str, mode of operation ('all', 'rgb', 'bgr', 'gray', 'hsv', 'crcb', 'lab').
    """

Methods

  1. cng_rgb

    def cng_rgb(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Converts the image to RGB color space.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  2. cng_bgr

    def cng_bgr(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Saves the image in BGR color space.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  3. cng_gray

    def cng_gray(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Converts the image to grayscale.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  4. cng_hsv

    def cng_hsv(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Converts the image to HSV color space.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  5. cng_crcb

    def cng_crcb(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Converts the image to YCrCb color space.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  6. cng_lab

    def cng_lab(self, opt: str, img: np.ndarray, idx: int | str = 0) -> None:
        """
        Converts the image to LAB color space.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - img: np.ndarray, input image.
        - idx: int | str, index for the output file name.
        """
    
  7. execute

    def execute(self, opt: str, file: str, idx: int | str = 0) -> None:
        """
        Executes the specified color space transformation.
    
        Parameters:
        - opt: str, operation type ('train', 'test', 'val').
        - file: str, path to the input image.
        - idx: int | str, index for the output file name.
        """
    

Operation Module (Operation.py)

Class: InitOperation

Constructor

def __init__(self, target_directory: str = 'modified_dataset', src_directory: str = 'dataset', mode: str = 'all') -> None:
    """
    Initializes the InitOperation object.

    Parameters:
    - target_directory: str, path to the target directory.
    - src_directory: str, path to the source dataset directory.
    - mode: str, mode of operation ('all', 'rgb', 'bgr', 'gray', 'hsv', 'crcb', 'lab').
    """

Methods

  1. start_train

    def start_train(self) -> None:
        """
        Creates the modified training dataset.
        """
    
  2. start_test

    def start_test(self) -> None:
        """
        Creates the modified testing dataset.
        """
    
  3. start_val

    def start_val(self) -> None:
        """
        Creates the modified validation dataset.
        """
    
  4. reform_dataset

    def reform_dataset(self) -> None:
        """
        Reformats the entire dataset.
        """
    

Example Usage

# Import the InitOperation class
from ModeYOLO.Operation import InitOperation

# Create an InitOperation object
init_op = InitOperation(target_directory='modified_dataset', src_directory='dataset', mode='all')

# Create the modified dataset
init_op.reform_dataset()

This example assumes that the source dataset is structured according to the specified folder structure. Adjust the paths and parameters accordingly based on your dataset structure.

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

modeyolo-0.1.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

modeyolo-0.1.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file modeyolo-0.1.3.tar.gz.

File metadata

  • Download URL: modeyolo-0.1.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.11 Windows/10

File hashes

Hashes for modeyolo-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8d23d55132b4eaf90b5d99df6ffa267eeaa44c5abf56e5fe6a54417fc2e093d9
MD5 369f0764f139f926eb29d9324b2b61d5
BLAKE2b-256 f33dc4cc377bae87bcaf0e05826a481dd6d1ee01c834c4d8e4f7938a1861d7f4

See more details on using hashes here.

File details

Details for the file modeyolo-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: modeyolo-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.11 Windows/10

File hashes

Hashes for modeyolo-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 92fda184c1393c20e19cdf7135ae36048d82b835b6a716f1f41d9321eb20bc2c
MD5 23119d0d5618db335d1eefb139d33631
BLAKE2b-256 7310380f93bef2238e0db70ccd41e4a64dca1162322e3050f07eb7ebbb69c5e6

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