How kaushik410/self_supervised_low_light_enhancer works
Project type and purpose
• This is a self-supervised, deep-learning-powered image enhancement web app.
• It lets end users upload low-light images via a Streamlit interface, applies Retinex preprocessing and a deep residual autoencoder with attention, then returns an enhanced image plus quality metrics and visualizations.
File structure
• app.py: Streamlit UI + orchestration (frontend + controller)
• enhancer.py: core enhancement logic (Retinex + model definition + training/inference loops)
• metrics.py: image-quality metric computations and visualizations (noise map, histograms, etc.)
• requirements.txt: Python dependencies (torch, streamlit, numpy, OpenCV, etc.)
README for additional insights
• Confirms usage of GPU if available (torch.cuda)
• Caches processed images to avoid redundant training
• No pretrained weights; model is trained on-the-fly per image
• Outputs NIQE, PIQE, MS-SSIM, VIF scores and visual artifacts (edge maps, frequency spectra)
a. Main components
1. User Interface (Streamlit front-end)
2. Orchestrator / Controller (app.py logic)
3. Image Preprocessing (Retinex module in enhancer.py)
4. Deep Enhancement Engine (residual autoencoder + attention in enhancer.py)
5. Metrics & Visualization Engine (metrics.py)
6. Caching Layer (Streamlit cache or on-disk storage)
7. GPU/Compute Resource (optional torch.cuda)
8. External Libraries & Frameworks (Torch, Streamlit, OpenCV, NumPy)
b. Relationships & data flow
1. User uploads an image via Streamlit UI →
2. Controller checks cache →
• if hit → load enhanced image & metrics → display
• if miss → send raw image to Preprocessing
3. Preprocessing (Retinex) → output normalized image →
4. Enhancement Engine (train/infer autoencoder) → enhanced image →
5. Metrics & Visualization Engine → compute NIQE, PIQE, MS-SSIM, VIF + generate noise & edge maps, histograms →
6. Controller aggregates results →
7. Streamlit displays enhanced image + metric scores + visualizations →
8. Optionally write to cache
c. Architectural patterns & design principles
• Layered architecture: UI layer, application/controller layer, domain logic (preprocessing + model + metrics), caching/infrastructure layer
• On-demand compute: dynamic model training per request
• Separation of concerns:
• app.py (I/O + orchestration)
• enhancer.py (image-processing + model)
• metrics.py (quality metrics + plotting)
d. Key technologies & libraries
• Python 3.x, Streamlit (UI)
• PyTorch (model training/inference)
• OpenCV / NumPy (image operations)
• Streamlit cache decorator or custom on-disk cache
• GPU acceleration via torch.cuda (if available)