A newer version of the Gradio SDK is available:
6.8.0
metadata
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
- Input image is cropped to fit the chosen grid size
- Convert image to LAB and compute mean color per cell
- Preprocess 10kβ20k CIFAR tiles
- Find the best tile match for each cell using FAISS L2 search
- Assemble final mosaic in optimized NumPy format
- 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