| | --- |
| | title: Optimised Mosaic Generator |
| | emoji: π§© |
| | colorFrom: blue |
| | colorTo: purple |
| | sdk: gradio |
| | sdk_version: 5.49.1 |
| | app_file: app.py |
| | pinned: false |
| | --- |
| | |
| | # β‘ Optimised Mosaic Generator (Lab 5) |
| |
|
| | A high-performance image mosaic generator built using FAISS, OpenCV, and LAB color matching. |
| | 20Γβ100Γ faster than the baseline (Lab 1) implementation. |
| |
|
| | --- |
| |
|
| | ## π Features |
| | - FAISS-accelerated nearest neighbor search |
| | - Up to 20,000 CIFAR-100 tiles |
| | - LAB color space matching |
| | - OpenCV fast tile resizing |
| | - Efficient tile caching (baked into the Space after first run) |
| | - MSE + SSIM quality metrics |
| | - Beautiful Gradio interface |
| |
|
| | --- |
| |
|
| | ## π§ How it works |
| | 1. Input image is cropped to fit the chosen grid size |
| | 2. Convert image to LAB and compute mean color per cell |
| | 3. Preprocess 10kβ20k CIFAR tiles |
| | 4. Find the best tile match for each cell using FAISS L2 search |
| | 5. Assemble final mosaic in optimized NumPy format |
| | 6. Compute MSE/SSIM and render output |
| |
|
| | --- |
| |
|
| | ## π¦ Technologies Used |
| | - Python |
| | - Gradio |
| | - NumPy |
| | - OpenCV |
| | - FAISS |
| | - Hugging Face Datasets |
| | - CIFAR-100 tiles |
| | - PIL (Pillow) |
| |
|
| | --- |
| |
|
| | ## π οΈ Options |
| | - Grid sizes: **16 / 32 / 64 / 128** |
| | - Tile sizes: **8, 16, 24, 32 px** |
| | - Tile bank size: **up to 20,000 tiles** |
| | - Optional color quantization |
| | - Show/hide grid overlay |
| |
|
| | --- |
| |
|
| | ## π Performance |
| | This version is dramatically faster than Lab 1: |
| |
|
| | - Vectorized implementation β **5Γ speedup** |
| | - FAISS + OpenCV implementation β **20β100Γ speedup** |
| | - Memory-efficient tile caching |
| | - Fast, interactive UI |
| |
|
| | --- |
| |
|
| | ## πΌοΈ Example |
| | Try uploading any portrait, landscape, or artwork to see mosaic results instantly. |
| |
|
| | --- |
| |
|
| | ## π License |
| | MIT License |
| | Β© 2025 Saumith Devarsetty |