psdfy 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- psdfy-0.1.3/PKG-INFO +425 -0
- psdfy-0.1.3/README.md +391 -0
- psdfy-0.1.3/psdfy/__init__.py +3 -0
- psdfy-0.1.3/psdfy/__main__.py +6 -0
- psdfy-0.1.3/psdfy/cli.py +253 -0
- psdfy-0.1.3/psdfy/config.py +140 -0
- psdfy-0.1.3/psdfy/weights.py +132 -0
- psdfy-0.1.3/psdfy.egg-info/PKG-INFO +425 -0
- psdfy-0.1.3/psdfy.egg-info/SOURCES.txt +18 -0
- psdfy-0.1.3/psdfy.egg-info/dependency_links.txt +1 -0
- psdfy-0.1.3/psdfy.egg-info/entry_points.txt +2 -0
- psdfy-0.1.3/psdfy.egg-info/requires.txt +19 -0
- psdfy-0.1.3/psdfy.egg-info/top_level.txt +1 -0
- psdfy-0.1.3/pyproject.toml +64 -0
- psdfy-0.1.3/setup.cfg +4 -0
- psdfy-0.1.3/tests/test_api_convert.py +212 -0
- psdfy-0.1.3/tests/test_auth_signature.py +756 -0
- psdfy-0.1.3/tests/test_layer_builder.py +87 -0
- psdfy-0.1.3/tests/test_mask_postprocess.py +110 -0
- psdfy-0.1.3/tests/test_naming.py +55 -0
psdfy-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: psdfy
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: PSD layer converter and processor
|
|
5
|
+
Author-email: Wirandra Alaya <daycodestudioproject@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: psd,layer,converter
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: typer>=0.9.0
|
|
17
|
+
Requires-Dist: fastapi>=0.100.0
|
|
18
|
+
Requires-Dist: uvicorn>=0.23.0
|
|
19
|
+
Requires-Dist: pydantic>=2.0
|
|
20
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
21
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
22
|
+
Requires-Dist: itsdangerous>=2.0
|
|
23
|
+
Requires-Dist: bcrypt>=4.0
|
|
24
|
+
Requires-Dist: requests>=2.31.0
|
|
25
|
+
Requires-Dist: pillow>=10.0.0
|
|
26
|
+
Requires-Dist: numpy>=1.24.0
|
|
27
|
+
Requires-Dist: opencv-python-headless>=4.8.0
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
34
|
+
|
|
35
|
+
# 🎨 psdfy
|
|
36
|
+
|
|
37
|
+
**Convert any image into an editable Adobe Photoshop file with AI-powered layer segmentation.**
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ✨ Features
|
|
44
|
+
|
|
45
|
+
- **🤖 AI-Powered Segmentation** - Uses SAM 2 to automatically detect and separate objects
|
|
46
|
+
- **📦 Multi-Layer PSD Export** - Each detected object becomes an editable layer
|
|
47
|
+
- **🎯 Text-Prompted Detection** - Optional GroundingDINO integration for specific object detection
|
|
48
|
+
- **🌐 Web UI** - Simple browser interface for uploading and downloading
|
|
49
|
+
- **💻 CLI Tool** - Command-line interface for automation and scripting
|
|
50
|
+
- **☁️ Cloud Ready** - S3 storage backend support for cloud deployments
|
|
51
|
+
- **🐳 Docker Support** - CPU and GPU Docker images included
|
|
52
|
+
- **⚡ Fast Processing** - Optimized for 1080p images (< 5 seconds on GPU)
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🚀 Quick Start
|
|
57
|
+
|
|
58
|
+
### Option 1: Web UI (Easiest)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Install psdfy
|
|
62
|
+
pip install psdfy
|
|
63
|
+
|
|
64
|
+
# Run installation wizard
|
|
65
|
+
psdfy install
|
|
66
|
+
|
|
67
|
+
# Start the service
|
|
68
|
+
psdfy start
|
|
69
|
+
|
|
70
|
+
# Open browser and go to http://localhost:3457
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then:
|
|
74
|
+
1. Login with password (default: `123456`)
|
|
75
|
+
2. Upload an image
|
|
76
|
+
3. Click "Convert to PSD"
|
|
77
|
+
4. Download your layered PSD file
|
|
78
|
+
|
|
79
|
+
### Option 1b: Install Without Weights (Lightweight)
|
|
80
|
+
|
|
81
|
+
If you want to set up psdfy without downloading the large model weights (5GB+), use:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install psdfy
|
|
85
|
+
pip install psdfy
|
|
86
|
+
|
|
87
|
+
# Run installation wizard without downloading weights
|
|
88
|
+
psdfy install --skip-weights
|
|
89
|
+
|
|
90
|
+
# Later, download weights when ready
|
|
91
|
+
psdfy install --download-weights-only
|
|
92
|
+
|
|
93
|
+
# Start the service
|
|
94
|
+
psdfy start
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This is useful for:
|
|
98
|
+
- Setting up on servers with limited bandwidth
|
|
99
|
+
- Testing the UI before committing to full installation
|
|
100
|
+
- Downloading weights on a separate machine
|
|
101
|
+
|
|
102
|
+
### Option 2: Docker (Recommended)
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# CPU version
|
|
106
|
+
docker build -f docker/Dockerfile -t psdfy:latest .
|
|
107
|
+
docker run -p 3456:3456 -p 3457:3457 psdfy:latest
|
|
108
|
+
|
|
109
|
+
# GPU version (CUDA 12.1)
|
|
110
|
+
docker build -f docker/Dockerfile.gpu -t psdfy:gpu .
|
|
111
|
+
docker run --gpus all -p 3456:3456 -p 3457:3457 psdfy:gpu
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Option 3: Python API
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from app.utils.io import load_image
|
|
118
|
+
from app.services.segmenter import get_segmenter
|
|
119
|
+
from app.services.psd_writer import get_psd_writer
|
|
120
|
+
|
|
121
|
+
# Load image
|
|
122
|
+
image_array, (width, height), fmt = load_image(image_bytes)
|
|
123
|
+
|
|
124
|
+
# Segment objects
|
|
125
|
+
segmenter = get_segmenter()
|
|
126
|
+
masks = segmenter.segment_auto(image_array)
|
|
127
|
+
|
|
128
|
+
# Write PSD
|
|
129
|
+
psd_writer = get_psd_writer()
|
|
130
|
+
psd_bytes = psd_writer.write_psd(layers, width, height)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 📖 Usage
|
|
136
|
+
|
|
137
|
+
### Web UI
|
|
138
|
+
|
|
139
|
+
1. **Login** - Enter password (default: `123456`)
|
|
140
|
+
2. **Upload** - Drag & drop or click to select image
|
|
141
|
+
3. **Configure** - Choose segmentation mode:
|
|
142
|
+
- `Automatic` - Detects all objects
|
|
143
|
+
- `Text Prompt` - Specify objects (e.g., "person . table . book")
|
|
144
|
+
4. **Convert** - Click "Convert to PSD"
|
|
145
|
+
5. **Download** - Get your layered PSD file
|
|
146
|
+
|
|
147
|
+
### CLI Commands
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Show version and system info
|
|
151
|
+
psdfy version
|
|
152
|
+
|
|
153
|
+
# Install/configure psdfy
|
|
154
|
+
psdfy install --password mypassword
|
|
155
|
+
|
|
156
|
+
# Start API and UI servers
|
|
157
|
+
psdfy start
|
|
158
|
+
|
|
159
|
+
# Stop servers
|
|
160
|
+
psdfy stop
|
|
161
|
+
|
|
162
|
+
# Diagnose and repair installation
|
|
163
|
+
psdfy fix --dry-run
|
|
164
|
+
|
|
165
|
+
# Update to latest version
|
|
166
|
+
psdfy update
|
|
167
|
+
|
|
168
|
+
# Check for issues
|
|
169
|
+
psdfy fix --redownload-weights
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 🏗️ Architecture
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
┌─────────────────────────────────────────────────────────┐
|
|
178
|
+
│ Browser (Web UI) │
|
|
179
|
+
└────────────────────────┬────────────────────────────────┘
|
|
180
|
+
│ (Cookie Auth)
|
|
181
|
+
▼
|
|
182
|
+
┌─────────────────────────────────────────────────────────┐
|
|
183
|
+
│ GUI Web Server (Port 3457) │
|
|
184
|
+
│ - Login page │
|
|
185
|
+
│ - Upload interface │
|
|
186
|
+
│ - Server-side proxy to API │
|
|
187
|
+
└────────────────────────┬────────────────────────────────┘
|
|
188
|
+
│ (X-Session-Id, X-Client-Signature)
|
|
189
|
+
▼
|
|
190
|
+
┌─────────────────────────────────────────────────────────┐
|
|
191
|
+
│ Proxy API Server (Port 3456) │
|
|
192
|
+
│ - /convert - Image to PSD conversion │
|
|
193
|
+
│ - /files - Download results │
|
|
194
|
+
│ - /auth - Session management │
|
|
195
|
+
└────────────────────────┬────────────────────────────────┘
|
|
196
|
+
│
|
|
197
|
+
┌────────────────┼────────────────┐
|
|
198
|
+
▼ ▼ ▼
|
|
199
|
+
┌────────┐ ┌────────┐ ┌────────┐
|
|
200
|
+
│ SAM 2 │ │ Mask │ │ PSD │
|
|
201
|
+
│ Loader │ │ Post- │ │ Writer │
|
|
202
|
+
│ │ │ process│ │ │
|
|
203
|
+
└────────┘ └────────┘ └────────┘
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 🛠️ Development
|
|
209
|
+
|
|
210
|
+
### Setup
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Clone repository
|
|
214
|
+
git clone https://github.com/Mattel-Limbo/psdfy.git
|
|
215
|
+
cd psdfy
|
|
216
|
+
|
|
217
|
+
# Create virtual environment
|
|
218
|
+
python -m venv venv
|
|
219
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
220
|
+
|
|
221
|
+
# Install in development mode
|
|
222
|
+
pip install -e ".[dev]"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Code Quality
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Run linter
|
|
229
|
+
ruff check app psdfy tests
|
|
230
|
+
|
|
231
|
+
# Format code
|
|
232
|
+
black app psdfy tests
|
|
233
|
+
|
|
234
|
+
# Type checking
|
|
235
|
+
mypy --strict app psdfy
|
|
236
|
+
|
|
237
|
+
# Run tests
|
|
238
|
+
pytest tests/ -v
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Project Structure
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
psdfy/
|
|
245
|
+
├── app/ # FastAPI application
|
|
246
|
+
│ ├── api_app/ # Proxy API server (port 3456)
|
|
247
|
+
│ ├── ui_app/ # Web UI server (port 3457)
|
|
248
|
+
│ ├── services/ # Business logic (segmentation, PSD writing, etc.)
|
|
249
|
+
│ ├── models/ # AI model loaders (SAM 2, GroundingDINO)
|
|
250
|
+
│ ├── storage/ # Storage backends (local, S3)
|
|
251
|
+
│ └── utils/ # Helper utilities
|
|
252
|
+
├── psdfy/ # CLI tool
|
|
253
|
+
│ ├── commands/ # CLI commands (install, start, stop, etc.)
|
|
254
|
+
│ ├── config.py # Configuration management
|
|
255
|
+
│ └── weights.py # Model weights downloader
|
|
256
|
+
├── web/ # Web UI assets
|
|
257
|
+
│ └── templates/ # HTML templates
|
|
258
|
+
├── tests/ # Test suite
|
|
259
|
+
├── docker/ # Docker configurations
|
|
260
|
+
└── scripts/ # Utility scripts (benchmarking, etc.)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 📋 Requirements
|
|
266
|
+
|
|
267
|
+
- **Python**: 3.11 or higher
|
|
268
|
+
- **RAM**: 8GB minimum (16GB recommended)
|
|
269
|
+
- **GPU** (optional): NVIDIA GPU with CUDA 12.1+ for faster processing
|
|
270
|
+
- **Disk**: 5GB for model weights
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 🔧 Configuration
|
|
275
|
+
|
|
276
|
+
Configuration is stored in `~/.psdfy/config.toml`:
|
|
277
|
+
|
|
278
|
+
```toml
|
|
279
|
+
[app]
|
|
280
|
+
host = "localhost"
|
|
281
|
+
api_port = 3456
|
|
282
|
+
ui_port = 3457
|
|
283
|
+
device = "cpu" # or "cuda", "mps"
|
|
284
|
+
|
|
285
|
+
[auth]
|
|
286
|
+
ui_password_hash = "..."
|
|
287
|
+
client_secret = "..."
|
|
288
|
+
|
|
289
|
+
[models]
|
|
290
|
+
sam2_weights_path = "~/.psdfy/weights/sam2_hiera_large.pt"
|
|
291
|
+
enable_grounding_dino = false
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 🐛 Troubleshooting
|
|
297
|
+
|
|
298
|
+
### Port Already in Use
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Change ports
|
|
302
|
+
psdfy start --api-port 3500 --ui-port 3501
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Model Weights Not Found
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Re-download weights
|
|
309
|
+
psdfy fix --redownload-weights
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Reset Password
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Reset to default (123456)
|
|
316
|
+
psdfy fix --reset-password
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Check System Health
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Run diagnostics
|
|
323
|
+
psdfy fix --dry-run
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 📊 Performance
|
|
329
|
+
|
|
330
|
+
| Resolution | GPU (RTX 3080) | CPU (i7-12700) |
|
|
331
|
+
|-----------|----------------|----------------|
|
|
332
|
+
| 512x512 | ~0.5s | ~3s |
|
|
333
|
+
| 1080x1080 | ~1.5s | ~8s |
|
|
334
|
+
| 2160x2160 | ~4s | ~20s |
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 📝 API Examples
|
|
339
|
+
|
|
340
|
+
### Convert Image (cURL)
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Get session
|
|
344
|
+
SESSION=$(curl -X POST http://localhost:3456/auth/client-signature \
|
|
345
|
+
-H "Content-Type: application/json" \
|
|
346
|
+
-d '{"clientSecret":"your-secret"}' | jq -r '.sessionId')
|
|
347
|
+
|
|
348
|
+
# Convert image
|
|
349
|
+
curl -X POST http://localhost:3456/convert \
|
|
350
|
+
-H "X-Session-Id: $SESSION" \
|
|
351
|
+
-H "X-Client-Signature: your-signature" \
|
|
352
|
+
-F "file=@image.jpg" \
|
|
353
|
+
-F "mode=auto" \
|
|
354
|
+
-o output.psd
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Convert Image (Python)
|
|
358
|
+
|
|
359
|
+
```python
|
|
360
|
+
import requests
|
|
361
|
+
|
|
362
|
+
# Get session
|
|
363
|
+
response = requests.post(
|
|
364
|
+
"http://localhost:3456/auth/client-signature",
|
|
365
|
+
json={"clientSecret": "your-secret"}
|
|
366
|
+
)
|
|
367
|
+
session_id = response.json()["sessionId"]
|
|
368
|
+
|
|
369
|
+
# Convert image
|
|
370
|
+
with open("image.jpg", "rb") as f:
|
|
371
|
+
response = requests.post(
|
|
372
|
+
"http://localhost:3456/convert",
|
|
373
|
+
headers={
|
|
374
|
+
"X-Session-Id": session_id,
|
|
375
|
+
"X-Client-Signature": "your-signature"
|
|
376
|
+
},
|
|
377
|
+
files={"file": f},
|
|
378
|
+
data={"mode": "auto"}
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
# Save PSD
|
|
382
|
+
with open("output.psd", "wb") as f:
|
|
383
|
+
f.write(response.content)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## 📄 License
|
|
389
|
+
|
|
390
|
+
MIT License - see LICENSE file for details
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## 🤝 Contributing
|
|
395
|
+
|
|
396
|
+
Contributions are welcome! Please:
|
|
397
|
+
|
|
398
|
+
1. Fork the repository
|
|
399
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
400
|
+
3. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
401
|
+
4. Push to branch (`git push origin feature/amazing-feature`)
|
|
402
|
+
5. Open a Pull Request
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 📞 Support
|
|
407
|
+
|
|
408
|
+
- **Issues**: [GitHub Issues](https://github.com/Mattel-Limbo/psdfy/issues)
|
|
409
|
+
- **Discussions**: [GitHub Discussions](https://github.com/Mattel-Limbo/psdfy/discussions)
|
|
410
|
+
- **Documentation**: See `plan.md` for detailed technical documentation
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## 🎯 Roadmap
|
|
415
|
+
|
|
416
|
+
- [ ] Batch processing support
|
|
417
|
+
- [ ] Advanced layer ordering heuristics
|
|
418
|
+
- [ ] Real-time preview in browser
|
|
419
|
+
- [ ] Multi-user support with API keys
|
|
420
|
+
- [ ] Webhook notifications
|
|
421
|
+
- [ ] Custom model fine-tuning
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
**Made with ❤️ for designers and developers**
|