mathaisjustin's picture
Deploy Fish Disease Detection AI
fbbdeab

A newer version of the Gradio SDK is available: 6.1.0

Upgrade
metadata
title: Fish Disease Detection AI
emoji: 🐟
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.7.1
app_file: app.py
pinned: false
license: mit
tags:
  - computer-vision
  - deep-learning
  - vgg16
  - fish-disease
  - grad-cam
  - explainable-ai
  - medical-imaging

🐟 Fish Disease Detection AI

Python PyTorch Gradio License

AI-powered fish disease detection system combining VGG16 CNN, Grad-CAM explainability, and Gemini AI for comprehensive diagnosis and treatment recommendations.


🎯 Key Features

πŸŽ“ High Accuracy

  • 98.65% test accuracy on 8 fish disease classes
  • Trained on 5,000+ annotated images
  • Robust to various image conditions

πŸ”¬ Explainable AI

  • Grad-CAM heatmap visualization shows exactly where the model is looking
  • Highlights disease-relevant areas (lesions, discoloration, abnormalities)
  • Builds trust through transparency

πŸ€– AI-Powered Treatment

  • Google Gemini 2.0 generates disease-specific treatment protocols
  • Immediate actions, medication recommendations, and preventive measures
  • Expected recovery rates and timelines

⚑ Real-Time Performance

  • ~2-3 second inference on GPU
  • Supports batch processing
  • Web-based interface accessible anywhere

🦠 Detected Diseases

Disease Description Severity
Aeromoniasis Bacterial infection causing hemorrhaging High
Bacterial Gill Disease Respiratory issues, gill damage High
Bacterial Red Disease External lesions and ulcers Medium
EUS Epizootic Ulcerative Syndrome Critical
Healthy Fish No disease detected None
Parasitic Diseases External/internal parasites Medium
Saprolegniasis Fungal Fungal infection (cotton-like growth) Medium
Viral White Tail Viral infection affecting tail High

πŸš€ How to Use

1️⃣ Upload Image

Upload a clear, well-lit photo of your fish (JPG/PNG, max 10MB)

2️⃣ Analyze

Click "Analyze Fish" button for instant diagnosis

3️⃣ Review Results

  • Disease prediction with confidence score
  • Probability breakdown for all 8 diseases
  • Grad-CAM heatmap showing model focus areas
  • AI treatment recommendations with detailed protocols

πŸ“Š Model Architecture

Input Image (224Γ—224 RGB) ↓ VGG16 Backbone (Pretrained on ImageNet) ↓ Feature Extraction (4096-dim) ↓ Custom Classification Head ↓ 8-Class Softmax Output ↓ Grad-CAM Activation Mapping

Technical Specifications:

  • Base Model: VGG16 (transfer learning)
  • Input Size: 224Γ—224 pixels
  • Normalization: ImageNet mean/std
  • Framework: PyTorch 2.5.1
  • Device: CUDA/CPU compatible

πŸ“ˆ Performance Metrics

Metric Score
Test Accuracy 98.65%
Precision (avg) 98.2%
Recall (avg) 98.1%
F1-Score (avg) 98.15%
Training Samples 5,000+
Validation Samples 1,000+
Test Samples 500+

🎯 Confidence Thresholds

The system uses a 70% confidence threshold for reliable diagnoses:

  • β‰₯ 80% - 🟒 High confidence (Very reliable)
  • 70-79% - 🟑 Good confidence (Reliable)
  • < 70% - πŸ”΄ Low confidence (Requires verification)

When confidence is below 70%, the system:

  • Shows top 3 disease candidates
  • Provides general guidelines
  • Recommends professional consultation

πŸ”¬ Grad-CAM Visualization

Understanding the Heatmap:

  • πŸ”΄ Red areas - High importance (disease symptoms, lesions)
  • 🟑 Yellow areas - Moderate importance
  • 🟒 Green/Blue areas - Low importance

The heatmap proves the model focuses on actual pathological features, not spurious correlations.


πŸ› οΈ Technical Details

Dependencies

torch==2.5.1 torchvision==0.20.1 gradio==5.7.1 google-generativeai==0.8.3 pillow==11.0.0 opencv-python-headless==4.10.0.84 numpy==1.26.4 python-dotenv==1.0.0

Environment Setup

This application requires a Gemini API key for treatment recommendations. Set it as an environment variable:

GEMINI_API_KEY=your_api_key_here


⚠️ Medical Disclaimer

This is an AI diagnostic tool for preliminary screening only.

βœ… Use For:

  • Initial disease screening
  • Educational purposes
  • Research and development
  • Aquaculture monitoring

❌ Do NOT Use For:

  • Definitive medical diagnosis
  • Treatment without professional consultation
  • Emergency veterinary decisions

Always consult a qualified aquaculture veterinarian for:

  • Professional diagnosis confirmation
  • Treatment plan approval
  • Medication dosage recommendations
  • Emergency health situations

πŸŽ“ Research & Citation

This project is part of research on AI-assisted aquaculture diagnostics and explainable deep learning.

BibTeX Citation:

@software{fish_disease_detection_2025, author = {Justin Mathais}, title = {Fish Disease Detection AI: VGG16 with Grad-CAM Explainability}, year = {2025}, url = {https://github.com/YOUR_USERNAME/fish-disease-detection} }


πŸ“§ Contact & Support


πŸ“œ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ™ Acknowledgments

  • VGG16 Architecture: Simonyan & Zisserman (Paper)
  • Grad-CAM: Selvaraju et al. (Paper)
  • Google Gemini AI: Treatment recommendation generation
  • PyTorch Community: Deep learning framework
  • Gradio: Web interface framework

🌟 Star History

If this project helped you, please consider giving it a ⭐ on GitHub!


Made with ❀️ for aquaculture health