File size: 1,766 Bytes
a0d575e 0675bbd |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
---
license: mit
tags:
- image-colorization
- pytorch
model_name: Simple Colorizer
library_name: pytorch
---
# 🎨 Simple Colorizer - Image Colorization Model
This repository contains a PyTorch-trained U-Net model that automatically colorizes grayscale images.
---
## 📂 Repository Contents
- `best_colorization_model.pth`: Trained model weights
- `model.py`: The `ImprovedUNet` architecture definition
- `README.md`: This file
---
## 🚀 Usage Example
### 1️⃣ Install Dependencies
```python
pip install -r requirements.txt
```
### 2️⃣ Load the Model
```python
import torch
from model import ImprovedUNet
```
# Create the model instance
```python
model = ImprovedUNet()
# Load the weights
checkpoint = torch.load("best_colorization_model.pth", map_location="cpu")
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
```
### 3️⃣ Colorize an Image
```python
from PIL import Image
import torchvision.transforms as T
img = Image.open("path/to/grayscale_image.jpg").convert("L")
transform = T.Compose([
T.Resize((256, 256)),
T.ToTensor(),
T.Normalize(mean=[0.5], std=[0.5])
])
input_tensor = transform(img).unsqueeze(0)
with torch.no_grad():
output = model(input_tensor)
output_image = output.squeeze(0).permute(1, 2, 0).numpy()
output_image = (output_image * 255).clip(0, 255).astype("uint8")
Image.fromarray(output_image).save("colorized_output.png")
```
ℹ️ Training Information
Architecture: Custom U-Net (ImprovedUNet)
Input Size: 256x256 pixels
Optimizer: Adam
Loss Function: MSE
Epochs: [Specify the number of epochs]
📈 Results
Here is an example of an image colorized by the model:

✨ Author
This model was developed by Eric Houzelle. |