Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.
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.
ModeYOLO depends on the following libraries:
ultralytics
)torch
)os
)cv2
)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.py
)colorcng
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).
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').
"""
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.
"""
DatasetModifier.py
)InitModifier
def __init__(self, target_directory: str = 'modified_dataset', src_directory: str = 'dataset', mode: str = 'all') -> None:
"""
Initializes the InitModifier 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').
"""
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.
"""
# Import the InitModifier class
from ModeYOLO.DatasetModifier import InitModifier
# Create an InitModifier object
init_op = InitModifier(target_directory='modified_dataset', src_directory='dataset', mode='all')
# Create the modified dataset
init_op.reform_dataset()
ModelTrain.py
)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.
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 modelChoose a model based on your specific requirements and follow the on-screen instructions during training for optimal results.
# 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.
This project is licensed under the MIT License - see the LICENSE file for details.
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.
FAQs
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.
We found that modeyolo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.