File size: 3,765 Bytes
95e7952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
  "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"
      }
    }
  ]
}