An AI-powered image editing desktop application with advanced features like inpainting, face swapping, portrait editing, upscaling, and intelligent selection.
AIBox Image is a desktop application built with Rust (frontend) and Python (backend services) that provides a suite of AI-powered image editing tools. The application features a modern GUI built with egui/eframe and leverages state-of-the-art machine learning models for various image manipulation tasks.
- Intelligent Selection: Automated object selection using Grounding DINO and SAM 2 (Segment Anything Model)
- Inpainting: Remove or replace objects in images using Stable Diffusion 1.5
- Face Swapping: Swap faces between images using InsightFace
- Portrait Editing: Advanced portrait manipulation with LivePortrait
- Image Upscaling: Enhance image resolution using Stable Diffusion x4 Upscaler
- History Management: Track and revert image editing operations
- Drag & Drop: Easy image loading via drag and drop
┌─────────────────────────────────────────┐
│ Desktop Application │
│ (Rust + egui/eframe) │
│ │
│ ┌──────────┐ ┌─────────┐ ┌────────┐│
│ │ Canvas │ │ Tools │ │History ││
│ │ Panel │ │ Panel │ │ Panel ││
│ └──────────┘ └─────────┘ └────────┘│
└──────────────────┬──────────────────────┘
│ ZeroMQ (msgpack)
├───────────────┬──────────────┬───────────────┐
▼ ▼ ▼ ▼
┌──────────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Selection │ │Inpainting│ │ Face │ │Upscaling │
│ Service │ │ Service │ │ Swapping │ │ Service │
│ │ │ │ │ Service │ │ │
│ Grounding │ │ Stable │ │Insight- │ │ Stable │
│ DINO + SAM2 │ │Diffusion │ │ Face │ │Diffusion │
└──────────────┘ └──────────┘ └──────────┘ └──────────┘
▲
│
┌───────┴────────┐
│ Portrait │
│ Editing │
│ Service │
│ │
│ LivePortrait │
└────────────────┘
- Framework: eframe 0.32.0 (egui for UI)
- Image Processing: image crate with PNG/JPEG support, fast_morphology for image operations
- Async Runtime: Tokio for concurrent operations
- IPC: ZeroMQ for communication with Python services
- Serialization: MessagePack (rmp-serde) for efficient data transfer
Main Modules:
image_canvas: Interactive image display and manipulationai_tools: UI for all AI-powered editing toolshistory_panel: Undo/redo functionality and operation historyworker: Background task management for AI operationsconfig: Configuration management (reads from config.toml)
All backend services are built with:
- PyTorch: Deep learning framework
- ZeroMQ: Message queue for IPC
- MessagePack: Binary serialization
- Pydantic: Data validation
Services:
-
Selection Service
- Models: Grounding DINO + SAM 2
- Purpose: Intelligent object detection and segmentation
-
Inpainting Service
- Model: Stable Diffusion 1.5 Inpainting
- Purpose: Remove or replace image regions with AI-generated content
-
Face Swapping Service
- Model: InsightFace + InSwapper
- Purpose: Detect and swap faces between images
-
Portrait Editing Service
- Model: LivePortrait
- Purpose: Advanced portrait manipulation and expression transfer
-
Upscaling Service
- Model: Stable Diffusion x4 Upscaler
- Purpose: Enhance image resolution while preserving quality
aibox-image-lib: Python package providing common utilities for all services, including:
- Message protocol definitions
- ZeroMQ transport abstractions
- Shared data structures
- Transport: ZeroMQ (request-reply pattern)
- Serialization: MessagePack for compact binary encoding
- Data Flow:
- User interacts with Rust frontend
- Frontend serializes request (image data + parameters) to MessagePack
- Request sent to appropriate Python service via ZeroMQ
- Service processes image using AI models
- Response (processed image + metadata) sent back via MessagePack
- Frontend deserializes and displays result
The application uses a config.toml file to manage:
- Model cache directory
- Model selections for each service
- Model-specific parameters (model IDs, checkpoints)
- Language: Rust (edition 2024)
- UI Framework: egui/eframe
- Image Processing: image, fast_morphology
- Async: Tokio
- Messaging: ZeroMQ, MessagePack
- Language: Python 3.9-3.14
- ML Framework: PyTorch
- Models:
- Hugging Face Transformers (Stable Diffusion models)
- InsightFace (Face detection/recognition)
- SAM 2 (Segmentation)
- Grounding DINO (Object detection)
- LivePortrait (Portrait editing)
- Messaging: PyZMQ, MessagePack
- Validation: Pydantic
- Rust (latest stable)
- Python 3.9-3.14
- CUDA-capable GPU (recommended for AI models)
- uv (Python package manager)
aibox-image/
├── app/ # Rust frontend application
│ ├── src/ # Source code
│ │ ├── ai_tools/ # AI tool UI components
│ │ ├── image_canvas/ # Canvas implementation
│ │ ├── main.rs # Application entry point
│ │ └── worker.rs # Background task handling
│ ├── config.toml # Application configuration
│ └── Cargo.toml # Rust dependencies
│
└── backend/ # Python backend services
├── aibox-image-lib/ # Shared Python library
│ └── src/aibox_image_lib/ # Transport and protocol code
├── selection-service/ # Object selection service
├── inpainting-service/ # Image inpainting service
├── face-swapping-service/ # Face swapping service
├── portrait-editing-service/ # Portrait editing service
└── upscaling-service/ # Image upscaling service
# Build the frontend
cd app
cargo build --release
# Install backend dependencies (per service)
cd ../backend/selection-service
uv sync