Files
PaintPlus/scripts
Claude 8fe8498df2 Add local GPU inference: auto-detect GPU, auto-download best diffusion models
Adds AI_PROVIDER=local_gpu — a fully self-contained GPU inference engine
using HuggingFace Diffusers that requires zero InvokeAI/ComfyUI setup.
All existing providers (InvokeAI, ComfyUI, OpenAI, Replicate) remain intact
and can be mixed with local GPU via per-operation overrides.

New features:
- GPU auto-detection (CUDA/NVIDIA, MPS/Apple Silicon, CPU fallback)
- VRAM-tiered model selection:
    ultra ≥16 GB → SDXL inpaint + SDXL base
    high  8-16 GB → SDXL inpaint + SDXL base
    medium 4-8 GB → SD 2.x inpaint + SD 2.1
    low  <4 GB   → SD 2.x (small)
- Auto-download model weights to HuggingFace disk cache at startup
  (background task; first request loads from local disk, not internet)
- LRU pipeline cache evicts oldest GPU pipeline when VRAM limit reached
- Per-operation model overrides via HF_MODEL_INPAINT / HF_MODEL_TXT2IMG etc.
- Optional HF_TOKEN for gated/private HuggingFace models

New files:
- backend/app/services/gpu_detect.py   — GPU detection + tier/model mapping
- backend/app/services/local_diffusion.py — Diffusers provider + LRU cache
- backend/app/routers/gpu_status.py    — GET /api/gpu/status, POST /api/gpu/prefetch
- backend/requirements.gpu.txt         — Diffusers ecosystem deps (GPU only)
- docker-compose.gpu.yml               — NVIDIA GPU compose (one-command startup)
- Dockerfile.gpu                       — pytorch/pytorch:2.1.0-cuda12.1 base image
- scripts/gpu_setup.py                 — Startup GPU info logger

Modified:
- backend/app/config.py                — local_gpu settings added
- backend/app/services/remote_provider.py — local_gpu registered as provider
- backend/app/routers/ai_tools.py      — /api/config exposes GPU tier + caps
- backend/app/main.py                  — GPU router + background prefetch task
- backend/entrypoint.sh                — runs gpu_setup.py at container start
- .env.example                         — local_gpu documented as first option

Quick start with GPU:
  docker compose -f docker-compose.gpu.yml up --build

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 15:08:41 +00:00
..

Classic Eyes Scripts

This directory contains scripts for generating and importing classic eye images into the AI Photo Edit patch library.

Overview

The scripts generate a variety of classic eye styles that can be used as reusable patches for photo editing:

  • Realistic eyes - Detailed eyes with gradient irises and realistic highlights
  • Anime eyes - Large, expressive eyes in anime style with prominent highlights
  • Cartoon eyes - Simple, bold cartoon-style eyes

Each style is available in multiple iris colors: blue, green, brown, hazel, grey, and amber.

Scripts

1. generate_classic_eyes_ppm.py

Generates classic eye images using only the Python standard library (no dependencies required).

python scripts/generate_classic_eyes_ppm.py

This creates PPM format images in data/classic_eyes_ppm/. PPM is a simple image format that can be converted to PNG later.

2. download_classic_eyes.py

Full-featured script that generates eyes and imports them directly into the patch library. Requires PIL/Pillow.

# Run inside the backend container
docker exec -it ai-photo-edit-backend python /app/../scripts/download_classic_eyes.py

# Or with the API running
python scripts/download_classic_eyes.py --api --base-url http://localhost:8101

# Or save to a directory for later import
python scripts/download_classic_eyes.py --output-dir ./my_eyes

3. startup_import_eyes.py

Converts PPM files to PNG and imports them into the patch library. Run this inside the backend container.

docker exec -it ai-photo-edit-backend python /app/../scripts/startup_import_eyes.py

4. import_saved_eyes.py

Import previously saved eye images from a directory.

python scripts/import_saved_eyes.py /path/to/saved/eyes

Quick Start

  1. Generate the eye images (no dependencies needed):

    python scripts/generate_classic_eyes_ppm.py
    
  2. Start the application:

    docker compose up -d
    
  3. Import the eyes:

    docker exec -it ai-photo-edit-backend python /scripts/startup_import_eyes.py
    
  4. Verify in the app: Open the patch library in the UI to see the imported classic eyes.

Generated Eyes

Style Colors Available Size
Realistic Blue, Green, Brown, Hazel, Grey, Amber 200x200
Anime Blue, Green, Brown, Hazel, Grey, Amber 200x200
Cartoon Blue, Green, Brown, Hazel, Grey, Amber 200x200

Total: 18 unique eye variants

Extending

To add more eye styles or colors, edit the generate_classic_eyes_ppm.py or download_classic_eyes.py scripts:

# Add new color
colors["purple"] = (128, 0, 128)

# Add new style in create_classic_eye() function
elif style == "fantasy":
    # Your custom eye drawing code
    pass

File Formats

  • PPM: Portable Pixmap format - simple, universal, generated without dependencies
  • PNG: Preferred format for the patch library - converted from PPM using PIL

License

The generated eye images are created programmatically and are free to use without restrictions.