Metadata-Version: 2.4
Name: twat-genai
Version: 2.6.2
Project-URL: Documentation, https://github.com/twardoch/twat-genai#readme
Project-URL: Issues, https://github.com/twardoch/twat-genai/issues
Project-URL: Source, https://github.com/twardoch/twat-genai
Author-email: Adam Twardoch <adam+github@twardoch.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.10
Requires-Dist: fal-client>=0.5.9
Requires-Dist: httpx>=0.28.1
Requires-Dist: numpy>=2.2.3
Requires-Dist: pillow>=11.1.0
Requires-Dist: pydantic>=2.10.6
Requires-Dist: python-slugify>=8.0.4
Requires-Dist: twat-image>=1.8.1
Requires-Dist: twat>=1.8.1
Requires-Dist: webcolors>=24.11.1
Provides-Extra: all
Requires-Dist: fal-client>=0.5.9; extra == 'all'
Requires-Dist: httpx>=0.28.1; extra == 'all'
Requires-Dist: numpy>=2.2.3; extra == 'all'
Requires-Dist: pillow>=11.1.0; extra == 'all'
Requires-Dist: pydantic>=2.10.6; extra == 'all'
Requires-Dist: python-slugify>=8.0.4; extra == 'all'
Requires-Dist: twat-image>=1.8.1; extra == 'all'
Requires-Dist: twat>=1.8.1; extra == 'all'
Requires-Dist: webcolors>=24.11.1; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.15.0; extra == 'dev'
Requires-Dist: pre-commit>=4.1.0; extra == 'dev'
Requires-Dist: ruff>=0.9.6; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-benchmark[histogram]>=5.1.0; extra == 'test'
Requires-Dist: pytest-cov>=6.0.0; extra == 'test'
Requires-Dist: pytest-xdist>=3.6.1; extra == 'test'
Requires-Dist: pytest>=8.3.4; extra == 'test'
Description-Content-Type: text/markdown

# twat-genai

(work in progress)

Image generation package that leverages fal.ai's models for AI image generation. Provides a flexible command-line interface and Python API for generating images using various AI models and techniques.

## Features

- Multiple AI image generation modes:
  - Text-to-image generation
  - Image-to-image transformation
  - Canny edge-guided generation
  - Depth-guided generation
- Support for LoRA (Low-Rank Adaptation) models with a built-in library of style presets
- Flexible prompt expansion with alternatives using brace syntax
- Concurrent image generation for multiple prompts
- Comprehensive metadata storage for generated images
- Modern Python packaging with PEP 621 compliance
- Type hints and runtime type checking
- Comprehensive test suite and documentation
- CI/CD ready configuration

## Installation

```bash
pip install twat-genai
```


## Usage

### Command Line Interface

```bash
## Basic text-to-image generation
python -m twat_genai "a beautiful sunset" --output_dir images
## Using a specific style from the LoRA library
python -m twat_genai "a beautiful sunset" --lora "shou_xin"
## Image-to-image transformation
python -m twat_genai "enhance this photo" --model image --input_image input.jpg
## Multiple prompts with alternatives
python -m twat_genai "a {red; blue; green} house with {white; black} windows"
```

### Python API

```python
import twat_genai
from twat_genai.main import async_main, ModelTypes

## Generate images asynchronously
results = await async_main(
prompts="a beautiful sunset",
output_dir="generated_images",
model=ModelTypes.TEXT,
lora="shou_xin",
image_size="SQ"
)   
```


## Key Features in Detail

### Prompt Expansion
The tool supports flexible prompt expansion using brace syntax:
- `"a {red; blue} house"` generates two images: "a red house" and "a blue house"
- Nested alternatives are supported
- Semicolons separate alternatives

### LoRA Styles
Built-in library of LoRA styles for different artistic effects:
- Gesture drawing
- Sketch and smudge effects
- 2-color illustrations
- Pencil sketches
- Tarot card style
- And more...

### Image Generation Modes
- **Text-to-Image**: Generate images from text descriptions
- **Image-to-Image**: Transform existing images
- **Canny Edge**: Use edge detection to guide generation
- **Depth-Guided**: Use depth information for generation

### Output Management
- Automatic file naming with customizable prefixes/suffixes
- Metadata storage in JSON format
- Various image size options (square, landscape, portrait)
- Support for custom dimensions

## Development

This project uses [Hatch](https://hatch.pypa.io/) for development workflow management.

### Setup Development Environment

```bash
## Install hatch if you haven't already
pip install hatch
## Create and activate development environment
hatch shell
## Run tests
hatch run test
## Run tests with coverage
hatch run test-cov
## Run linting
hatch run lint
## Format code
hatch run format
```

## License

MIT License  
.
