{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# DeepScan: Production-Grade Side-Scan Sonar AI Training\n", "**Smart India Hackathon 2026 | Problem Statement 26057**\n", "\n", "This notebook uses **Heavy Acoustic Augmentation** and Domain Adaptation to train a highly robust YOLOv8 model for AUV Edge deployment, even on small datasets." ], "metadata": { "id": "header" } }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "install" }, "outputs": [], "source": [ "!pip install ultralytics roboflow opencv-python\n", "import torch\n", "print(\"GPU Available:\", torch.cuda.is_available())" ] }, { "cell_type": "markdown", "source": [ "### 1. Download Dataset via Roboflow\n", "Replace the API key with your own from Roboflow Universe." ], "metadata": { "id": "dataset_md" } }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "dataset" }, "outputs": [], "source": [ "from roboflow import Roboflow\n", "rf = Roboflow(api_key=\"YOUR_ROBOFLOW_API_KEY_HERE\")\n", "project = rf.workspace(\"underwater-object-detection\").project(\"side-scan-sonar-debris\")\n", "version = project.version(1)\n", "dataset = version.download(\"yolov8\")" ] }, { "cell_type": "markdown", "source": [ "### 2. Train with Heavy Acoustic Augmentation\n", "Standard YOLO crushes sonar data. We use massive augmentations to simulate murky water, varying sonar frequencies, and AUV roll/pitch." ], "metadata": { "id": "train_md" } }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "train" }, "outputs": [], "source": [ "from ultralytics import YOLO\n", "\n", "# Load a pretrained YOLOv8 small model (optimal for Nvidia Jetson Edge deployment)\n", "model = YOLO('yolov8s.pt')\n", "\n", "# Train the model with acoustic physics parameters\n", "results = model.train(\n", " data=f\"{dataset.location}/data.yaml\",\n", " epochs=100,\n", " imgsz=640,\n", " batch=16,\n", " project=\"models\",\n", " name=\"sss_detector_v1\",\n", " \n", " # --- HEAVY ACOUSTIC AUGMENTATION ---\n", " mosaic=1.0, # Stitches images to teach scale variation\n", " mixup=0.2, # Blends anomalies into different backgrounds\n", " hsv_h=0.015, # Simulates changing sonar ping frequencies\n", " hsv_s=0.7, \n", " hsv_v=0.4, # Simulates attenuation (darkness) in deep water\n", " degrees=10.0, # Simulates AUV rolling due to currents\n", " translate=0.1, # Simulates AUV shifting\n", " flipud=0.5, # Common in bidirectional sonar scans\n", " fliplr=0.5\n", ")" ] }, { "cell_type": "markdown", "source": [ "### 3. Export for Deployment\n", "Once training is complete, download `models/sss_detector_v1/weights/best.pt` and place it in your local React/FastAPI project!" ], "metadata": { "id": "export_md" } } ] }