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.
Question: Does image enhancement improve underwater object detection accuracy?
Answer: No. Enhancement designed for human vision degrades machine learning model performance.
| 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) |
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 theyolov8s.ptpretrained weights remain innotebooks/. They are historical artifacts; the five numbered01_*.ipynb–05_*.ipynbfiles are the new canonical entry points. Result PNGs from earlier analysis live underoutputs/results/.
- Python 3.8+
- CUDA 11.8+ (optional, for GPU acceleration)
- 4GB RAM minimum
# 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 .envFor 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 targetFor 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.pngfrom 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.yamlfrom 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.ptfrom src.enhancement.clahe import apply_clahe
enhanced_image = apply_clahe(raw_image, clip_limit=2.0, tile_grid_size=(8, 8))- 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)
- CLAHE - Contrast Limited Adaptive Histogram Equalization
- White Balance - Gray World Assumption
- Dark Channel Prior - Physics-based haze removal
- Histogram Equalization - Baseline contrast stretching
- Backbone: YOLOv8s (Small variant)
- Pre-training: COCO (80 classes)
- Fine-tuning: Underwater imagery (2 classes)
- Hardware: CPU (AMD Ryzen 5 8640HS)
- 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
- Achieves 84.8% mAP50 on test set
- 98.2% precision (minimal false alarms)
- 74.3% recall (detects most threats)
| 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 |
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.
- Limited Enhancement Testing: Only CLAHE tested in depth; other methods partially evaluated
- Small Comparison Sample: Only 3 images for enhancement vs raw comparison
- Dataset Scope: Primarily coastal underwater environments; generalization unknown
- Training Duration: 10 epochs due to CPU constraints; convergence may not be optimal
- Military Dataset: Public datasets used as proxy; real threat detection requires classified data
- 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
# Run all tests
pytest tests/
# Run specific test module
pytest tests/test_models.py -v
# With coverage
pytest --cov=src tests/This project is licensed under the MIT License - see LICENSE file for details.
Contributions are welcome! Please open an issue first to discuss what you would like to change.
- Author: Sashank (Sashank2006)
- GitHub: github.com/Sashank2006/KadalonAI
- Project Status: Production-ready
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