File size: 2,044 Bytes
0e868b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: Color Restorization Model
emoji: 🖼️
colorFrom: indigo
colorTo: yellow
sdk: gradio
sdk_version: 3.9
app_file: app.py
pinned: true
license: unlicense
---

# 🌈 Color Restorization Model (CPU Optimized)

Bring your old black & white photos back to life—upload, adjust, and download in vivid color.

This version has been optimized for **CPU inference**, removing GPU dependencies and improving performance on standard hardware.

## Features

*   **Adaptive Resolution Processing**: Large images are processed intelligently to preserve sharpness while ensuring fast colorization.
*   **Quality Presets**: Choose between **Fast**, **Balanced**, and **High** quality to suit your hardware.
*   **Real-time Progress**: Visual progress bar.
*   **Pure CPU Stack**: Optimized for Intel/AMD CPUs with AVX2 support (via PyTorch).

## CPU Compatibility Matrix

| Processor Generation | Recommended Preset | 1080p Processing Time (Est.) |
| :--- | :--- | :--- |
| Intel Core i3 / Older | **Fast (256px)** | 2-5s |
| Intel Core i5 (8th Gen+) | **Balanced (512px)** | 1-3s |
| Intel Core i7 / Ryzen 7 | **High (1080px)** | 3-8s |
| M1/M2 Mac | **Balanced** | <1s |

## Performance Tuning

*   **Memory Constrained (<8GB RAM):** Stick to "Fast" or "Balanced".
*   **High-Res Archival:** Use "Original" resolution only if you have >16GB RAM and patience.
*   **Batch Processing:** The core logic is thread-safe and can be extended for batch processing.

## Technical Details

The application uses the DDColor architecture via ModelScope. Optimizations include:
1.  **L-Channel Preservation:** We apply colorization at a lower resolution and merge it with the original high-resolution Luminance channel using LAB color space.
2.  **In-Memory Pipeline:** Removed disk I/O bottlenecks.
3.  **Dynamic Quantization:** Automatically applied to the model on supported CPUs.

## Installation

```bash
pip install -r requirements.txt
python app.py
```

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference