https://github.com/nevrohelios/deep-viz
๐ฌ Deep-Viz: Unveiling the Black Box of Deep Learning
https://github.com/nevrohelios/deep-viz
captum opencv pytorch streamlit torchvision
Last synced: 3 months ago
JSON representation
๐ฌ Deep-Viz: Unveiling the Black Box of Deep Learning
- Host: GitHub
- URL: https://github.com/nevrohelios/deep-viz
- Owner: NevroHelios
- Created: 2025-06-25T07:54:49.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-26T19:09:28.000Z (12 months ago)
- Last Synced: 2025-06-26T20:20:37.444Z (12 months ago)
- Topics: captum, opencv, pytorch, streamlit, torchvision
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฌ Deep-Viz: Unveiling the Black Box of Deep Learning



*"Seeing is believing, but understanding is enlightening"* ๐ง โจ
## ๐ What is Deep-Viz?
Deep-Viz is an interactive web application that makes AI interpretability accessible to everyone! Ever wondered what a neural network "sees" when it looks at an image? This tool pulls back the curtain on deep learning models, revealing the hidden patterns and decision-making processes that drive AI predictions.
## ๐ฏ Features
### ๐ **Model Interpretability Made Simple**
- **Class Activation Maps (CAM)** using SmoothGradCAM++ ๐จ
- **Integrated Gradients** for pixel-level feature attribution ๐
- **Real-time visualization** of model predictions ๐
- **Multi-model support** (ResNet18 & ResNet50) โ๏ธ
### ๐จ **Interactive Experience**
- **Drag-and-drop** image upload ๐ค
- **Layer-wise exploration** of neural network activations ๐ฌ
- **Top-5 predictions** with confidence scores ๐
- **Side-by-side comparison** of different visualization techniques ๐
## ๐ง How It Works
```mermaid
graph TD
A[๐ท Upload Image] --> B[๐ Preprocessing]
B --> C[๐ค ResNet Model]
C --> D[๐ Predictions]
C --> E[๐จ SmoothGradCAM++]
C --> F[๐ Integrated Gradients]
D --> G[๐ Top-5 Results]
E --> H[๐บ๏ธ Class Activation Map]
F --> I[โก Attribution Heatmap]
G --> J[๐ฑ Interactive Dashboard]
H --> J
I --> J
style A fill:#ff6b6b
style C fill:#4ecdc4
style J fill:#45b7d1
```
## ๐ Quick Start
### Prerequisites
Make sure you have Python 3.7+ installed on your system.
### Installation
1. **Clone the repository**
```bash
git clone https://github.com/nevrohelios/deep-viz.git
cd deep-viz
```
2. **Install dependencies**
```bash
pip install -r requirements.txt
```
3. **Launch the application**
```bash
streamlit run main.py
```
4. **Open your browser** and navigate to `http://localhost:8501` ๐
## ๐ Understanding the Visualizations
### ๐จ Class Activation Maps (CAM)
CAMs highlight the regions in an image that are most important for the model's prediction. Think of it as the model's "attention map" - where is it looking when making decisions?
```
๐ผ๏ธ Original Image โ ๐ฅ Heat Map โ ๐ฏ Important Regions
```
### โก Integrated Gradients
This technique provides pixel-level attributions, showing how much each pixel contributes to the final prediction. It's like having X-ray vision into the model's decision process!
```
๐ Pixel Analysis โ ๐ Attribution Scores โ ๐จ Visualization
```
## ๐ง Technical Architecture
### ๐ฆ Core Components
| Component | Purpose | Technology |
|-----------|---------|------------|
| ๐จ **Frontend** | Interactive UI | Streamlit |
| ๐ค **Model Backend** | Deep Learning | PyTorch + TorchVision |
| ๐ **Interpretability** | CAM Generation | TorchCAM |
| โก **Attribution** | Gradient Analysis | Captum |
| ๐ผ๏ธ **Image Processing** | Preprocessing | PIL + Transforms |
### ๐๏ธ Model Architecture
```
Input Image (224ร224ร3)
โ
ResNet18/50 Backbone
โ
Feature Extraction
โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ CAM Extraction โ Gradient Flow โ
โ (TorchCAM) โ (Captum) โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
โ
Visualization Pipeline
โ
Interactive Dashboard
```
## ๐ฎ Usage Examples
### ๐ Example 1: Animal Classification
Upload a photo of your pet and see which features the model uses to identify the animal!
### ๐๏ธ Example 2: Scene Understanding
Try landscape photos to understand how the model recognizes different environments.
### ๐ Example 3: Object Detection
Upload images with vehicles to see how the model focuses on distinctive features.
## ๐ฌ Advanced Features
### ๐๏ธ **Layer Selection**
Explore different layers of the neural network to understand how features evolve from simple edges to complex patterns:
- **Early Layers**: Edge detection, basic shapes ๐
- **Middle Layers**: Textures, patterns ๐
- **Deep Layers**: Complex objects, semantic features ๐๏ธ
### ๐ **Model Comparison**
Switch between ResNet18 and ResNet50 to see how model depth affects interpretation:
| Model | Parameters | Speed | Accuracy |
|-------|------------|-------|----------|
| ResNet18 | 11.7M | โก Fast | ๐ฏ Good |
| ResNet50 | 25.6M | ๐ Slower | ๐ฏ Better |
## ๐ฎ What Makes This Special?
### ๐จ **Visual Excellence**
- Clean, intuitive interface designed for both beginners and experts
- Real-time processing with smooth animations
- High-quality visualizations that reveal model insights
### ๐งช **Educational Value**
- Perfect for students learning about AI interpretability
- Demonstrates cutting-edge explainable AI techniques
- Bridges the gap between theory and practice
### ๐ **Production Ready**
- Robust error handling and user feedback
- Optimized for performance
- Extensible architecture for adding new models
## ๐ ๏ธ Dependencies
```python
# Core ML Framework
torch # PyTorch deep learning framework
torchvision # Computer vision utilities
torchcam # Class Activation Mapping
# Interpretability
captum # Model interpretability library
# Web Framework
streamlit # Interactive web applications
# Image Processing
pillow # Python Imaging Library
numpy # Numerical computing
matplotlib # Plotting library
```
## ๐ Future Enhancements
- [ ] ๐ฏ **More Models**: Add support for Vision Transformers, EfficientNet
- [ ] ๐จ **Advanced Visualizations**: GradCAM, LIME, SHAP
- [ ] ๐ฑ **Mobile Support**: Responsive design for mobile devices
- [ ] ๐ **API Integration**: REST API for programmatic access
- [ ] ๐ฅ **Video Analysis**: Extend to video classification
- [ ] ๐ **Multi-language**: Support for multiple languages
## ๐ค Contributing
We welcome contributions! Whether it's:
- ๐ Bug fixes
- โจ New features
- ๐ Documentation improvements
- ๐จ UI/UX enhancements
Please feel free to open issues and pull requests!
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- **PyTorch Team** for the amazing deep learning framework ๐ฅ
- **Streamlit** for making web apps incredibly simple ๐
- **Captum** for state-of-the-art interpretability tools ๐
- **TorchCAM** for excellent CAM implementations ๐จ
---
**Made with โค๏ธ and lots of โ**
*Star โญ this repo if you found it helpful!*