Skip to content

worldofunreal/runware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Art Automation System

A powerful, automated AI art generation system using the Runware API. Generate high-quality images automatically with various models, styles, and scheduling options.

πŸš€ Features

  • Multiple Generation Modes: Single image, batch processing, template-based, and style variations
  • Automated Scheduling: Set up recurring generation jobs with customizable intervals
  • Multiple Models: Support for various AI models including FLUX, Stable Diffusion, and custom CivitAI models
  • Style Variations: Generate the same prompt in different artistic styles
  • Template System: Pre-built templates for portraits, landscapes, fantasy, cyberpunk, and abstract art
  • Concurrent Processing: Generate multiple images simultaneously for better performance
  • Local Storage: Automatically download and organize generated images
  • Metadata Tracking: Keep detailed records of all generations
  • CLI Interface: Easy-to-use command-line interface
  • Configuration Management: Flexible configuration via environment variables and JSON files

πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • Runware API key (get one at my.runware.ai)
  • Internet connection for API access

πŸ› οΈ Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd runware
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up your API key:

    cp config.env.example .env

    Edit .env and add your Runware API key:

    RUNWARE_API_KEY=your_api_key_here

🎨 Quick Start

Basic Usage

  1. Generate a single image:

    python cli.py generate "A futuristic stealth jet streaking through a neon-lit cityscape"
  2. Generate multiple images:

    python cli.py batch --prompts "A serene mountain landscape" "A cyberpunk city street" "A magical forest"
  3. Use templates:

    python cli.py template portrait "a young woman with blue hair" --style anime --count 3
  4. Generate style variations:

    python cli.py styles "A majestic dragon flying over mountains" --styles realistic anime cyberpunk

Advanced Usage

Batch Processing from File

Create a file prompts.txt:

A serene mountain landscape at sunset
A cyberpunk city street at night
A magical forest with glowing mushrooms
A futuristic robot in a laboratory

Then run:

python cli.py batch --file prompts.txt --model runware:97@2

Automated Scheduling

  1. Configure the scheduler:

    python cli.py scheduler config --enabled true --interval-hours 6 --batch-size 2
  2. Start the scheduler:

    python cli.py scheduler start
  3. Check status:

    python cli.py scheduler status

Custom Prompts

Add custom prompts to the pool:

python cli.py add-prompt cyberpunk "A neon-lit street with holographic advertisements"
python cli.py add-prompt fantasy "A magical library with floating books and glowing orbs"

πŸ“š Detailed Usage

Command Line Interface

The CLI provides several commands for different use cases:

generate - Single Image Generation

python cli.py generate "Your prompt here" [options]

Options:

  • --model: Specify the model to use
  • --width, --height: Image dimensions
  • --steps: Number of generation steps
  • --cfg-scale: CFG scale parameter
  • --negative-prompt: Negative prompt for unwanted elements

batch - Batch Image Generation

python cli.py batch --file prompts.txt [options]
# or
python cli.py batch --prompts "prompt1" "prompt2" "prompt3" [options]

Options:

  • --file: File containing prompts (one per line)
  • --prompts: List of prompts directly
  • --sequential: Generate sequentially instead of concurrently
  • All other options from generate command

template - Template-Based Generation

python cli.py template <template_type> <subject> [options]

Template types: portrait, landscape, fantasy, cyberpunk, abstract

Options:

  • --style: Artistic style to apply
  • --location: Location for landscape templates
  • --count: Number of images to generate

styles - Style Variations

python cli.py styles "Base prompt" --styles realistic anime cyberpunk [options]

scheduler - Automated Scheduling

# Configure scheduler
python cli.py scheduler config --enabled true --interval-hours 12 --batch-size 4

# Start scheduler
python cli.py scheduler start

# Check status
python cli.py scheduler status

# Show configuration
python cli.py scheduler config --show

Programmatic Usage

You can also use the system programmatically:

import asyncio
from ai_art_generator import AIArtGenerator

async def main():
    generator = AIArtGenerator()
    await generator.connect()
    
    # Generate a single image
    result = await generator.generate_single_image(
        prompt="A futuristic stealth jet streaking through a neon-lit cityscape",
        model="runware:97@2",
        width=1344,
        height=768
    )
    
    print(f"Generated: {result['local_path']}")
    await generator.disconnect()

asyncio.run(main())

🎯 Available Models

The system includes several pre-configured models:

  • realistic: runware:97@2 - High-quality realistic images
  • anime: civitai:102438@133677 - Anime-style images
  • artistic: runware:101@1 - Artistic and creative styles
  • photorealistic: runware:100@1 - Photorealistic images
  • fantasy: civitai:102438@133677 - Fantasy and imaginative styles
  • cyberpunk: runware:97@2 - Cyberpunk and futuristic styles
  • portrait: runware:100@1 - Portrait-optimized
  • landscape: runware:101@1 - Landscape-optimized

You can also use any CivitAI model by copying its AIR ID and using it directly.

πŸ“ File Structure

runware/
β”œβ”€β”€ ai_art_generator.py      # Main generation engine
β”œβ”€β”€ automated_scheduler.py   # Automated scheduling system
β”œβ”€β”€ cli.py                   # Command-line interface
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ config.env.example       # Environment variables template
β”œβ”€β”€ .env                     # Your API key (create this)
β”œβ”€β”€ generated_images/        # Output directory for images
β”œβ”€β”€ scheduler_config.json    # Scheduler configuration
β”œβ”€β”€ prompt_pool.json         # Custom prompt pool
β”œβ”€β”€ generation_metadata.json # Generation history
└── job_summaries.json       # Scheduler job summaries

βš™οΈ Configuration

Environment Variables

Create a .env file with your configuration:

# Required
RUNWARE_API_KEY=your_api_key_here

# Optional - Generation Settings
DEFAULT_MODEL=runware:97@2
DEFAULT_WIDTH=1024
DEFAULT_HEIGHT=1024
DEFAULT_STEPS=40
DEFAULT_CFG_SCALE=5

# Optional - Output Settings
OUTPUT_DIR=./generated_images
BATCH_SIZE=4

Scheduler Configuration

The scheduler can be configured via the CLI or by editing scheduler_config.json:

{
  "enabled": true,
  "interval_hours": 24,
  "batch_size": 4,
  "models": ["runware:97@2", "runware:101@1"],
  "styles": ["realistic", "artistic", "anime", "cyberpunk"],
  "categories": ["landscape", "portrait", "fantasy", "abstract"],
  "max_concurrent": 2,
  "randomize_prompts": true,
  "save_metadata": true
}

πŸ”§ Advanced Features

Custom Models

You can use any model from CivitAI by copying its AIR ID:

python cli.py generate "Your prompt" --model civitai:123456@789012

Concurrent Processing

The system automatically processes multiple images concurrently for better performance. You can disable this with the --sequential flag:

python cli.py batch --file prompts.txt --sequential

Metadata Tracking

All generations are automatically tracked with metadata including:

  • Generation parameters
  • Model used
  • Timestamps
  • File paths
  • Error information (if any)

Error Handling

The system includes robust error handling:

  • Automatic retries for transient failures
  • Detailed error logging
  • Graceful degradation for partial batch failures
  • Connection recovery for network issues

πŸš€ Deployment

Local Development

For development and testing:

python cli.py generate "Test prompt"

Production Deployment

For production use, consider:

  1. Process Management: Use systemd, supervisord, or pm2 to keep the scheduler running
  2. Logging: Configure proper logging for monitoring
  3. Backup: Regularly backup your generated images and metadata
  4. Monitoring: Set up monitoring for API usage and costs

Example systemd service:

[Unit]
Description=AI Art Scheduler
After=network.target

[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/runware
ExecStart=/usr/bin/python3 cli.py scheduler start
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

πŸ“Š Cost Management

Runware offers competitive pricing starting at $0.0006 per image. Monitor your usage:

  1. Check generation metadata: Review generation_metadata.json
  2. Monitor API usage: Check your Runware dashboard
  3. Set batch limits: Configure appropriate batch sizes
  4. Use efficient models: Choose models that balance quality and cost

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

  • Documentation: Check this README and inline code comments
  • Runware API: Visit docs.runware.ai
  • Issues: Create an issue in this repository
  • Community: Join the Runware community for support

πŸŽ‰ Examples

Generate a Cyberpunk Scene

python cli.py generate "A neon-lit cyberpunk city street with flying cars and holographic advertisements" --model runware:97@2 --width 1344 --height 768

Create a Portrait Series

python cli.py template portrait "a confident business person" --style realistic --count 5

Automated Daily Generation

python cli.py scheduler config --enabled true --interval-hours 24 --batch-size 3
python cli.py scheduler start

Style Experimentation

python cli.py styles "A majestic dragon flying over mountains" --styles realistic anime cyberpunk artistic

Happy generating! 🎨✨

About

AI image generation automated

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published