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 versatile Python package designed for efficient color space transformations, dataset modification, and YOLO model training. It seamlessly integrates into your workflow, providing solutions for diverse machine learning applications in computer vision.
Dependencies
ModeYOLO depends on the following libraries:
- Ultralytics (
ultralytics
) - PyTorch (
torch
) - os (
os
) - opencv-python (
cv2
)
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
Color Spaces:
Currently we accepting this ['RGB', 'BGR', 'GRAY', 'CrCb', 'LAB', 'HSV']
Color Spaces. Each element in the list corresponds to a specific color space. Here's an explanation of each color space:
-
RGB (Red, Green, Blue): The standard color model used in most digital cameras and displays, where each pixel is represented by three values indicating the intensity of red, green, and blue.
-
BGR (Blue, Green, Red): Similar to RGB but with the order of color channels reversed. OpenCV, a popular computer vision library, uses BGR as its default color order.
-
GRAY (Grayscale): A single-channel color space where each pixel is represented by a single intensity value, typically ranging from black to white.
-
CrCb: A component of the YCbCr color space often used in image and video compression. It separates chrominance (color information) from luminance (brightness information).
-
LAB: The LAB color space represents colors independently of device-specific characteristics. It consists of three components: L* (luminance), a* (green to red), and b* (blue to yellow).
-
HSV (Hue, Saturation, Value): A color space that separates color information into three components: hue (the type of color), saturation (the intensity or vividness of the color), and value (brightness).
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
-
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. """
-
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. """
-
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. """
-
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. """
-
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. """
-
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. """
-
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
-
start_train
def start_train(self) -> None: """ Creates the modified training dataset. """
-
start_test
def start_test(self) -> None: """ Creates the modified testing dataset. """
-
start_val
def start_val(self) -> None: """ Creates the modified validation dataset. """
-
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()
Certainly! Below is an updated README.md file reflecting the newly added trainYOLO
submodule. The readme includes information about the new submodule, its purpose, and usage.
ModelTrain Module (ModelTrain.py
)
Class: trainYOLO
This submodule facilitates YOLO model training with various pre-trained models. Users can choose from a selection of YOLO models, specify training parameters, and seamlessly integrate it into their workflows.
Pre-trained Models
The trainYOLO
submodule supports training with various pre-trained YOLO models. Choose a model by entering the corresponding index when prompted. Here are the available models:
yolov3u.pt
: YOLOv3 with upsamplingyolov5nu.pt
: YOLOv5 with narrow channelsyolov5su.pt
: YOLOv5 with small modelyolov5mu.pt
: YOLOv5 with medium modelyolov5lu.pt
: YOLOv5 with large modelyolov5xu.pt
: YOLOv5 with extra-large modelyolov5n6u.pt
: YOLOv5 with narrow channels and 6x sizeyolov5s6u.pt
: YOLOv5 with small model and 6x sizeyolov5m6u.pt
: YOLOv5 with medium model and 6x sizeyolov5l6u.pt
: YOLOv5 with large model and 6x sizeyolov5x6u.pt
: YOLOv5 with extra-large model and 6x sizeyolov6n.pt
: YOLOv6 with narrow channelsyolov6s.pt
: YOLOv6 with small modelyolov6m.pt
: YOLOv6 with medium modelyolov6l.pt
: YOLOv6 with large modelyolov6l6.pt
: YOLOv6 with large model and 6x sizeyolov8n.pt
: YOLOv8 with narrow channelsyolov8s.pt
: YOLOv8 with small modelyolov8m.pt
: YOLOv8 with medium modelyolov8l.pt
: YOLOv8 with large modelyolov8x.pt
: YOLOv8 with extra-large modelyolov9s.pt
: YOLOv9 with small modelyolov9m.pt
: YOLOv9 with medium modelyolov9c.pt
: YOLOv9 with complex modelyolov9e.pt
: YOLOv9 with extra-large model
Choose a model based on your specific requirements and follow the on-screen instructions during training for optimal results.
Example Usage
# Import the trainYOLO class
from ModeYOLO.ModelTrain import trainYOLO
# Create a trainYOLO object
yolo_trainer = trainYOLO(target_directory='modified_dataset', src_directory='dataset', mode='all', data_path='./modified_dataset/data.yaml', epochs=1, imgsz=224)
# Train the YOLO model
yolo_trainer.train()
# Validate the trained model
yolo_trainer.val()
Note: Follow the on-screen instructions to choose a YOLO model for training.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
-
Mention any contributors or external libraries that inspired or helped with the development of ModeYOLO.
-
Feel free to adjust the content as needed and let me know if you have further requirements!
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file modeyolo-0.2.1.tar.gz
.
File metadata
- Download URL: modeyolo-0.2.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42d26139f19e33df9914fba75740724980019e3a9c9932ef5f2a1dac1d68c348 |
|
MD5 | a67bd8a8cbee52415718098780dee98c |
|
BLAKE2b-256 | 5e66467e270a3a80e95e19c5d28eeaa26fd60ee1405697e9f38931a2d0683d74 |
File details
Details for the file modeyolo-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: modeyolo-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af2a653affddc3dec97f077f134d7f0abb7ebe96a41a8fdcb4a958b997ce16b3 |
|
MD5 | 8b09b7da0e29a37173cf829a9140b3a0 |
|
BLAKE2b-256 | eec8f1eaecebbb94abfde71f7f6d03d3526b88f7e3f63d4a3a9205262056d444 |