LLM-powered data augmentation policy designer with domain-safe, task-aware policies
Project description
AugmentAI ๐จ
LLM-Powered Data Augmentation Policy Designer
Design domain-safe, task-aware augmentation policies through natural language conversation. No more manual hyperparameter tuningโjust describe your dataset and constraints, and get scientifically sound augmentation pipelines.
Design Philosophy: The LLM suggests. Rules decide. Code executes.
๐ Features
- One-Command Preparation:
augmentai prepare ./dataset- inspect, split, augment, export - ๐ AutoSearch:
augmentai search ./dataset- find optimal policies automatically - Natural Language Interface: Describe your dataset in plain English
- Domain-Aware Constraints: Built-in rules for medical, OCR, satellite, and natural images
- Safety-First Design: Hard constraints that prevent scientifically invalid augmentations
- Full Reproducibility: Seed locking, manifest tracking, deterministic pipelines
- LLM as Advisor: OpenAI, Gemini, Ollama, or LM StudioโLLM suggests, rules validate
- Executable Output: Generate standalone Python scripts ready to run
- Verbose/Quiet Modes:
--verbosefor debugging,--quietfor CI/CD pipelines
๐ Quick Start
Installation
# Install from PyPI
pip install augmentai
# Or install from source
git clone https://github.com/kyrozepto/augmentai.git
cd augmentai && pip install -e .
Set up your LLM provider
# Option 1: Environment variables (recommended)
export OPENAI_API_KEY="your-api-key" # For OpenAI
export GOOGLE_API_KEY="your-api-key" # For Gemini (from aistudio.google.com)
# Option 2: Pass directly via CLI
augmentai chat --provider gemini --api-key "your-key"
augmentai chat --provider openai --api-key "your-key"
# Option 3: Use Ollama (free, local)
ollama pull llama3.2
augmentai chat --provider ollama
Supported LLM Providers:
| Provider | Models | API Key Env Var |
|---|---|---|
openai |
gpt-4o-mini, gpt-4o | OPENAI_API_KEY |
gemini |
gemini-2.0-flash, gemini-1.5-pro | GOOGLE_API_KEY |
ollama |
llama3.2, mistral, etc. | (none needed) |
lmstudio |
local models | (none needed) |
One-Command Dataset Preparation
# Prepare dataset with auto-detected domain
augmentai prepare ./dataset
# Medical domain with custom split
augmentai prepare ./lung_ct --domain medical --split 70/15/15
# Preview what would happen (dry run)
augmentai prepare ./images --dry-run
Interactive Policy Design
# Start interactive chat
augmentai chat --domain medical
# List available domains
augmentai domains
# Validate an existing policy
augmentai validate my_policy.yaml --domain medical
๐ AutoSearch: Find Optimal Policies Automatically
# Search for best policy (uses evolutionary optimization)
augmentai search ./dataset --domain medical --budget 50
# With custom output directory
augmentai search ./images --budget 100 --output ./search_results
# Preview search configuration
augmentai search ./data --dry-run
AutoSearch uses proxy metrics (diversity, coverage, strength, balance) to score policies without requiring full model training.
๏ฟฝ Output Structure
Running augmentai prepare generates:
prepared/
โโโ data/
โ โโโ train/ # Training split
โ โโโ val/ # Validation split
โ โโโ test/ # Test split
โโโ augmented/ # Output for augmented data
โโโ augment.py # Standalone augmentation script
โโโ config.yaml # Pipeline configuration
โโโ manifest.json # Reproducibility manifest
โโโ requirements.txt # Dependencies
โโโ README.md # Usage instructions
๐ฏ Real-World Examples
๐ฅ Medical: Dental Panoramic X-Ray
augmentai prepare "C:\Users\you\datasets\panoramic-xray" --domain medical --split 70/15/15
# Output:
# โ Detected: 1,247 images across 4 classes (cavity, healthy, fracture, caries)
# โ Split: 873 train, 187 val, 187 test
# โ Policy: Conservative augmentations preserving dental anatomy
# โ Forbidden: ElasticTransform, ColorJitter (would distort teeth/bone structure)
๐ฐ๏ธ Satellite: Land Use Classification
augmentai prepare ./sentinel2_tiles --domain satellite --seed 42
# Multi-spectral imagery gets special treatment:
# โ Allowed: Rotation (any angle), flips, scale
# โ Forbidden: ColorJitter, HSV, ChannelShuffle (breaks spectral bands!)
๐ OCR: Document Scanning
augmentai prepare ./scanned_receipts --domain ocr
# Text legibility is preserved:
# โ Allowed: Slight rotation (ยฑ5ยฐ), brightness adjustment
# โ Forbidden: MotionBlur, ElasticTransform (destroys text)
๐ผ๏ธ Natural: Instagram-style Photos
augmentai prepare ./pet_photos --domain natural
# Maximum flexibility for general images:
# โ Allowed: Everything! Color jitter, elastic, cutout, mixup
# โ Strong augmentations for robust models
๐ฌ Research: Reproducible Experiments
# Exact same augmentations every time
augmentai prepare ./experiment_data --seed 12345 --output ./exp_v1
# Later, reproduce with the manifest
cat ./exp_v1/manifest.json
# {
# "seed": 12345,
# "dataset_hash": "a1b2c3d4...",
# "policy_hash": "e5f6g7h8...",
# "augmentai_version": "0.1.0"
# }
๐ญ Production: Batch Processing
# Prepare multiple datasets with consistent settings
for dataset in chest_xray brain_mri skin_lesion; do
augmentai prepare ./raw/$dataset --domain medical --output ./prepared/$dataset
done
๐ป Python API: Full Control
from augmentai.core import Policy, Transform
from augmentai.domains import get_domain
from augmentai.rules.enforcement import RuleEnforcer
from augmentai.export import ScriptGenerator
# Create custom policy
policy = Policy(
name="dental_xray_v2",
domain="medical",
transforms=[
Transform("HorizontalFlip", 0.5),
Transform("Rotate", 0.7, parameters={"limit": 20}),
Transform("CLAHE", 0.4, parameters={"clip_limit": 2.0}),
Transform("GaussNoise", 0.3, parameters={"var_limit": (10, 30)}),
Transform("RandomBrightnessContrast", 0.5),
]
)
# Validate against medical rules
enforcer = RuleEnforcer(get_domain("medical"))
result = enforcer.enforce_policy(policy)
print(f"Safe transforms: {len(result.policy.transforms)}")
# Generate standalone script
generator = ScriptGenerator()
script = generator.generate_augment_script(result.policy, seed=42)
with open("my_augment.py", "w") as f:
f.write(script)
๐ Modifying Generated Config
After running augmentai prepare, edit config.yaml:
# config.yaml - tweak as needed!
policy:
name: dental_xray_policy
domain: medical
seed: 42
transforms:
- name: HorizontalFlip
probability: 0.5 # โ Increase to 0.7?
- name: Rotate
probability: 0.5
parameters:
limit: 15 # โ Bump to 25 for more variety
- name: CLAHE # โ Add new transforms!
probability: 0.4
parameters:
clip_limit: 2.0
Then re-run the generated script:
python augment.py --input data/train --output augmented/train --seed 42
๐ Interactive Learning Session
$ augmentai chat --domain medical
You: I have dental panoramic x-rays with cavity annotations. What augmentations
are safe? I'm worried about distorting the teeth.
๐ค AugmentAI: Great concern! For dental x-rays, I recommend:
โ
Safe for dental imaging:
โข HorizontalFlip (p=0.5) - Teeth are roughly symmetric
โข Rotate (p=0.5, limit=ยฑ10ยฐ) - Small rotations are realistic
โข CLAHE (p=0.3) - Enhances contrast in x-rays
โข GaussNoise (p=0.2) - Simulates sensor noise
โ ๏ธ Automatically blocked:
โข ElasticTransform - Would warp tooth boundaries unrealistically
โข GridDistortion - Same issue, breaks tooth geometry
โข ColorJitter - X-rays are grayscale, color transforms invalid
You: Can I increase rotation to 30 degrees?
๐ค AugmentAI: I'd advise caution. Dental panoramic x-rays are typically taken
with the patient positioned consistently. Rotations beyond ยฑ15ยฐ might create
unrealistic training samples. However, if your dataset has varied positioning,
ยฑ20ยฐ could work. I'll set it to 20ยฐ as a compromise.
/preview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ Transform โ Probability โ Parameters โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ HorizontalFlip โ 50% โ - โ
โ Rotate โ 50% โ limit=20 โ
โ CLAHE โ 30% โ clip_limit=2.0 โ
โ GaussNoise โ 20% โ var_limit=(5, 25) โ
โ RandomBrightnessContrast โ 30% โ brightness_limit=0.1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโ
/export dental_cavity_policy.py
โ Exported to dental_cavity_policy.py
๐ฅ Domain Safety
AugmentAI enforces hard constraints that cannot be overridden:
| Domain | Forbidden Transforms | Reason |
|---|---|---|
| Medical | ElasticTransform, GridDistortion, ColorJitter | Breaks anatomy, invalid for grayscale |
| OCR | MotionBlur, ElasticTransform | Destroys text legibility |
| Satellite | ColorJitter, HSV, ChannelShuffle | Breaks spectral band relationships |
๐ Project Structure
augmentai/
โโโ cli/ # CLI commands (prepare, chat, validate, search)
โโโ core/ # Policy, Transform, Manifest, Pipeline
โโโ domains/ # Domain rules (medical, ocr, satellite, natural)
โโโ inspection/ # Dataset auto-detection & analysis
โโโ splitting/ # Train/val/test splitting strategies
โโโ export/ # Script & folder generation
โโโ llm/ # LLM client and prompts
โโโ rules/ # Safety validation & enforcement
โโโ compilers/ # Backend code generation
โโโ search/ # ๐ AutoSearch: evolutionary policy optimization
โโโ utils/ # ๐ Progress bars, logging utilities
โโโ exceptions.py # ๐ Custom error hierarchy
๐ง Configuration
Create augmentai.yaml in your project:
llm:
provider: openai # or ollama, lmstudio
model: gpt-4o-mini
temperature: 0.7
backend: albumentations
output_dir: ./policies
๐ฏ Custom Domains
Define your own domain constraints in YAML:
# my_domain.yaml
name: my_custom_domain
description: Custom constraints for my task
constraints:
- transform_name: ElasticTransform
level: forbidden
reason: Not suitable for my task
- transform_name: Rotate
level: recommended
reason: Good for rotation invariance
parameter_limits:
limit: [-30, 30]
recommended_transforms:
- HorizontalFlip
- RandomBrightnessContrast
Load with:
augmentai chat --domain-file my_domain.yaml
๐ค Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
๐ License
MIT License - see LICENSE for details.
๐ Acknowledgments
- Albumentations for the augmentation backend
- Rich for beautiful terminal UI
- OpenAI, Ollama, LM Studio for LLM support
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 augmentai-0.1.1.tar.gz.
File metadata
- Download URL: augmentai-0.1.1.tar.gz
- Upload date:
- Size: 142.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e96ec86c0e6b51cd8e2ff4fed86c22309326556a26b89236a6efafbc99be8f6
|
|
| MD5 |
d6c1952b45d00b628c961441328e2210
|
|
| BLAKE2b-256 |
fd233d13e8fbb04768ca5e83139136394b94835c6b6da02be2bab0e7ce970d55
|
File details
Details for the file augmentai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: augmentai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 152.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd34c1bffceeb90096b3cd0dcc338cf4e8599723f4b89de0a42ca5a94554504a
|
|
| MD5 |
597303f9eb0741a8bb12eedace7c45f7
|
|
| BLAKE2b-256 |
09ffae38287dd822d7cb6d68c80fef86567ef84404fc39a71c5d1a03ab2c8ff4
|