Skip to main content

A Python library for generating realistic synthetic images to train segmentation models in a smart, simple way.

Project description

transforms_fake

A Python library for generating realistic synthetic images to train segmentation models in a smart, simple way.

PyPI version License Status

Overview

transforms_fake automatically generates new labeled images and masks from existing annotated datasets. Unlike traditional augmentation libraries, which only transform existing data, this library creates entirely new training examples by intelligently extracting and repositioning objects with their corresponding masks.

Key innovation: context-aware object insertion that maintains a realistic appearance while expanding the diversity of the dataset.

Features

  • Instance-aware copy and paste: extract objects using segmentation masks
  • Contextual transformations: rotation, scaling, and inversion with mask preservation
  • Insertion between images: place objects from one image into different backgrounds
  • Automatic mask updates: maintains segmentation labels with pixel-perfect accuracy
  • Framework integration: compatible with PyTorch and FastAI workflows
  • Dataset export: generate ready-to-use training datasets

Installation

pip install transforms_fake

For the latest development version:

pip install git+https://github.com/THOTIACORP/transforms_fake.git

Quick start

GUI

from transforms_fake.main import main

# Basic usage
main()

Code

from transforms_fake.main import process_images



class FakeLogWidget:
    def __init__(self):
        self.logs = []

    def append(self, text):
        self.logs.append(text)

    def repaint(self):
        pass  # Não faz nada, só para evitar erro

    def __str__(self):
        return "\n".join(self.logs)

# Uso:
log_widget = FakeLogWidget()
# Basic usage
img_dir = './img'
mask_dir = './mask'
output_dir = './output'
num_fundos = 50
num_ratos_por_fundo = 100

process_images(img_dir, mask_dir, output_dir, num_fundos, num_ratos_por_fundo, log_widget)

print("Logs:")
print(log_widget)

Dataset structure

Organize your data as follows:

dataset/
├── images/
│   ├── image1.png
│   └── image2.png
└── masks/
    ├── image1_mask.png
    └── image2_mask.png

How it works

  1. Input processing: Loads images with corresponding segmentation masks
  2. Instance detection: Identifies individual objects within the masks
  3. Object extraction: Isolates objects using the mask boundaries
  4. Contextual placement: Inserts objects into new locations with transformations
  5. Mask synchronization: Updates the segmentation masks to match the new object positions

Comparison with existing tools

vs. Albumentations

Feature Albumentations transforms_fake
Traditional augmentation
Synthetic instance generation
Individual object manipulation
Copy and paste with mask recognition

vs. Other augmentation tools

  • Traditional libraries modify existing pixels
  • transforms_fake creates new object arrangements while preserving realism
  • Designed specifically for segmentation tasks that require diversity at the instance level

Use cases

  • Medical images: augment rare cases of pathologies
  • Object detection: augment variations in object occurrence
  • Segmentation: generate diverse object arrangements
  • Small datasets: multiply training examples contextually

Requirements

  • Python 3.7+
  • PIL/Pillow for image processing
  • NumPy for matrix operations
  • Compatible with PyTorch and FastAI

Contributions

Contributions are welcome! Please:

  1. Fork the repository
  2. Create feature branches
  3. Submit pull requests with clear descriptions
  4. Report bugs via issues on GitHub

License

GNU General Public License v3.0 - See LICENSE for details.

Contact

THOTIACORP

Authors

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

transforms_fake-0.1.4.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transforms_fake-0.1.4-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file transforms_fake-0.1.4.tar.gz.

File metadata

  • Download URL: transforms_fake-0.1.4.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for transforms_fake-0.1.4.tar.gz
Algorithm Hash digest
SHA256 16b2814c461c09dc3d10e0cf77e441c002fa5ae2925f0db59da8cc9cc6c6e894
MD5 c596ec79821bb49907fa1e19468fdbea
BLAKE2b-256 8711971902633c0ef5d2bf55a9edd0a0035098d25880e46e14b07076b5ddd0e4

See more details on using hashes here.

File details

Details for the file transforms_fake-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for transforms_fake-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0641923d020061a9b731098a41d24fe15d137a3c59b9aea196fc0e220b52a8
MD5 718faa0c91c06d12436fdf65fd16d71d
BLAKE2b-256 17999b0b677755b189b5c862cf48a08476039146474efc1dfa2ec7705527736f

See more details on using hashes here.

Supported by

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