An end-to-end image classification pipeline that combines ๐งฑ Custom CNN, ๐ Transfer Learning, and ๐ญ Vision Transformer models - enhanced with ๐งฉ Explainable AI (XAI) visualizations and deployed in a Streamlit app.
This repository contains the complete project for building and explaining a full image classification pipeline. The pipeline moves from a hand-crafted CNN baseline to state-of-the-art deep learning models, enriched with Explainable AI (XAI) methods, and deployed as an interactive Streamlit web app.
- ๐ Data Preparation โ Exploratory analysis, class balance checks, preprocessing, and augmentations.
- ๐งฑ Custom CNN (CitrusNet) โ Novel convolutional network designed and trained from scratch.
- ๐ Transfer Learning โ Fine-tuning four pretrained CNN backbones (ImageNet weights).
- ๐ญ Vision Transformer (ViT) โ Transformer-based classifier for advanced performance.
- ๐งฉ XAI (Explainability) โ Applying Grad-CAM, Score-CAM, LIME, and SHAP to interpret predictions.
- ๐ Streamlit App โ User-friendly interface for image upload, prediction, and interactive XAI visualizations.
- ๐งฑ Custom Made CNN [CitrusNet] with โฅ65% accuracy (baseline target).
- ๐ Transfer learning with four unique CNN architectures.
- ๐ญ Vision Transformer experiment.
- ๐ Comparative evaluation (accuracy, precision, recall, F1, confusion matrices).
- ๐งฉ XAI overlays on โฅ10 test images with detailed interpretation.
- ๐ Streamlit app for model selection, predictions, and side-by-side explanations.
| Model | Training Type | Test Accuracy | Macro F1 | Notes |
|---|---|---|---|---|
| EfficientNet-B0 | Transfer Learning | Highest (reported best) | Highest | Selected for XAI & deployment |
| ResNet34 | Transfer Learning | Slightly lower than EfficientNet | High | Very stable baseline |
| ConvNeXt-Tiny | Transfer Learning | Comparable to ResNet | High | Heavier, no clear gain |
| CitrusNet (Proposed) | From Scratch | ~97% | ~0.97 | Excellent for custom CNN |
| DenseNet121 | Transfer Learning | Lower than ResNet | Moderate | Less stable |
| ViT-B/16 | Transformer | Lowest | Lowest | Data-limited underperformance |
- Python (PyTorch, torchvision, scikit-learn, Captum, pytorch-grad-cam, LIME)
- Streamlit for deployment
- Matplotlib / Seaborn for plots
- Google Colab / Kaggle GPU for training
- I used the Citrus Fruit Dataset containing high-quality images of citrus fruits for training, validation, and testing.
-
๐ Scientific Project Report (IEEE/ACM style).
-
๐ฆ 6 Runnable Jupiter Notebook Code.
-
๐พ 6 Trained Model Weights.
- CitrusNet_[custom_cnn].pt
- Efficientnet_B0.pt
- Resnet34.pt
- Densenet121.pt
- Convnext_Tiny.pt
- VIT_Best.pt
-
Open the live application [No installation required]
๐ Citrus Fruit Classification -
From the left sidebar:
- Select a model: (Best Model Used)
- CitrusNet [Custom]
- EfficientNet-B0 [Best]
- ResNet34
- or Upload your own
.ptmodel
- Upload one or more citrus fruit images (
.jpg,.png)
- Select a model: (Best Model Used)
-
View the results:
- Predicted fruit class
- Confidence score
- Grad-CAM visual explanations
- Optional LIME explanations
- This app is styled for Dark mode. Light theme may hide some UI elements.
- Change via [Right Side โฎ โ Settings โ App Theme โ Dark].
git clone https://github.com/Shourav-Deb/Citrus-Net.git
cd Citrus-Net
pip install -r requirements.txt
streamlit run app.pyIf you need the trained notebook, models or report file for academic purposes, feel free to Contact Anytime.
- Built with PyTorch, torchvision, scikit-learn, pytorch-grad-cam, LIME, and Streamlit.
- Inspired by cutting-edge research in Computer Vision & Explainable AI (XAI).
