Skip to main content

PSD layer converter and processor

Project description

๐ŸŽจ psdfy

Convert any image into an editable Adobe Photoshop file with AI-powered layer segmentation.

Upload a photo, and psdfy automatically detects objects, creates separate layers for each one, and exports a ready-to-edit .psd file. Perfect for designers, photographers, and anyone who needs to work with layered images.


โœจ Features

  • ๐Ÿค– AI-Powered Segmentation - Uses SAM 2 to automatically detect and separate objects
  • ๐Ÿ“ฆ Multi-Layer PSD Export - Each detected object becomes an editable layer
  • ๐ŸŽฏ Text-Prompted Detection - Optional GroundingDINO integration for specific object detection
  • ๐ŸŒ Web UI - Simple browser interface for uploading and downloading
  • ๐Ÿ’ป CLI Tool - Command-line interface for automation and scripting
  • โ˜๏ธ Cloud Ready - S3 storage backend support for cloud deployments
  • ๐Ÿณ Docker Support - CPU and GPU Docker images included
  • โšก Fast Processing - Optimized for 1080p images (< 5 seconds on GPU)

๐Ÿš€ Quick Start

Option 1: Web UI (Easiest)

# Install psdfy
pip install psdfy

# Run installation wizard
psdfy install

# Start the service
psdfy start

# Open browser and go to http://localhost:3457

Then:

  1. Login with password (default: 123456)
  2. Upload an image
  3. Click "Convert to PSD"
  4. Download your layered PSD file

Option 1b: Install Without Weights (Lightweight)

If you want to set up psdfy without downloading the large model weights (5GB+), use:

# Install psdfy
pip install psdfy

# Run installation wizard without downloading weights
psdfy install --no-weights

# Later, download weights when ready
psdfy install --download-weights-only

# Start the service
psdfy start

This is useful for:

  • Setting up on servers with limited bandwidth
  • Testing the UI before committing to full installation
  • Downloading weights on a separate machine
  • Running without SAM2 segmentation (basic functionality only)

Option 2: Docker (Recommended)

# CPU version
docker build -f docker/Dockerfile -t psdfy:latest .
docker run -p 3456:3456 -p 3457:3457 psdfy:latest

# GPU version (CUDA 12.1)
docker build -f docker/Dockerfile.gpu -t psdfy:gpu .
docker run --gpus all -p 3456:3456 -p 3457:3457 psdfy:gpu

Option 3: Python API

from app.utils.io import load_image
from app.services.segmenter import get_segmenter
from app.services.psd_writer import get_psd_writer

# Load image
image_array, (width, height), fmt = load_image(image_bytes)

# Segment objects
segmenter = get_segmenter()
masks = segmenter.segment_auto(image_array)

# Write PSD
psd_writer = get_psd_writer()
psd_bytes = psd_writer.write_psd(layers, width, height)

๐Ÿ“– Usage

Web UI

  1. Login - Enter password (default: 123456)
  2. Upload - Drag & drop or click to select image
  3. Configure - Choose segmentation mode:
    • Automatic - Detects all objects
    • Text Prompt - Specify objects (e.g., "person . table . book")
  4. Convert - Click "Convert to PSD"
  5. Download - Get your layered PSD file

CLI Commands

# Show version and system info
psdfy version

# Install/configure psdfy
psdfy install --password mypassword

# Start API and UI servers
psdfy start

# Stop servers
psdfy stop

# Diagnose and repair installation
psdfy fix --dry-run

# Update to latest version
psdfy update

# Check for issues
psdfy fix --redownload-weights

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Browser (Web UI)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚ (Cookie Auth)
                         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         GUI Web Server (Port 3457)                       โ”‚
โ”‚  - Login page                                            โ”‚
โ”‚  - Upload interface                                      โ”‚
โ”‚  - Server-side proxy to API                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚ (X-Session-Id, X-Client-Signature)
                         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Proxy API Server (Port 3456)                     โ”‚
โ”‚  - /convert - Image to PSD conversion                   โ”‚
โ”‚  - /files - Download results                            โ”‚
โ”‚  - /auth - Session management                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                โ–ผ                โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ SAM 2  โ”‚      โ”‚ Mask   โ”‚      โ”‚ PSD    โ”‚
    โ”‚ Loader โ”‚      โ”‚ Post-  โ”‚      โ”‚ Writer โ”‚
    โ”‚        โ”‚      โ”‚ processโ”‚      โ”‚        โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Development

Setup

# Clone repository
git clone https://github.com/Mattel-Limbo/psdfy.git
cd psdfy

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

Code Quality

# Run linter
ruff check app psdfy tests

# Format code
black app psdfy tests

# Type checking
mypy --strict app psdfy

# Run tests
pytest tests/ -v

Project Structure

