Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KadalonAI: Underwater Threat Detection Using Image Enhancement & Deep Learning

Python 3.8+ PyTorch License: MIT Status: Production

📋 Overview

KadalonAI investigates the impact of image enhancement techniques on underwater object detection accuracy. Using a YOLOv8 deep learning model trained on 14,731 underwater images, this project quantifies how CLAHE, White Balance, Dark Channel Prior, and Histogram Equalization affect threat detection performance in degraded underwater environments.

Key Finding: While enhancement improves human perception, it paradoxically decreases YOLOv8 detection confidence by 11.2% on average, revealing a critical domain-distribution mismatch.

🎯 Objective

Question: Does image enhancement improve underwater object detection accuracy?

Answer: No. Enhancement designed for human vision degrades machine learning model performance.

📊 Results Summary

Metric Value
mAP50 0.848
Precision 0.982
Recall 0.743
Enhancement Impact -11.2% average decrease
Dataset Size 14,731 images
Training Time 4 hours (CPU)

🗂️ Project Structure

KadalonAI/
├── src/                          → Production code
│   ├── data/                     → Loaders, preprocessing, augmentation, class unification
│   ├── models/                   → YOLOv8 trainer, inference engine, evaluation
│   ├── enhancement/              → CLAHE, White Balance, Dark Channel Prior, Histogram Eq
│   ├── utils/                    → Config loader, logger, visualization, pydantic schemas
│   ├── pipelines/                → Composable training / inference / enhancement-impact pipelines
│   └── api/                      → FastAPI inference server
├── notebooks/                    → 5 numbered starter notebooks + 2 historical day-* notebooks
├── configs/                      → data_config.yaml, model_config.yaml, training_config.yaml
├── outputs/                      → models/, results/, logs/
├── tests/                        → Unit tests (enhancement, models, inference, pipelines, api)
├── docs/                         → Installation, usage, architecture, API reference
├── scripts/                      → train / evaluate / infer / serve / unify_classes / benchmark
│                                  → export_onnx / reproduce / setup_environment
├── data/                         → DVC-tracked raw / processed / external (see data/README.md)
├── images/                       → 5 sample underwater test images
├── .github/
│   ├── workflows/                → ci, release-drafter, dependabot-auto-merge
│   ├── ISSUE_TEMPLATE/           → bug, feature, question
│   ├── PULL_REQUEST_TEMPLATE.md
│   ├── CODEOWNERS
│   ├── dependabot.yml
│   └── release-drafter.yml
├── Dockerfile + docker-compose.yml → Reproducible container
├── Makefile                      → make setup / test / train / serve / docker-build / dvc-init
├── pyproject.toml                → Modern packaging + tool configs (pytest, ruff, black, mypy)
├── pre-commit, editorconfig, gitattributes
├── MODEL_CARD.md                 → Model card (Model Cards paper format)
├── CONTRIBUTING.md, CHANGELOG.md, CODE_OF_CONDUCT.md, SECURITY.md, CITATION.cff
├── LICENSE (MIT)
└── README.md

Entry points: scripts/train.py, scripts/evaluate.py, scripts/infer.py, scripts/serve.py, scripts/unify_classes.py, scripts/reproduce.py, scripts/export_onnx.py, scripts/benchmark.py.

Note on existing content: The pre-existing notebooks (day15_object_detection.ipynb, day9_histogram.ipynb) and the yolov8s.pt pretrained weights remain in notebooks/. They are historical artifacts; the five numbered 01_*.ipynb–05_*.ipynb files are the new canonical entry points. Result PNGs from earlier analysis live under outputs/results/.

🔧 Installation

Prerequisites

  • Python 3.8+
  • CUDA 11.8+ (optional, for GPU acceleration)
  • 4GB RAM minimum

Setup

# Clone repository
git clone https://github.com/Sashank2006/KadalonAI.git
cd KadalonAI

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Setup environment variables
cp .env.example .env

For a one-shot setup on Unix-like shells, use the Makefile:

make setup          # creates venv, installs runtime + dev deps, configures pre-commit
make test           # runs the full test suite
make help           # lists every available target

For an end-to-end reproduction of every result in this README:

