From 9119557482868a32ffc278f8a9d8de86b5d07a7f Mon Sep 17 00:00:00 2001
From: chelseanguyenn <67062596+chelseanguyenn@users.noreply.github.com>
Date: Tue, 12 Aug 2025 10:59:04 -0700
Subject: [PATCH 1/2] Add files via upload
Uploaded oil spill detection colab
---
OilSpillDetection_Fixed.ipynb | 404 ++++++++++++++++++++++++++++++++++
1 file changed, 404 insertions(+)
create mode 100644 OilSpillDetection_Fixed.ipynb
diff --git a/OilSpillDetection_Fixed.ipynb b/OilSpillDetection_Fixed.ipynb
new file mode 100644
index 00000000..a0b85265
--- /dev/null
+++ b/OilSpillDetection_Fixed.ipynb
@@ -0,0 +1,404 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "yDGmDi0cMcyD"
+ },
+ "outputs": [],
+ "source": [
+ "!pip install -q kaggle\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from google.colab import files\n",
+ "files.upload() # Upload kaggle.json\n",
+ "{\"username\":\"cheloceannguyen\",\"key\":\"0f1c72736e018e74a01d3cdd9e47ad04\"}"
+ ],
+ "metadata": {
+ "id": "Gk8B2Ny3OBhq",
+ "outputId": "b88b5703-6a79-4b71-f498-75b09c31da96",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 56
+ }
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " \n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!mkdir -p ~/.kaggle\n",
+ "!cp kaggle.json ~/.kaggle/\n",
+ "!chmod 600 ~/.kaggle/kaggle.json\n"
+ ],
+ "metadata": {
+ "id": "BgHq4xbEOKGQ",
+ "outputId": "6271de97-85e9-4e7e-970f-34e84cde1f2f",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "cp: cannot stat 'kaggle.json': No such file or directory\n",
+ "chmod: cannot access '/root/.kaggle/kaggle.json': No such file or directory\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!kaggle datasets download -d kabeer2004/water-pollution-images -p /content/data\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "eTV4H2W-OM_b",
+ "outputId": "677be07f-5746-4956-9b91-9862b4a6b8a1"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Traceback (most recent call last):\n",
+ " File \"/usr/local/bin/kaggle\", line 10, in \n",
+ " sys.exit(main())\n",
+ " ^^^^^^\n",
+ " File \"/usr/local/lib/python3.11/dist-packages/kaggle/cli.py\", line 68, in main\n",
+ " out = args.func(**command_args)\n",
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
+ " File \"/usr/local/lib/python3.11/dist-packages/kaggle/api/kaggle_api_extended.py\", line 1741, in dataset_download_cli\n",
+ " with self.build_kaggle_client() as kaggle:\n",
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
+ " File \"/usr/local/lib/python3.11/dist-packages/kaggle/api/kaggle_api_extended.py\", line 688, in build_kaggle_client\n",
+ " username=self.config_values['username'],\n",
+ " ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^\n",
+ "KeyError: 'username'\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import zipfile\n",
+ "import os\n",
+ "\n",
+ "zip_path = \"/content/data/water-pollution-images.zip\"\n",
+ "extract_path = \"/content/data/water_pollution\"\n",
+ "\n",
+ "with zipfile.ZipFile(zip_path, 'r') as zip_ref:\n",
+ " zip_ref.extractall(extract_path)\n",
+ "\n",
+ "# Optional: remove the zip file to save space\n",
+ "os.remove(zip_path)\n"
+ ],
+ "metadata": {
+ "id": "iI9S9Pj9OQzx"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import os\n",
+ "from PIL import Image\n",
+ "from pathlib import Path\n",
+ "\n",
+ "def is_image_valid(img_path):\n",
+ " try:\n",
+ " with Image.open(img_path) as img:\n",
+ " img.verify()\n",
+ " return True\n",
+ " except:\n",
+ " return False\n",
+ "\n",
+ "def clean_dataset(folder):\n",
+ " folder = Path(folder)\n",
+ " deleted = 0\n",
+ " for img_path in folder.rglob(\"*.*\"):\n",
+ " if not is_image_valid(img_path):\n",
+ " img_path.unlink()\n",
+ " deleted += 1\n",
+ " print(f\"Deleted {deleted} invalid images.\")\n",
+ "\n",
+ "clean_dataset(\"/content/data/water_pollution\")\n"
+ ],
+ "metadata": {
+ "id": "-Elo_gP0OT3V",
+ "outputId": "5f71eaa8-3cdd-4b2a-ff55-be94be13102d",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Deleted 1 invalid images.\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from collections import defaultdict\n",
+ "\n",
+ "summary = defaultdict(int)\n",
+ "for root, _, files in os.walk(\"/content/data/water_pollution\"):\n",
+ " for file in files:\n",
+ " if file.endswith(('.png', '.jpg', '.jpeg')):\n",
+ " label = os.path.basename(root)\n",
+ " summary[label] += 1\n",
+ "\n",
+ "print(\"Image count per label/class:\")\n",
+ "for label, count in summary.items():\n",
+ " print(f\"{label}: {count}\")\n"
+ ],
+ "metadata": {
+ "id": "5d7-PywzOYxV",
+ "outputId": "487337fa-3f4c-4769-8124-0d04c8f5c4d6",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Image count per label/class:\n",
+ "waterpollution: 289\n"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 3adc9978c7637785efa3420769ec2d48ef7c34e9 Mon Sep 17 00:00:00 2001
From: chelseanguyenn <67062596+chelseanguyenn@users.noreply.github.com>
Date: Tue, 12 Aug 2025 11:01:43 -0700
Subject: [PATCH 2/2] Delete OilSpillDetection_Fixed.ipynb
Wrong file of model
---
OilSpillDetection_Fixed.ipynb | 404 ----------------------------------
1 file changed, 404 deletions(-)
delete mode 100644 OilSpillDetection_Fixed.ipynb
diff --git a/OilSpillDetection_Fixed.ipynb b/OilSpillDetection_Fixed.ipynb
deleted file mode 100644
index a0b85265..00000000
--- a/OilSpillDetection_Fixed.ipynb
+++ /dev/null
@@ -1,404 +0,0 @@
-{
- "nbformat": 4,
- "nbformat_minor": 0,
- "metadata": {
- "colab": {
- "provenance": []
- },
- "kernelspec": {
- "name": "python3",
- "display_name": "Python 3"
- },
- "language_info": {
- "name": "python"
- }
- },
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "id": "yDGmDi0cMcyD"
- },
- "outputs": [],
- "source": [
- "!pip install -q kaggle\n"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "from google.colab import files\n",
- "files.upload() # Upload kaggle.json\n",
- "{\"username\":\"cheloceannguyen\",\"key\":\"0f1c72736e018e74a01d3cdd9e47ad04\"}"
- ],
- "metadata": {
- "id": "Gk8B2Ny3OBhq",
- "outputId": "b88b5703-6a79-4b71-f498-75b09c31da96",
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 56
- }
- },
- "execution_count": null,
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "!mkdir -p ~/.kaggle\n",
- "!cp kaggle.json ~/.kaggle/\n",
- "!chmod 600 ~/.kaggle/kaggle.json\n"
- ],
- "metadata": {
- "id": "BgHq4xbEOKGQ",
- "outputId": "6271de97-85e9-4e7e-970f-34e84cde1f2f",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "cp: cannot stat 'kaggle.json': No such file or directory\n",
- "chmod: cannot access '/root/.kaggle/kaggle.json': No such file or directory\n"
- ]
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "!kaggle datasets download -d kabeer2004/water-pollution-images -p /content/data\n"
- ],
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "eTV4H2W-OM_b",
- "outputId": "677be07f-5746-4956-9b91-9862b4a6b8a1"
- },
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Traceback (most recent call last):\n",
- " File \"/usr/local/bin/kaggle\", line 10, in \n",
- " sys.exit(main())\n",
- " ^^^^^^\n",
- " File \"/usr/local/lib/python3.11/dist-packages/kaggle/cli.py\", line 68, in main\n",
- " out = args.func(**command_args)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/usr/local/lib/python3.11/dist-packages/kaggle/api/kaggle_api_extended.py\", line 1741, in dataset_download_cli\n",
- " with self.build_kaggle_client() as kaggle:\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/usr/local/lib/python3.11/dist-packages/kaggle/api/kaggle_api_extended.py\", line 688, in build_kaggle_client\n",
- " username=self.config_values['username'],\n",
- " ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^\n",
- "KeyError: 'username'\n"
- ]
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "import zipfile\n",
- "import os\n",
- "\n",
- "zip_path = \"/content/data/water-pollution-images.zip\"\n",
- "extract_path = \"/content/data/water_pollution\"\n",
- "\n",
- "with zipfile.ZipFile(zip_path, 'r') as zip_ref:\n",
- " zip_ref.extractall(extract_path)\n",
- "\n",
- "# Optional: remove the zip file to save space\n",
- "os.remove(zip_path)\n"
- ],
- "metadata": {
- "id": "iI9S9Pj9OQzx"
- },
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "code",
- "source": [
- "import os\n",
- "from PIL import Image\n",
- "from pathlib import Path\n",
- "\n",
- "def is_image_valid(img_path):\n",
- " try:\n",
- " with Image.open(img_path) as img:\n",
- " img.verify()\n",
- " return True\n",
- " except:\n",
- " return False\n",
- "\n",
- "def clean_dataset(folder):\n",
- " folder = Path(folder)\n",
- " deleted = 0\n",
- " for img_path in folder.rglob(\"*.*\"):\n",
- " if not is_image_valid(img_path):\n",
- " img_path.unlink()\n",
- " deleted += 1\n",
- " print(f\"Deleted {deleted} invalid images.\")\n",
- "\n",
- "clean_dataset(\"/content/data/water_pollution\")\n"
- ],
- "metadata": {
- "id": "-Elo_gP0OT3V",
- "outputId": "5f71eaa8-3cdd-4b2a-ff55-be94be13102d",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Deleted 1 invalid images.\n"
- ]
- }
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "from collections import defaultdict\n",
- "\n",
- "summary = defaultdict(int)\n",
- "for root, _, files in os.walk(\"/content/data/water_pollution\"):\n",
- " for file in files:\n",
- " if file.endswith(('.png', '.jpg', '.jpeg')):\n",
- " label = os.path.basename(root)\n",
- " summary[label] += 1\n",
- "\n",
- "print(\"Image count per label/class:\")\n",
- "for label, count in summary.items():\n",
- " print(f\"{label}: {count}\")\n"
- ],
- "metadata": {
- "id": "5d7-PywzOYxV",
- "outputId": "487337fa-3f4c-4769-8124-0d04c8f5c4d6",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Image count per label/class:\n",
- "waterpollution: 289\n"
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file