Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- pytorch
|
| 6 |
+
- unet
|
| 7 |
+
- image-generation
|
| 8 |
+
- computer-vision
|
| 9 |
+
- conditional-generation
|
| 10 |
+
- polygon-coloring
|
| 11 |
+
library_name: torch
|
| 12 |
+
pipeline_tag: image-to-image
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Colored Polygon UNet
|
| 16 |
+
|
| 17 |
+
## Model Description
|
| 18 |
+
|
| 19 |
+
This is a conditional UNet model trained to generate colored polygon images. Given a grayscale/outline polygon image and a color specification, the model generates a colored version of the polygon.
|
| 20 |
+
|
| 21 |
+
### Supported Colors
|
| 22 |
+
- Blue, Cyan, Green, Magenta, Orange, Purple, Red, Yellow
|
| 23 |
+
|
| 24 |
+
### Model Architecture
|
| 25 |
+
- **Base**: Conditional UNet with color embedding
|
| 26 |
+
- **Input Size**: 128x128 pixels
|
| 27 |
+
- **Color Embedding**: 32 dimensions
|
| 28 |
+
- **Features**: 64 base features
|
| 29 |
+
|
| 30 |
+
### Training Details
|
| 31 |
+
- **Framework**: PyTorch
|
| 32 |
+
- **Loss Function**: Combined MSE + L1 Loss
|
| 33 |
+
- **Optimizer**: Adam (lr=0.0001)
|
| 34 |
+
- **Batch Size**: 8
|
| 35 |
+
- **Epochs**: 20
|
| 36 |
+
|
| 37 |
+
## Usage
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
from huggingface_hub import hf_hub_download
|
| 42 |
+
|
| 43 |
+
# Download model
|
| 44 |
+
model_path = hf_hub_download(
|
| 45 |
+
repo_id="your_username/colored-polygon-unet",
|
| 46 |
+
filename="best_model.pth"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
# Load checkpoint
|
| 50 |
+
checkpoint = torch.load(model_path, map_location='cpu')
|
| 51 |
+
|
| 52 |
+
# Initialize model (you'll need the model architecture code)
|
| 53 |
+
model = ConditionalUNet(
|
| 54 |
+
in_channels=3,
|
| 55 |
+
out_channels=3,
|
| 56 |
+
features=64,
|
| 57 |
+
num_colors=8,
|
| 58 |
+
color_embed_dim=32
|
| 59 |
+
)
|
| 60 |
+
model.load_state_dict(checkpoint['model_state_dict'])
|
| 61 |
+
model.eval()
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## Performance
|
| 65 |
+
- Trained on Kaggle with GPU acceleration
|
| 66 |
+
- Typical PSNR: 25-35 dB
|
| 67 |
+
- Fast inference: ~0.1s per image
|
| 68 |
+
|
| 69 |
+
## Limitations
|
| 70 |
+
- Fixed 128x128 input size
|
| 71 |
+
- Limited to 8 predefined colors
|
| 72 |
+
- Works best with simple polygon shapes
|