make reproduce      # runs scripts/reproduce.py (train -> evaluate -> enhancement impact -> notebooks)

For a reproducible Docker deployment:

make docker-build
docker compose up api
curl -X POST -F "image=@images/2.png" -F "method=clahe" http://localhost:8000/enhance --output out.png

📚 Usage

Training

from src.models.yolo_trainer import YOLOTrainer

trainer = YOLOTrainer(config_path='configs/training_config.yaml')
results = trainer.train()

Or from the command line:

python scripts/train.py --config configs/training_config.yaml

Inference

from src.models.inference import Detector

detector = Detector(model_path='outputs/models/best.pt')
results = detector.predict(image_path='path/to/image.png')
print(f"Detections: {results}")

Or from the command line:

python scripts/infer.py --image images/1.png --model outputs/models/best.pt

Enhancement

from src.enhancement.clahe import apply_clahe

enhanced_image = apply_clahe(raw_image, clip_limit=2.0, tile_grid_size=(8, 8))

📈 Methodology

1. Dataset Collection

  • Source: Roboflow (Naval, Underwater Mines datasets) + Brackish underwater dataset
  • Size: 14,731 images
  • Classes: 2 (threat-like-object: 125, non-threat: 28,518)
  • Split: 80/10/10 (train/val/test)

2. Enhancement Techniques Tested

  1. CLAHE - Contrast Limited Adaptive Histogram Equalization
  2. White Balance - Gray World Assumption
  3. Dark Channel Prior - Physics-based haze removal
  4. Histogram Equalization - Baseline contrast stretching

3. Model Architecture

  • Backbone: YOLOv8s (Small variant)
  • Pre-training: COCO (80 classes)
  • Fine-tuning: Underwater imagery (2 classes)
  • Hardware: CPU (AMD Ryzen 5 8640HS)

4. Evaluation Metrics

  • mAP50: Mean Average Precision at IoU=0.5
  • Precision: True positives / (True positives + False positives)
  • Recall: True positives / (True positives + False negatives)
  • Inference Speed: ms per image

🔍 Key Findings

Model Performance

  • Achieves 84.8% mAP50 on test set
  • 98.2% precision (minimal false alarms)
  • 74.3% recall (detects most threats)

Enhancement Impact Analysis

Image Raw Conf Enhanced Conf Change
1 0.000 0.000 0.000
2 0.653 0.312 -0.341
3 0.456 0.461 +0.005
Avg -0.112

Scientific Interpretation

Enhancement methods optimized for human perception may not be suitable for machine learning pipelines. Models trained on raw imagery develop feature representations specific to that domain; heavily processed images create distribution shift.

⚠️ Limitations

  1. Limited Enhancement Testing: Only CLAHE tested in depth; other methods partially evaluated
  2. Small Comparison Sample: Only 3 images for enhancement vs raw comparison
  3. Dataset Scope: Primarily coastal underwater environments; generalization unknown
  4. Training Duration: 10 epochs due to CPU constraints; convergence may not be optimal
  5. Military Dataset: Public datasets used as proxy; real threat detection requires classified data

🚀 Future Work

  • GPU training for full 50+ epochs
  • Test all enhancement methods systematically
  • Domain adaptation techniques
  • Synthetic threat generation using GANs
  • Deployment on edge devices (Jetson, mobile)
  • Real-time inference optimization
  • Ensemble methods combining multiple detectors

📖 Documentation

🧪 Testing

# Run all tests
pytest tests/

# Run specific test module
pytest tests/test_models.py -v

# With coverage
pytest --cov=src tests/

📝 License

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

🤝 Contributing

Contributions are welcome! Please open an issue first to discuss what you would like to change.

📞 Contact

📚 Citation

If you use this project in your research, please cite:

@software{kadalonai2025,
  title={KadalonAI: Underwater Threat Detection Using Image Enhancement and Deep Learning},
  author={Sashank},
  year={2025},
  url={https://github.com/Sashank2006/KadalonAI}
}

Last Updated: January 2025 Model Version: YOLOv8s-v1.2 Dataset Version: Combined-v1

About

An AI-powered computer vision and emergency-response research project focused on underwater artifact/artillery detection, image enhancement, and detection workflow experimentation using Python-based machine learning pipelines.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages