{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Train a YOLO model for object detection with oriented bounding boxes\n", "\n", "This notebook trains a YOLO model for object detection with oriented bounding boxes on the HRSC2016-MS dataset.\n", "\n", "The original dataset can be found [here](https://github.com/wmchen/HRSC2016-MS).\n", "\n", "![](../images/hrsc2016-ms-run.png)\n", "\n", "\n", "\n", "We re-use the Tables created in [create-custom-obb-table.ipynb](../1-create-tables/obbs/create-custom-obb-table.ipynb)." ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "## Project setup" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "PROJECT_NAME = \"3LC Tutorials - OBBs\"\n", "DATASET_NAME = \"HRSC2016-MS\"\n", "DOWNLOAD_PATH = \"\"" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "%pip install 3lc-ultralytics" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "import tlc\n", "from tlc_ultralytics import YOLO, Settings" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "## Load tables" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "train_table = tlc.Table.from_names(\"train\", DATASET_NAME, PROJECT_NAME)\n", "val_table = tlc.Table.from_names(\"val\", DATASET_NAME, PROJECT_NAME)" ] }, { "cell_type": "markdown", "id": "8", "metadata": {}, "source": [ "## Train a model" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "model = YOLO(\"yolo11n-obb.pt\")\n", "settings = Settings(\n", " project_name=PROJECT_NAME,\n", " run_name=\"train-yolon-obb-hrsc2016-ms\",\n", " image_embeddings_dim=2,\n", ")\n", "\n", "model.train(\n", " tables={\"train\": train_table, \"val\": val_table},\n", " settings=settings,\n", " label_column_name=\"obb\",\n", " epochs=10,\n", " workers=0,\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.9" }, "test_marks": [ "dependent" ] }, "nbformat": 4, "nbformat_minor": 5 }