psdfy/
โ”œโ”€โ”€ app/                    # FastAPI application
โ”‚   โ”œโ”€โ”€ api_app/           # Proxy API server (port 3456)
โ”‚   โ”œโ”€โ”€ ui_app/            # Web UI server (port 3457)
โ”‚   โ”œโ”€โ”€ services/          # Business logic (segmentation, PSD writing, etc.)
โ”‚   โ”œโ”€โ”€ models/            # AI model loaders (SAM 2, GroundingDINO)
โ”‚   โ”œโ”€โ”€ storage/           # Storage backends (local, S3)
โ”‚   โ””โ”€โ”€ utils/             # Helper utilities
โ”œโ”€โ”€ psdfy/                 # CLI tool
โ”‚   โ”œโ”€โ”€ commands/          # CLI commands (install, start, stop, etc.)
โ”‚   โ”œโ”€โ”€ config.py          # Configuration management
โ”‚   โ””โ”€โ”€ weights.py         # Model weights downloader
โ”œโ”€โ”€ web/                   # Web UI assets
โ”‚   โ””โ”€โ”€ templates/         # HTML templates
โ”œโ”€โ”€ tests/                 # Test suite
โ”œโ”€โ”€ docker/                # Docker configurations
โ””โ”€โ”€ scripts/               # Utility scripts (benchmarking, etc.)

๐Ÿ“‹ Requirements

  • Python: 3.11 or higher
  • RAM: 8GB minimum (16GB recommended)
  • GPU (optional): NVIDIA GPU with CUDA 12.1+ for faster processing
  • Disk: 5GB for model weights

๐Ÿ”ง Configuration

Configuration is stored in ~/.psdfy/config.toml:

[app]
host = "localhost"
api_port = 3456
ui_port = 3457
device = "cpu"  # or "cuda", "mps"

[auth]
ui_password_hash = "..."
client_secret = "..."

[models]
sam2_weights_path = "~/.psdfy/weights/sam2_hiera_large.pt"
enable_grounding_dino = false

๐Ÿ› Troubleshooting

Port Already in Use

# Change ports
psdfy start --api-port 3500 --ui-port 3501

Model Weights Not Found

# Re-download weights
psdfy fix --redownload-weights

Reset Password

# Reset to default (123456)
psdfy fix --reset-password

Check System Health

# Run diagnostics
psdfy fix --dry-run

๐Ÿ“Š Performance

Resolution GPU (RTX 3080) CPU (i7-12700)
512x512 ~0.5s ~3s
1080x1080 ~1.5s ~8s
2160x2160 ~4s ~20s

๐Ÿ“ API Examples

Convert Image (cURL)

# Get session
SESSION=$(curl -X POST http://localhost:3456/auth/client-signature \
  -H "Content-Type: application/json" \
  -d '{"clientSecret":"your-secret"}' | jq -r '.sessionId')

# Convert image
curl -X POST http://localhost:3456/convert \
  -H "X-Session-Id: $SESSION" \
  -H "X-Client-Signature: your-signature" \
  -F "file=@image.jpg" \
  -F "mode=auto" \
  -o output.psd

Convert Image (Python)

import requests

# Get session
response = requests.post(
    "http://localhost:3456/auth/client-signature",
    json={"clientSecret": "your-secret"}
)
session_id = response.json()["sessionId"]

# Convert image
with open("image.jpg", "rb") as f:
    response = requests.post(
        "http://localhost:3456/convert",
        headers={
            "X-Session-Id": session_id,
            "X-Client-Signature": "your-signature"
        },
        files={"file": f},
        data={"mode": "auto"}
    )

# Save PSD
with open("output.psd", "wb") as f:
    f.write(response.content)

๐Ÿ“„ License

MIT License - see LICENSE file for details


๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ž Support


๐ŸŽฏ Roadmap

  • Batch processing support
  • Advanced layer ordering heuristics
  • Real-time preview in browser
  • Multi-user support with API keys
  • Webhook notifications
  • Custom model fine-tuning

Made with โค๏ธ for designers and developers

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

psdfy-0.1.5.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

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

psdfy-0.1.5-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file psdfy-0.1.5.tar.gz.

File metadata

  • Download URL: psdfy-0.1.5.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for psdfy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7abfe85179fd357e14db789156acffaebdbff4a076162e80fed86948d2ec5279
MD5 8259161316bbcf1631dd37c0e8132649
BLAKE2b-256 20823e24d391b3cbeaeaa7e59d9526d8ded03e3895dbab8f01ea5150471e88bc

See more details on using hashes here.

File details

Details for the file psdfy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: psdfy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for psdfy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 218593d2beacf3b0144d5d4f92f03ddeb2b8402def8ff0c94a714ce9e0a28494
MD5 7127c2a0bd6117908957396c8143626d
BLAKE2b-256 1201409ceb0e080485686666a15f17d9c758e53cfef64928fa605e4b86314088

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