Skip to content

Vani691/EnvisionAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩻 EnvisionAI: Enterprise Radiology Diagnostics

Python TensorFlow FastAPI Streamlit

An enterprise-grade, end-to-end Deep Learning system designed to analyze Chest X-Rays, detect 6 distinct pulmonary pathologies, and provide Explainable AI (XAI) visualizations alongside automated clinical reporting.

EnvisionAI Dashboard

The EnvisionAI Clinical Dashboard predicting Emphysema with 93.7% confidence and Grad-CAM localization.


🌟 Key Features

  • Multi-Class Pathology Detection: Highly accurate classification across 6 categories: Covid-19, Emphysema, Normal, Pneumonia (Bacterial), Pneumonia (Viral), and Tuberculosis.
  • Deep Transfer Learning: Built upon Google's highly optimized MobileNetV2 architecture, fine-tuned specifically for complex radiological textures.
  • Explainable AI (Grad-CAM): Eliminates the "black box" of AI by generating high-resolution heatmaps that highlight the exact biological focal points driving the model's predictions.
  • Enterprise Clinical Dashboard: A highly responsive Streamlit frontend that simulates a real-world hospital charting system.
  • Automated Clinical Reporting: Dynamically generates context-aware medical reports based on confidence intervals and secondary differential diagnoses.

🧠 System Architecture

The project is structured around a decoupled microservice architecture, utilizing FastAPI for high-speed neural network inference and Streamlit for the clinical interface.

graph TD
    subgraph Frontend [Clinical Dashboard - Streamlit]
        A[Radiologist Uploads X-Ray] --> B{EnvisionAI UI}
        B --> |Displays Results| Z[Final Diagnostics & Report]
    end

    subgraph Backend [Inference Server - FastAPI]
        B -- HTTP POST (Image) --> C[FastAPI Endpoint]
        C --> D[Image Preprocessing & Normalization]
    end

    subgraph Core AI [Deep Learning Engine - TensorFlow]
        D -- Float32 Array --> E[MobileNetV2 Base Model]
        E --> |Feature Extraction| F[Dense Classification Head]
        F --> |Softmax Array| G[Class Probabilities]
        
        E -.-> |Gradient Tape| H[Grad-CAM Generator]
        H --> |Heatmap Matrix| I[OpenCV Image Overlay]
    end

    G -.-> |JSON Payload| B
    I -.-> |Heatmap Image| B

Loading

🚀 Model Training & Fine-Tuning Pipeline

This model overcomes standard medical dataset limitations (such as class imbalance and feature memorization) using a rigorous, two-phase training protocol:

  1. Data Preprocessing: Images are resized to 256x256x3 (RGB) and subjected to dynamic data augmentation (Zoom, Rotation, Flip). Scikit-Learn Class Weights were calculated and applied to heavily penalize the model for missing rare diseases.

  2. Phase 1 (Feature Extraction): The base MobileNetV2 layers were frozen. Only the custom dense classification head was trained to map basic features to the 6 pathology classes.

  3. Phase 2 (Fine-Tuning): The top 54 layers of MobileNetV2 were unfrozen and trained with a microscopic learning rate (1e-5). This allowed the model's internal convolutional lenses to transition from detecting generic shapes to identifying highly specific biological lung textures.

  • Final Validation Accuracy: ~75.8% (Highly competitive for a 6-class, complex medical dataset).

💻 Installation & Usage

  1. Clone the Repository Bash git clone https://github.com/Vani691/EnvisionAI.git cd EnvisionAI
  2. Set Up Virtual Environment & Install Dependencies Bash python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate pip install -r requirements.txt
  3. Run the Backend API (Terminal 1) This initializes the FastAPI server and loads the fine-tuned .h5 model into memory.

Bash uvicorn api.main:app --reload 4. Run the Clinical Dashboard (Terminal 2) This launches the interactive Streamlit user interface in your web browser.

Bash streamlit run app/streamlit_app.py


📂 Project Structure

EnvisionAI/
│
├── api/
│   └── main.py                 # FastAPI backend endpoints
├── app/
│   └── streamlit_app.py        # Streamlit frontend & UI logic
├── models/
│   └── model_finetuned.h5      # Final saved deep learning model
├── src/
│   ├── data_loader.py          # TF dataset prep & augmentation
│   ├── train.py                # Phase 1: Transfer learning script
│   ├── finetune.py             # Phase 2: Unfreezing and fine-tuning
│   ├── predict.py              # Prediction & preprocessing logic
│   └── gradcam.py              # Explainable AI heatmap generation
├── outputs/
│   ├── heatmaps/               # Saved Grad-CAM overlays
│   └── comparisons/            # Training loss/accuracy JSONs & UI screens
└── README.md

⚠️ Disclaimer

  • This application is an AI prototype built strictly for educational, research, and portfolio purposes. It is not an FDA-approved medical device and must not be used for actual diagnostic or clinical decision-making without the direct supervision of a licensed medical professional.

👩‍💻 Developer

Shravani Mane | CSE-AIML Student

About

An enterprise-grade Deep Learning system for Chest X-Ray analysis. Detects 6 pulmonary pathologies using MobileNetV2 Transfer Learning, featuring a FastAPI backend, Streamlit clinical dashboard, and Explainable AI (Grad-CAM) visualizations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages