Skip to main content

No project description provided

Project description

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

pip install twat-genai

Usage

Command Line Interface

## 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

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 for development workflow management.

Setup Development Environment

## 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

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

twat_genai-1.6.1.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

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

twat_genai-1.6.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file twat_genai-1.6.1.tar.gz.

File metadata

  • Download URL: twat_genai-1.6.1.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for twat_genai-1.6.1.tar.gz
Algorithm Hash digest
SHA256 5eae2eb48f33f31ee03c6367c56bd82f9b915ae6e31b8b1765ef30c9f0fe29e0
MD5 187ee3e5918f4ed2bbb04c2c2e0c8c9e
BLAKE2b-256 13751d205e3afb3acc4ec470a80ef4366a53be03ed01ce10eff9edca7c905fde

See more details on using hashes here.

File details

Details for the file twat_genai-1.6.1-py3-none-any.whl.

File metadata

  • Download URL: twat_genai-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for twat_genai-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebcfd81a4da2ca0f6ff5b97fa6b3f277a1de22d217d2fd4321dd1011cd921028
MD5 fb439525b8c6379152022fc15af9e1cf
BLAKE2b-256 e66e2c59ee6b8421b2dbd896e88560b6b23a3f55f8d4fc6a7e2d8d7eae88ff56

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