Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: "Optimised Mosaic Generator"
|
| 3 |
+
emoji: 🧩
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "4.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# ⚡ Optimised Mosaic Generator (Lab 5)
|
| 13 |
+
A high-performance image mosaic generator built using FAISS, OpenCV, and LAB color matching.
|
| 14 |
+
20×–100× faster than the baseline (Lab 1) implementation.
|
| 15 |
+
|
| 16 |
+
## 🚀 Features
|
| 17 |
+
- **FAISS-accelerated nearest neighbor search**
|
| 18 |
+
- **Up to 20,000 CIFAR-100 tiles**
|
| 19 |
+
- **LAB color space matching**
|
| 20 |
+
- **OpenCV fast tile resizing**
|
| 21 |
+
- **Efficient tile caching (baked into the Space after first run)**
|
| 22 |
+
- **MSE + SSIM quality metrics**
|
| 23 |
+
- **Beautiful Gradio interface**
|
| 24 |
+
|
| 25 |
+
## 🧠 How it works
|
| 26 |
+
1. Input image is cropped to fit the chosen grid size
|
| 27 |
+
2. Convert image to LAB and compute mean color per cell
|
| 28 |
+
3. Preprocess 10k–20k CIFAR tiles
|
| 29 |
+
4. Find the best tile match for each cell using FAISS L2 search
|
| 30 |
+
5. Assemble final mosaic in optimized NumPy format
|
| 31 |
+
6. Compute MSE/SSIM and render output
|
| 32 |
+
|
| 33 |
+
## 📦 Technologies Used
|
| 34 |
+
- Python
|
| 35 |
+
- Gradio
|
| 36 |
+
- NumPy
|
| 37 |
+
- OpenCV
|
| 38 |
+
- FAISS
|
| 39 |
+
- Hugging Face Datasets
|
| 40 |
+
- CIFAR-100 tiles
|
| 41 |
+
- PIL (Pillow)
|
| 42 |
+
|
| 43 |
+
## 🛠️ Options
|
| 44 |
+
- Grid sizes: **16 / 32 / 64 / 128**
|
| 45 |
+
- Tile sizes: **8px / 16px / 24px / 32px**
|
| 46 |
+
- Tile bank size: **up to 20,000 tiles**
|
| 47 |
+
- Optional color quantization
|
| 48 |
+
- Show/hide grid overlay
|
| 49 |
+
|
| 50 |
+
## 📈 Performance
|
| 51 |
+
This version is dramatically faster than Lab 1:
|
| 52 |
+
- Vectorized implementation → 5× speedup
|
| 53 |
+
- FAISS + OpenCV implementation → **20–100× speedup**
|
| 54 |
+
- Memory-efficient tile caching
|
| 55 |
+
- Fast, interactive UI
|
| 56 |
+
|
| 57 |
+
## 🖼️ Example
|
| 58 |
+
Try uploading any portrait, landscape, or artwork to see mosaic results instantly.
|
| 59 |
+
|
| 60 |
+
## 📄 License
|
| 61 |
+
MIT License
|
| 62 |
+
© 2025 Saumith Devarsetty
|