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:
- Login with password (default:
123456) - Upload an image
- Click "Convert to PSD"
- 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
- Login - Enter password (default:
123456) - Upload - Drag & drop or click to select image
- Configure - Choose segmentation mode:
Automatic- Detects all objectsText Prompt- Specify objects (e.g., "person . table . book")
- Convert - Click "Convert to PSD"
- 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:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See
plan.mdfor detailed technical documentation
๐ฏ 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file psdfy-0.2.2.tar.gz.
File metadata
- Download URL: psdfy-0.2.2.tar.gz
- Upload date:
- Size: 65.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b00c4086ac42173d1b4b8748cf5adbdfd30540d59b2a205f61d93468729e59d
|
|
| MD5 |
26db87ad022e9f12b31d0d3855a6a7cf
|
|
| BLAKE2b-256 |
b9244530e4b3309abbe62814d26415c1eb658b4bbdd4e3401128b90ee664c467
|
File details
Details for the file psdfy-0.2.2-py3-none-any.whl.
File metadata
- Download URL: psdfy-0.2.2-py3-none-any.whl
- Upload date:
- Size: 73.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f14de1fad066d178cb093c4fd96a85cc0f8ee4a7869a60bc261ce707744fbe0c
|
|
| MD5 |
c4352b6e6b1e684e189a95a391745c52
|
|
| BLAKE2b-256 |
40d83421c19ceb0313591c0cdce3e2a28cf1bcc3a16584826301574b53b7f819
|