Skip to content

๐Ÿ”ฌ Deep-Viz: Unveiling the Black Box of Deep Learning

NevroHelios/deep-viz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฌ Deep-Viz: Unveiling the Black Box of Deep Learning

Deep Learning Visualization Streamlit PyTorch

"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

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
Loading

๐Ÿš€ Quick Start

Prerequisites

Make sure you have Python 3.7+ installed on your system.

Installation

  1. Clone the repository
git clone https://github.com/nevrohelios/deep-viz.git
cd deep-viz
  1. Install dependencies
pip install -r requirements.txt
  1. Launch the application
streamlit run main.py
  1. 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

# 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 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!

About

๐Ÿ”ฌ Deep-Viz: Unveiling the Black Box of Deep Learning

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages