Skip to content

saanidhi-git/AquaMorph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŠ AquaMorph โ€” Microplastic Morphology Classifier

Theme: Marine Ecosystem Protection & Water Quality Monitoring


๐Ÿ“ฝ๏ธ Demo Video

โ–ถ๏ธ [Watch Demo Video]https://drive.google.com/file/d/1NN_VU7zDTB2pvGUqbP6io8ZcJAt-oihn/view?usp=sharing


๐Ÿ–ฅ๏ธ App Screenshots

Batch Analysis with ETI Scoring

Batch

Classification

GAN


๐Ÿ“ Datasets Used & Preprocessing

Datasets

Dataset Source Train Images Val Images Classes
microplastic_100 Roboflow Universe 210 30 fiber, film, fragment, pallet
Microplastic-v2 Roboflow Universe 1,461 140 bead, fiber, fragment
Merged Combined 1,671 170 fiber, fragment, film, bead

๐Ÿ“‚ Full datasets + trained model: Google Drive

Class Standardization

Dataset 1 original Dataset 2 original AquaMorph unified class
fiber fiber fiber
fragment fragment fragment
film (not present) film
pallet bead bead

Preprocessing Pipeline

  1. Merging โ€” Images from both datasets merged into unified folder with remapped class labels
  2. Resize โ€” All images standardized to 640ร—640 for YOLOv8 input
  3. Augmentation (applied by YOLOv8 during training):
    • Random horizontal flip (p=0.5)
    • HSV colour jitter (hue ยฑ1.5%, saturation ยฑ70%, value ยฑ40%)
    • Random erasing (p=0.4)
    • Mosaic augmentation (4 images per tile)
  4. Normalization โ€” Pixel values normalized to [0, 1]
  5. Class imbalance โ€” Handled via augmentation; film class supplemented from Dataset 1

Size Estimation Preprocessing (OpenCV)

  1. Grayscale conversion
  2. Gaussian blur (5ร—5 kernel) for noise reduction
  3. Otsu's adaptive thresholding to isolate particle from background
  4. cv2.findContours() to detect particle boundary
  5. Maximum pairwise distance across contour points = Feret diameter
  6. Pixel โ†’ micrometre conversion at 0.25 ยตm/pixel (40ร— magnification)

๐Ÿค– Model Used & Performance Metrics

Architecture

![Screenshot 2]!System

Property Value
Model YOLOv8n (nano)
Pretrained on COCO dataset
Task Object Detection + Classification
Parameters 3,006,428
Model size 6.2 MB
Input size 640ร—640
Training epochs 30
Optimizer Auto (SGD โ†’ Adam)
Batch size 16
Hardware Tesla T4 GPU (Google Colab)
Training time ~16 minutes

Performance Metrics (Final Validation)

Class Precision Recall mAP50 mAP50-95
fiber 0.923 0.961 0.956 0.775
fragment 0.937 0.970 0.959 0.595
film 0.972 0.977 0.958 0.430
bead 0.801 0.825 0.816 0.515
Overall 0.908 0.933 0.922 0.578
  • Overall mAP50: 92.2% โ€” production-quality performance
  • Training loss at epoch 30: box=0.912, cls=0.514, dfl=1.001
  • Inference speed: 4.1ms per image on GPU

Training Output

Training Results

Ecological Threat Index (

ETI) Formula

ETI = morphology_score + size_score

morphology_score:
  fiber     = 40  (highest โ€” ingested by filter feeders)
  fragment  = 30  (leaches chemical additives)
  film      = 25  (smothers benthic organisms)
  bead      = 20  (point source, predictable)

size_score = 60 ร— (1 โˆ’ min(feret_ยตm, 5000) / 5000)
  โ†’ particles < 100ยตm can penetrate biological tissues
  โ†’ particles < 10ยตm can cross cell membranes

ETI range: 0โ€“100  (higher score = greater ecological threat)

โœจ Key Features

Core Classification Features

Feature Description
๐Ÿ” Morphology classification Classifies into Fiber, Fragment, Film, Bead with confidence %
๐Ÿ“ Feret diameter estimation Estimates longest particle dimension in micrometres (ยตm) via OpenCV contour detection
๐ŸŒก๏ธ Ecological Threat Index Combined 0โ€“100 risk score โ€” ETI Score shown per particle
๐Ÿšฆ Threat level badge HIGH RISK / MEDIUM / LOW colour-coded alert per prediction
๐Ÿงช Polymer source predictor Maps morphology โ†’ likely polymer (e.g. Polyester/Nylon for fiber)
๐ŸŒฟ Degradation stage estimator Classifies particle as Fresh / Lightly Weathered / Heavily Weathered

Analysis Modules (from sidebar)

Module Description
๐Ÿ” Classify Single image upload โ†’ full morphology + ETI analysis
๐Ÿ“ฆ Batch Analysis Upload multiple images โ†’ summary table with Class, Confidence, Feret Diameter, ETI Score, Threat Level, Degradation, Polymer โ†’ Download Full Results CSV
๐Ÿ—บ๏ธ Spatial Heatmap Multi-particle field image โ†’ colour-coded particle distribution map
๐ŸŽจ GAN Generator Generate synthetic microplastic training images per class
๐Ÿงช Polymer Source Detailed polymer origin analysis per morphology type
๐Ÿ“ Field Logger Log GPS coordinates + sample source + date for each analysis
โš ๏ธ Review Queue Low-confidence predictions flagged for manual human review
๐Ÿ“Š Dashboard Summary stats โ€” Images Processed, Avg ETI Score, High Threat count
โ„น๏ธ About Indian river context, model info, ETI formula explanation

System Status Panel

Status Component
๐ŸŸข Ready YOLOv8 model loaded
๐Ÿ”ต Ready Contour Analyser (OpenCV)
๐Ÿ”ด Standby DCGAN Generator

๐Ÿ‡ฎ๐Ÿ‡ณ Indian Environmental Context

AquaMorph is calibrated against published Indian river research:

  • Pune โ€” Mula River โ†’ 1,808 microplastic particles/L detected (2025 study); film-shaped MPs most abundant; particles as small as 25ยตm (our backyard)
  • Ganga & Yamuna Rivers โ†’ Fibre-shaped MPs dominant at 300ยตmโ€“5mm; polyamide and PAM primary polymers
  • South Indian rivers โ†’ Fibers 64.1%, films 21.7%, fragments 12%, beads 2.2%

๐Ÿ—๏ธ Model Architecture

Input Image (640ร—640)
        โ†“
YOLOv8n Backbone (CSPDarknet)
        โ†“
Feature Pyramid Network (FPN)
        โ†“
Detection Head
        โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Class: fiber / fragment / film / bead  โ”‚
โ”‚  Confidence %                           โ”‚
โ”‚  Bounding box coordinates               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ†“
OpenCV Contour Detection โ†’ Feret Diameter (ยตm)
        โ†“
Degradation Stage Estimator
        โ†“
ETI Score (0โ€“100) + Threat Level + Polymer Source
        โ†“
Streamlit UI โ€” Classify / Batch / Heatmap / GAN / Dashboard

๐Ÿš€ How to Run AquaMorph

Step 1 โ€” Clone the repo

git clone https://github.com/Saanidhi123/cummins_hackathon.git
cd cummins_hackathon
pip install -r requirements.txt

Step 2 โ€” Download the model

Download best.pt from Google Drive and place it inside the model/ folder:

๐Ÿ“ AquaMorph Model + Datasets (Google Drive)

Step 3 โ€” Run

streamlit run app.py

Open http://localhost:8501 in your browser.


๐Ÿ“‚ Repository Structure

cummins_hackathon/
โ”œโ”€โ”€ app.py                  โ† AquaMorph Streamlit web app
โ”œโ”€โ”€ train.py                โ† YOLOv8 training script
โ”œโ”€โ”€ requirements.txt        โ† Python dependencies
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ assets/                 โ† Screenshots and training output images
โ”‚   โ”œโ”€โ”€ training_results.png
โ”‚   โ”œโ”€โ”€ screenshot_batch.png
โ”‚   โ””โ”€โ”€ screenshot_classify.png
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ contour.py          โ† OpenCV Feret diameter estimation
โ”‚   โ””โ”€โ”€ scoring.py          โ† ETI score + polymer + degradation predictor
โ””โ”€โ”€ model/
    โ””โ”€โ”€ .gitkeep            โ† Download best.pt from Drive link above

๐Ÿ› ๏ธ Tech Stack

Layer Technology
ML Model YOLOv8n (Ultralytics)
Image Processing OpenCV
GAN Generator DCGAN (PyTorch)
Frontend / UI Streamlit
Data Management Pandas
Training Platform Google Colab (Tesla T4 GPU)
Dataset Source Roboflow Universe
Model Storage Google Drive
Version Control GitHub

๐Ÿ‘ฉโ€๐Ÿ’ป Team โ€” NeuralNomads_PS3

AquaMorph

Microplastic Morphology Classifier


๐Ÿ“„ License

Datasets used under CC BY 4.0 license (Roboflow Universe).

About

Microplastic Morphology Classifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages