Upload folder using huggingface_hub
Browse files- README.md +137 -0
- configuration.json +67 -0
- pytorch_model.pt +3 -0
README.md
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# MakeItColor: Image Colorization Model
|
2 |
+
|
3 |
+
## Model Description
|
4 |
+
**MakeItColor** is a deep learning model designed for automatic image colorization. It accepts grayscale images as input and generates vivid, realistic colorized outputs. Built with a PyTorch-based Convolutional Neural Network (CNN) architecture, it is seamlessly integrated with the **ModelScope** framework for easy deployment across various applications.
|
5 |
+
|
6 |
+
This model is inspired by and builds upon the work of [DDColor](https://github.com/piddnad/DDColor), utilizing a dual-encoder approach and trained on the **ImageNet-Val5k** dataset.
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
## Task
|
11 |
+
- **Image Colorization**
|
12 |
+
|
13 |
+
## Framework
|
14 |
+
- **PyTorch**, **ModelScope**
|
15 |
+
|
16 |
+
## Model Type
|
17 |
+
- **Convolutional Neural Network (CNN)**
|
18 |
+
|
19 |
+
## Input
|
20 |
+
- **Grayscale images** (single-channel)
|
21 |
+
|
22 |
+
## Output
|
23 |
+
- **Colorized images** (RGB format)
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
## Installation
|
28 |
+
Make sure you have **Python 3.7+** installed. Then, install the required dependencies:
|
29 |
+
|
30 |
+
```bash
|
31 |
+
!pip install gradio
|
32 |
+
!pip install opencv-python
|
33 |
+
!pip install modelscope==1.12.0
|
34 |
+
!pip install datasets==2.14.7
|
35 |
+
!pip install pillow
|
36 |
+
!pip install numpy
|
37 |
+
!pip install gradio-imageslider
|
38 |
+
```
|
39 |
+
|
40 |
+
---
|
41 |
+
|
42 |
+
## Usage
|
43 |
+
|
44 |
+
You can easily use **MakeItColor** through the ModelScope pipeline:
|
45 |
+
|
46 |
+
```python
|
47 |
+
import cv2
|
48 |
+
from modelscope.pipelines import pipeline
|
49 |
+
from modelscope.utils.constant import Tasks
|
50 |
+
|
51 |
+
# Initialize the colorization pipeline
|
52 |
+
img_colorization = pipeline(Tasks.image_colorization, model='your-username/makeitcolor')
|
53 |
+
|
54 |
+
# Load a grayscale image
|
55 |
+
img_path = 'input.jpg'
|
56 |
+
|
57 |
+
# Run colorization
|
58 |
+
result = img_colorization(img_path)
|
59 |
+
|
60 |
+
# Save the colorized image
|
61 |
+
cv2.imwrite('result.png', result['output_img'])
|
62 |
+
```
|
63 |
+
|
64 |
+
> **Note**:
|
65 |
+
> - Ensure that the input image (`input.jpg`) is a proper grayscale (single-channel) image.
|
66 |
+
> - The output (`result.png`) will be a standard RGB image.
|
67 |
+
|
68 |
+
---
|
69 |
+
|
70 |
+
## Model Files
|
71 |
+
|
72 |
+
The repository contains the following files:
|
73 |
+
|
74 |
+
- `pytorch_model.pt`: Pre-trained model weights.
|
75 |
+
- `configuration.json`: Model configuration file for ModelScope integration.
|
76 |
+
- `README.md`: This documentation file.
|
77 |
+
|
78 |
+
---
|
79 |
+
|
80 |
+
## Inference Requirements
|
81 |
+
|
82 |
+
- **Hardware**:
|
83 |
+
- CPU (supported)
|
84 |
+
- GPU (recommended for faster inference)
|
85 |
+
|
86 |
+
- **Software Dependencies**:
|
87 |
+
- `modelscope`
|
88 |
+
- `opencv-python`
|
89 |
+
- `torch`
|
90 |
+
|
91 |
+
---
|
92 |
+
|
93 |
+
## Input Format
|
94 |
+
|
95 |
+
- Grayscale images (`.png`, `.jpg`, etc.)
|
96 |
+
|
97 |
+
### Example
|
98 |
+
|
99 |
+
1. Prepare a grayscale image (e.g., `input.jpg`).
|
100 |
+
2. Run the provided example code.
|
101 |
+
3. Check the output file (`result.png`) for the colorized result.
|
102 |
+
|
103 |
+
---
|
104 |
+
|
105 |
+
## Limitations
|
106 |
+
|
107 |
+
- The model may struggle with highly complex, ambiguous, or abstract grayscale images.
|
108 |
+
- Performance and output quality depend on the clarity and details of the input.
|
109 |
+
- Primarily optimized for **natural images**; results may vary for synthetic or artistic inputs.
|
110 |
+
|
111 |
+
---
|
112 |
+
|
113 |
+
## Credits
|
114 |
+
|
115 |
+
This work builds upon and was inspired by the [DDColor project](https://github.com/piddnad/DDColor).
|
116 |
+
**MakeItColor** leverages a dual-encoder strategy from DDColor and is trained on the **ImageNet-Val5k** dataset.
|
117 |
+
|
118 |
+
Special thanks to the creators of DDColor for their foundational contributions.
|
119 |
+
|
120 |
+
---
|
121 |
+
|
122 |
+
## License
|
123 |
+
|
124 |
+
This project is licensed under the **Apache License 2.0**.
|
125 |
+
|
126 |
+
---
|
127 |
+
|
128 |
+
## Contact
|
129 |
+
|
130 |
+
For issues, questions, or feedback, feel free to:
|
131 |
+
|
132 |
+
- Open an issue on the [Hugging Face repository](#).
|
133 |
+
- Contact the maintainer directly at: **[[email protected]](mailto:[email protected])**
|
134 |
+
|
135 |
+
---
|
136 |
+
|
137 |
+
**Developed by Muhammad Noman**
|
configuration.json
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"framework": "pytorch",
|
3 |
+
|
4 |
+
"task": "image-colorization",
|
5 |
+
|
6 |
+
"pipeline": {
|
7 |
+
"type": "ddcolor-image-colorization"
|
8 |
+
},
|
9 |
+
|
10 |
+
"model": {
|
11 |
+
"type": "ddcolor"
|
12 |
+
},
|
13 |
+
|
14 |
+
"dataset": {
|
15 |
+
"name": "imagenet-val5k-image",
|
16 |
+
"dataroot_gt": "val5k/",
|
17 |
+
"filename_tmpl": "{}",
|
18 |
+
"scale": 1,
|
19 |
+
"gt_size": 256
|
20 |
+
},
|
21 |
+
|
22 |
+
"train": {
|
23 |
+
"dataloader": {
|
24 |
+
"batch_size_per_gpu": 4,
|
25 |
+
"workers_per_gpu": 4,
|
26 |
+
"shuffle": true
|
27 |
+
},
|
28 |
+
"optimizer": {
|
29 |
+
"type": "AdamW",
|
30 |
+
"lr": 1e-6,
|
31 |
+
"weight_decay": 0.01,
|
32 |
+
"betas": [0.9, 0.99]
|
33 |
+
},
|
34 |
+
"lr_scheduler": {
|
35 |
+
"type": "CosineAnnealingLR",
|
36 |
+
"T_max": 200000,
|
37 |
+
"eta_min": 1e-7
|
38 |
+
},
|
39 |
+
"max_epochs": 2,
|
40 |
+
"hooks": [{
|
41 |
+
"type": "CheckpointHook",
|
42 |
+
"interval": 1
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"type": "TextLoggerHook",
|
46 |
+
"interval": 1
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"type": "IterTimerHook"
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"type": "EvaluationHook",
|
53 |
+
"interval": 1
|
54 |
+
}
|
55 |
+
]
|
56 |
+
},
|
57 |
+
|
58 |
+
"evaluation": {
|
59 |
+
"dataloader": {
|
60 |
+
"batch_size_per_gpu": 8,
|
61 |
+
"workers_per_gpu": 1,
|
62 |
+
"shuffle": false
|
63 |
+
},
|
64 |
+
"metrics": "image-colorization-metric"
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
pytorch_model.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:17c460d7e55b32a598370621d77173be59e03c24b0823f06821db23a50c263ce
|
3 |
+
size 911950059
|