CoolFace
Apppublic

santosh3110/Ecoclassify-Wildlife_Classifier

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿฆ‰ EcoClassify โ€“ Wildlife Image Classifier

Python Streamlit PyTorch License

AI-powered wildlife conservation.

EcoClassify is an end-to-end computer vision project that classifies camera trap images into wildlife species using transfer learning (ResNet50). It includes model explainability (Grad-CAM), batch inference, fine-tuning via Streamlit UI, and MLflow/DagsHub integration for experiment tracking. It was born out of the need to help researchers, educators, and nature lovers quickly identify species without needing to be a machine learning wizard. This project was developed as part of my internship at Euron, with heartfelt thanks to Sudhanshu Kumar, Director of Euron, for his guidance and mentorship.

๐Ÿ”— Live Demo on Streamlit Cloud: ![Streamlit App](https://ecoclassify---wildlife-image-classifier-ojyez7lpcmvjx25vmxr95c.streamlit.app/)

๐Ÿ”— Live Demo on Hugging Face: ![Hugging Face Spaces](https://huggingface.co/spaces/santosh3110/Ecoclassify-Wildlife_Classifier)


๐Ÿ“ธ App Screenshots

Inference (Single Image)Grad-CAM Explainability
[image][image]
Batch InferenceFine-Tuning
[image][image]

๐Ÿ“– Table of Contents

  1. 1.About
  2. 2.Features
  3. 3.Architecture
  4. 4.Dataset
  5. 5.Installation
  6. 6.Usage
  7. 7.Streamlit App
  8. 8.Training & Evaluation
  9. 9.Explainability
  10. 10.Batch Inference
  11. 11.Fine-Tuning
  12. 12.Design Docs
  13. 13.Results
  14. 14.Future Work
  15. 15.Acknowledgements

๐ŸŒ About

Camera traps capture millions of images in wildlife conservation projects. Manual classification is slow, error-prone, and not scalable.

EcoClassify provides:

  • โ€”๐Ÿ”ฌ Automated species classification (7 classes + Blank).
  • โ€”๐Ÿ–ผ๏ธ Explainability dashboard (Grad-CAM heatmaps).
  • โ€”โšก Batch inference for CSV/ZIP datasets.
  • โ€”๐ŸŽ›๏ธ Fine-tuning interface for custom datasets.
  • โ€”๐Ÿ“Š MLflow/DagsHub experiment logging.

๐Ÿš€ Features

  • โ€”โœ… Species classification: Antelope_Duiker, Bird, Civet_Genet, Hog, Leopard, Monkey_Prosimian, Rodent, Blank.
  • โ€”โœ… Transfer learning with ResNet50 backbone.
  • โ€”โœ… Grad-CAM explainability for predictions.
  • โ€”โœ… Streamlit app with multiple tabs: Inference, Batch, Fine-tuning.
  • โ€”โœ… Config-driven training (YAML params & config).
  • โ€”โœ… Experiment tracking with MLflow + DagsHub.

๐Ÿ—๏ธ Architecture

System Architecture

mermaid
flowchart TD
    A[User Uploads Image] --> B[Preprocessing & Augmentation]
    B --> C[Model Inference: ResNet50]
    C --> D[Predictions: Species + Confidence ]
    C --> E[Explainability Engine: Grad-CAM]
    D & E --> F[Streamlit Dashboard: Results]
    F --> G[Download CSV / Fine-tune Model]

End-to-End Pipeline

mermaid
graph LR
    A[Data Ingestion] --> B[Data Loader]
    B --> C[Training Pipeline with MLflow Logging]
    C --> D[Evaluation of Models with MLflow Logging]
    D --> E[Batch Inference]
    E --> F[Streamlit App]
    F --> G[Model Fine Tuning]

Project Structure

.
EcoClassify---Wildlife-Image-Classifier/
โ”‚
โ”œโ”€โ”€ app.py                     # Streamlit app entry point
โ”œโ”€โ”€ main.py                    # Orchestrates full training โ†’ eval โ†’ inference pipeline
โ”œโ”€โ”€ setup.py                   # Package setup
โ”œโ”€โ”€ requirements.txt           # Dependencies
โ”œโ”€โ”€ README.md                  # Documentation
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ colab_code.ipynb           # Code for running the repo on Google Colab
โ”œโ”€โ”€ params.yaml                # Hyperparameters
โ”œโ”€โ”€ init_project_structure.py  # Script to bootstrap project tree
โ”‚
โ”œโ”€โ”€ artifacts/                 # All experiment outputs
โ”‚   โ”œโ”€โ”€ base_model/            # Initial CNN model
โ”‚   โ”œโ”€โ”€ resnet50_model/        # ResNet50 base model
โ”‚   โ”œโ”€โ”€ training/              # Trained model checkpoints
โ”‚   โ”œโ”€โ”€ prepare_callbacks/     # Callback checkpoints
โ”‚   โ”œโ”€โ”€ evaluation/            # Confusion matrices & reports
โ”‚   โ”œโ”€โ”€ explanations/          # Grad-CAM heatmaps
โ”‚   โ”œโ”€โ”€ batch_inference/       # Batch predictions
โ”‚   โ”œโ”€โ”€ data_ingestion/        # Raw & processed datasets
โ”‚   โ””โ”€โ”€ streamlit_outputs/     # Models & mappings saved from app
โ”‚
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ config.yaml            # Centralized config file
โ”‚ 
โ”œโ”€โ”€ docs/                      # Project Documents
โ”‚   โ”œโ”€โ”€ PRD.pdf                # Product Requirements & Specification Document
โ”‚   โ”œโ”€โ”€ HLD.pdf                # High Level Design Document
โ”‚   โ””โ”€โ”€ LLD.pdf                # Low Level Design Document
โ”‚
โ”œโ”€โ”€ logs/
โ”‚   โ””โ”€โ”€ running_logs.log       # Pipeline logs
โ”‚
โ”œโ”€โ”€ research/                  # Notebooks for experiments
โ”‚   โ””โ”€โ”€ experiment.ipynb
โ”‚   
โ”‚
โ””โ”€โ”€ src/ecoclassify/           # Source code (modular package)
    โ”œโ”€โ”€ components/            # Core ML components
    โ”‚   โ”œโ”€โ”€ customcnn_base_model.py
    โ”‚   โ”œโ”€โ”€ resnet50_model.py
    โ”‚   โ”œโ”€โ”€ training.py
    โ”‚   โ”œโ”€โ”€ evaluation.py
    โ”‚   โ”œโ”€โ”€ explanation_generator.py
    โ”‚   โ”œโ”€โ”€ fine_tuning.py
    โ”‚   โ”œโ”€โ”€ batch_inference.py
    โ”‚   โ”œโ”€โ”€ data_ingestion.py
    โ”‚   โ””โ”€โ”€ data_loader.py
    โ”‚
    โ”œโ”€โ”€ pipeline/              # Orchestrated stages
    โ”‚   โ”œโ”€โ”€ stage_01_data_ingestion.py
    โ”‚   โ”œโ”€โ”€ stage_02_customcnn_base_model.py
    โ”‚   โ”œโ”€โ”€ stage_03_resnet_50_model.py
    โ”‚   โ”œโ”€โ”€ stage_04_model_training.py
    โ”‚   โ”œโ”€โ”€ stage_05_model_evaluation.py
    โ”‚   โ”œโ”€โ”€ stage_06_generate_explanations.py
    โ”‚   โ””โ”€โ”€ stage_07_batch_inference.py
    โ”‚
    โ”œโ”€โ”€ config/                # Config manager
    โ”‚   โ””โ”€โ”€ configuration.py
    โ”‚
    โ”œโ”€โ”€ constants/             # File paths & constants
    โ”‚   โ””โ”€โ”€ paths.py
    โ”‚
    โ”œโ”€โ”€ entity/                # Config/data entities
    โ”‚   โ””โ”€โ”€ config_entity.py
    โ”‚
    โ”œโ”€โ”€ utils/                 # Utility functions
    โ”‚   โ”œโ”€โ”€ common.py
    โ”‚   โ””โ”€โ”€ logger.py
    โ”‚
    โ””โ”€โ”€ __init__.py

๐Ÿ“š Dataset

  • โ€”Source: Conser-vision Practice Area: Image Classification by drivendata.org
  • โ€”Provided by: The Pan African Programme: The Cultured Chimpanzee, Wild Chimpanzee Foundation, DrivenData. (2022). Conser-vision Practice Area: Image Classification. Retrieved [July 12 2025] from https://www.drivendata.org/competitions/87/competition-image-classification-wildlife-conservation/.

โš™๏ธ Installation

bash
git clone https://github.com/santosh3110/EcoClassify---Wildlife-Image-Classifier.git
cd EcoClassify---Wildlife-Image-Classifier
conda create -n ecoclassify python=3.10 -y
conda activate ecoclassify
pip install -r requirements.txt

(Optional: install PyTorch with CUDA if using GPU).


โ–ถ๏ธ Usage

Run Streamlit App

bash
streamlit run app.py

App opens at http://localhost:8501.

CLI Training

bash
python ecoclassify/pipelines/main.py

๐Ÿ–ฅ๏ธ Streamlit App

๐Ÿ‘‰ Try EcoClassify directly without setup: Live Demo on Hugging Face ๐Ÿš€

Tabs available:

  1. 1.About โ€“ Project info, dataset, motivation.
  2. 2.Inference โ€“ Upload images โ†’ classification + Grad-CAM heatmaps.
  3. 3.Batch Inference โ€“ Upload CSV + ZIP โ†’ get predictions CSV.
  4. 4.Fine-Tuning โ€“ Upload dataset (train/val) โ†’ retrain ResNet50 with custom hyperparameters.

๐Ÿ“Š Model Training & Evaluation

  • โ€”Models trained:
  • โ€”CustomCNN (100 epochs)
  • โ€”ResNet50 (transfer learning) (50 epochs)
  • โ€”Evaluation scope:
  • โ€”Confusion matrix
  • โ€”Classification report
  • โ€”Calibration metrics (temperature scaling)
  • โ€”Artifacts stored under artifacts/

Results Summary

ModelTemperatureUncalibrated AccuracyCalibrated AccuracyUncalibrated PrecisionCalibrated PrecisionUncalibrated RecallCalibrated RecallUncalibrated F1Calibrated F1Uncalibrated Log-LossCalibrated Log-Loss
CustomCNN0.660.700.700.700.700.700.700.690.690.890.83
ResNet500.820.890.890.890.890.890.890.890.890.410.39

Macro & Weighted Averages

ModelMacro PrecisionMacro RecallMacro F1Weighted PrecisionWeighted RecallWeighted F1
CustomCNN0.720.700.710.700.700.69
ResNet500.900.900.900.890.890.89

Per-class Metrics

CustomCNN

ClassPrecisionRecallF1-scoreSupport
antelope_duiker0.500.500.50495.00
bird0.750.690.72328.00
blank0.620.360.46443.00
civet_genet0.800.920.86485.00
hog0.920.790.85195.00
leopard0.910.870.89451.00
monkey_prosimian0.570.790.66498.00
rodent0.690.700.70403.00

ResNet50

ClassPrecisionRecallF1-scoreSupport
antelope_duiker0.810.810.81495.00
bird0.930.960.95328.00
blank0.770.620.68443.00
civet_genet0.940.970.96485.00
hog0.970.980.98195.00
leopard0.940.980.96451.00
monkey_prosimian0.900.930.91498.00
rodent0.890.950.92403.00

Training visuals:

  • โ€”CustomCNN Training Chart: [image]
  • โ€”ResNet50 Training Chart: [image]
  • โ€”Results tracked via **MLflow & DagsHub**

Confusion matrices:

CustomCNN confusion matrixResNet50 confusion matrix
[image][image]

๐Ÿ”Ž Explainability

  • โ€”Grad-CAM highlights model focus regions.
  • โ€”Outputs side-by-side comparison:
  • โ€”Original Image
  • โ€”Heatmap Overlay
  • โ€”Sample Grad-CAM heatmaps generated on Val dataset: [image] [image] [image] [image] ---

๐Ÿ“ฆ Batch Inference

  • โ€”Upload CSV (image paths) + ZIP (images).
  • โ€”Pipeline produces predictions.csv with class & confidence.

๐Ÿ› ๏ธ Fine-Tuning

  • โ€”Upload dataset in structure:
dataset.zip
 โ”œโ”€โ”€ train/
 โ”‚   โ”œโ”€โ”€ class1/
 โ”‚   โ”œโ”€โ”€ class2/
 โ””โ”€โ”€ val/
     โ”œโ”€โ”€ class1/
     โ”œโ”€โ”€ class2/
  • โ€”Configure hyperparams (epochs, batch size, LR, early stopping).
  • โ€”Retrains ResNet50 on uploaded data.
  • โ€”Outputs: new model weights + mapping.

๐Ÿ“„ Design Docs

๐Ÿ“Œ Included in /docs:

  • โ€”PRD โ€“ Product Requirements & Specs
  • โ€”HLD โ€“ High-Level Architecture Design
  • โ€”LLD โ€“ Low-Level Implementation Design

๐Ÿงฉ Future Work

  • โ€”๐Ÿš€ Deploy as FastAPI + Docker microservice.
  • โ€”๐Ÿ“ฑ Extend to mobile app for field researchers.
  • โ€”๐Ÿงช Add ensemble models (ResNet + ViT).
  • โ€”๐Ÿพ Multi-label support (detect multiple species in one frame).

โค๏ธ Acknowledgements

  • โ€”The Pan African Programme: The Cultured Chimpanzee, Wild Chimpanzee Foundation, DrivenData. (2022). Conser-vision Practice Area: Image Classification. Retrieved [July 12 2025] from https://www.drivendata.org/competitions/87/competition-image-classification-wildlife-conservation/.
  • โ€”Mentorship: Sudhanshu Kumar (Euron)
  • โ€”Frameworks: PyTorch, Streamlit, MLflow, TorchCAM

๐Ÿ“œ License

Apache 2.0 License ยฉ 2025 Santosh Kumar Guntupalli


โœจ Made with love for Wildlife & AI ๐Ÿ†๐ŸŒฑ