{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Create Table from COCO Keypoints\n", "\n", "Create a 3LC keypoints table from COCO-format annotations for human pose estimation and keypoint detection tasks.\n", "\n", "![img](../../images/coco-keypoints.png)\n", "\n", "\n", "\n", "COCO keypoints format is the standard for human pose estimation, providing 17 anatomical keypoints with visibility annotations. It's widely used in research and provides rich pose information for training robust pose estimation models.\n", "\n", "This notebook demonstrates loading COCO keypoints annotations and converting them to a 3LC Table. We process both the annotation JSON file and corresponding images, creating proper keypoint structures with coordinate positions and visibility flags." ] }, { "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 - COCO128\"\n", "DATASET_NAME = \"COCO128\"\n", "TABLE_NAME = \"initial-keypoints\"\n", "\n", "DATA_PATH = \"../../../data\"" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Install dependencies" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "%pip install 3lc" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## Imports" ] }, { "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 table" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "annotations_file = (Path(DATA_PATH) / \"coco128\" / \"keypoints_annotations.json\").absolute()\n", "image_folder = (Path(DATA_PATH) / \"coco128\" / \"images\").absolute()\n", "\n", "assert annotations_file.exists()\n", "assert image_folder.exists()" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "table = tlc.Table.from_coco(\n", " annotations_file=annotations_file,\n", " image_folder=image_folder,\n", " table_name=TABLE_NAME,\n", " project_name=PROJECT_NAME,\n", " dataset_name=DATASET_NAME,\n", " task=\"pose\",\n", " if_exists=\"rename\",\n", " # The remaining parameters are optional, and are used for decoration in the 3LC Dashboard\n", " lines=tlc.KeypointHelper.COCO_SKELETON,\n", " points=tlc.KeypointHelper.COCO_KEYPOINT_DEFAULT_POSE,\n", " point_attributes=tlc.KeypointHelper.COCO_KEYPOINT_NAMES,\n", " flip_indices=tlc.KeypointHelper.COCO_FLIP_INDICES,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "table" ] } ], "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" } }, "nbformat": 4, "nbformat_minor": 5 }