Upscale low-quality images using Real-ESRGAN and auto-fit them to any device screen.
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txtThe Real-ESRGAN binary (realesrgan-ncnn-vulkan) is downloaded automatically on first run.
python test_upscale.py --image tests/test.png
python test_upscale.py --image tests/test.png --device iphone_15_pro --fit cover
python test_upscale.py --scale 2
python test_upscale.py --list-devicespython run_server.py| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check |
| GET | /api/devices |
List device presets |
| POST | /api/upscale |
Upscale an image |
| POST | /api/upscale-device |
Upscale + fit to device screen |
| Field | Type | Default | Notes |
|---|---|---|---|
file |
file | — | Image upload |
scale |
int | 4 | 2 or 4 |
output_format |
str | PNG | PNG/JPEG/WEBP |
Same as above, plus:
| Field | Type | Default | Notes |
|---|---|---|---|
device |
str | — | Preset key (e.g. iphone_15_pro) |
screen_width |
int | — | Custom width (CSS px) |
screen_height |
int | — | Custom height (CSS px) |
dpr |
float | 1.0 | Device pixel ratio |
fit |
str | contain | contain / cover / fill |
Device resolution priority: preset > custom dims > User-Agent > desktop_1080p fallback.
Phones: iPhone 15 Pro, iPhone 14, iPhone SE, Pixel 8, Galaxy S24 Tablets: iPad Pro 12.9", iPad Air Desktop: 1080p, 1440p, 4K, MacBook Pro 14", MacBook Air 13"
- Real-ESRGAN (ncnn-vulkan) — GPU-accelerated image super-resolution
- FastAPI — REST API
- Pillow — Image processing
- Vanilla JS — Frontend