File size: 1,742 Bytes
e11dfae 8f10035 e11dfae ab89933 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae ea26232 e11dfae 8f10035 | 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 | ---
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 |