Templates to perform image transformations using the albumentations library.
Project description
Sinapsis Albumentations
Templates for applying image transformations using Albumentations.
🐍 Installation • 🚀 Features • 📚 Usage example • 📙 Documentation • 🔍 License
The Sinapsis albumentations module provides an extensive collection of templates powered by the Albumentations library. These templates allow users to apply a wide range of augmentations, from simple operations like flipping and resizing to more advanced transformations such as elastic distortions and geometric warping.
🐍 Installation
Install using your package manager of choice. We encourage the use of uv
Example with uv:
uv pip install sinapsis-albumentations --extra-index-url https://pypi.sinapsis.tech
or with raw pip:
pip install sinapsis-albumentations --extra-index-url https://pypi.sinapsis.tech
🚀 Features
Templates Supported
[!TIP] Use CLI command
sinapsis info --all-template-namesto show a list with all the available templates installed with thesinapsis-albumentationspackage.
🌍 General Attributes
[!NOTE] All templates share the following attributes:
apply_to_annotations(bool, optional): Determines whether transformations should also be applied to annotations like bounding boxes, keypoints, and masks. Defaults toFalse.bbox_params(dict[str, Any], optional): Configuration for transforming bounding boxes, following Albumentations'BboxParamsformat. Defaults toNone.keypoints_params(dict[str, Any], optional): Defines keypoint transformation settings using Albumentations'KeypointParams. Defaults toNone.additional_targets(dict[str, Any], optional): Specifies extra annotation types (e.g., segmentation masks) to be transformed alongside the image. Defaults to{"mask": "mask"}.Additional transformation-specific attributes can be dynamically assigned through the class initialization dictionary (
*_initattributes). These attributes correspond directly to the arguments used in Albumentations.
[!TIP] Use CLI command
sinapsis info --example-template-config TEMPLATE_NAMEto produce an example Agent config for the Template specified in TEMPLATE_NAME.For example, for RotateWrapper use
sinapsis info --example-template-config RotateWrapperto produce the following example config:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
- template_name: RotateWrapper
class_name: RotateWrapper
template_input: InputTemplate
attributes:
apply_to_annotations: false
bbox_params: null
keypoints_params: null
additional_targets:
mask: mask
rotate_init:
limit: [-45, 45]
interpolation: 1
border_mode: 4
value: [0, 0, 0]
mask_value: null
rotate_method: "largest_box"
crop_border: false
fill_value: 0
mask_fill_value: 0
deterministic: true
p: 1.0
📚 Usage example
The following example demonstrates how to use Sinapsis Albumentations to apply multiple image augmentations. This setup loads a dataset of images, applies horizontal flipping and elastic transformation, and saves the results. Below is the full YAML configuration, followed by a breakdown of each component.
Example configuration
agent:
name: transforms_agent
description: "Agent to apply an horizontal-flip and an elastic-transformation to a set of images loaded from a directory."
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: FolderImageDatasetCV2
class_name: FolderImageDatasetCV2
template_input: InputTemplate
attributes:
data_dir: my_dataset
- template_name: HorizontalFlip
class_name: HorizontalFlipWrapper
template_input: FolderImageDatasetCV2
attributes:
horizontalflip_init:
p: 1.0
- template_name: ElasticTransform
class_name: ElasticTransformWrapper
template_input: HorizontalFlip
attributes:
elastictransform_init:
mask_value: 150
p: 1.0
alpha: 100
sigma: 50
- template_name: ImageSaver
class_name: ImageSaver
template_input: ElasticTransform
attributes:
save_dir: results
extension: jpg
This configuration defines an agent and a sequence of templates to apply image transformations.
[!NOTE] Attributes specified under the
*_initkeys (e.g.,elastictransform_init,horizontalflip_init) correspond directly to the Albumentations transformation parameters. Ensure that values are assigned correctly according to the official Albumentations documentation, as they affect the behavior and performance of each transformation.
[!IMPORTANT] The FolderImageDataserCV2 and ImageSaver correspond to sinapsis-data-readers and sinapsis-data-writers. If you want to use the example, please make sure you install the packages.
To run the config, use the CLI:
sinapsis run name_of_config.yml
📙 Documentation
Documentation for this and other sinapsis packages is available on the sinapsis website
Tutorials for different projects within sinapsis are available at sinapsis tutorials page
🔍 License
This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.
For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sinapsis_albumentations-0.1.0.tar.gz.
File metadata
- Download URL: sinapsis_albumentations-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d639bab0252d09c25cdefe78ccb058cea007b224aa60f0762caefebfa91cc731
|
|
| MD5 |
bef928aa49c298128f41469a7e74024c
|
|
| BLAKE2b-256 |
3314acde884be9d8496962177c185b5ea1901baba18541fd21e76caea77c26c4
|
File details
Details for the file sinapsis_albumentations-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sinapsis_albumentations-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b01a7fba11b600982fa7854cfd2402b66dc5a81ecd7106e296caf70413124cb
|
|
| MD5 |
0a8ae553467ed201639752baceb28541
|
|
| BLAKE2b-256 |
09a742b861c037ad1b2e27d9214d9a591d2a3d4093439aee590dccc2a97137ad
|