{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Create Table from YOLO Instance Segmentation\n", "\n", "Create a 3LC Table from YOLO-format dataset with polygon-based instance segmentation annotations for modern object detection pipelines.\n", "\n", "![img](../../images/create-yolo-table.png)\n", "\n", "\n", "\n", "YOLO format is widely used in modern computer vision pipelines due to its simplicity and efficiency. The polygon-based segmentation format provides precise boundaries while maintaining fast inference speeds.\n", "\n", "This notebook loads a YOLO-format segmentation dataset and converts it to a 3LC Table. We process both image files and corresponding text annotation files containing normalized polygon coordinates for each instance.\n" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "## Project setup\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "PROJECT_NAME = \"3LC Tutorials - YOLO Segmentation\"\n", "DATASET_NAME = \"YOLO-Seg-Dataset\"\n", "TABLE_NAME = \"initial-segmentation\"\n", "DATA_PATH = \"../../../data\"\n", "INSTALL_DEPENDENCIES = True" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Install dependencies\n" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "if INSTALL_DEPENDENCIES:\n", " %pip install -q 3lc" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## Imports\n" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import tlc" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "## Create Segmentation Table\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "images_path = (Path(DATA_PATH) / \"yolo\" / \"datasets\" / \"simple\" / \"images\").absolute()\n", "\n", "assert images_path.exists()\n", "\n", "train_table = tlc.Table.from_yolo_url(\n", " images_url=images_path,\n", " categories={1.0: \"A\", 2.0: \"B\", 3.0: \"C\"},\n", " project_name=PROJECT_NAME,\n", " dataset_name=DATASET_NAME,\n", " table_name=TABLE_NAME,\n", " task=\"segment\",\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }