diff --git a/Grand_Prix/Inference/model/mobilenetv2-GrandPrix_v1_15.pkl.№1.epoch510 b/Grand_Prix/Inference/model/mobilenetv2-GrandPrix_v1_15.pkl.№1.epoch510 new file mode 100644 index 0000000..85537fb Binary files /dev/null and b/Grand_Prix/Inference/model/mobilenetv2-GrandPrix_v1_15.pkl.№1.epoch510 differ diff --git a/Grand_Prix/Inference/predict.ipynb b/Grand_Prix/Inference/predict.ipynb new file mode 100644 index 0000000..2ae2325 --- /dev/null +++ b/Grand_Prix/Inference/predict.ipynb @@ -0,0 +1,54 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "120b4212", + "metadata": {}, + "outputs": [], + "source": [ + "!python -m openpifpaf.predict test\\images\\test.png \\\n", + "--checkpoint=model/mobilenetv2-GrandPrix_v1_15.pkl.№1.epoch510 --image-output \\\n", + "--keypoint-threshold-rel=0.01 --cif-th=0.01 --caf-th=0.01 --seed-threshold=0.01 \\\n", + "--keypoint-threshold=0.01 --tr-minimum-threshold=0.01 --tr-single-pose-threshold=0.01 \\\n", + "--tr-multi-pose-threshold=0.01 --instance-threshold=0.1 --line-width=2 --json-output" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "984d60d5", + "metadata": {}, + "outputs": [], + "source": [ + "# !python -m openpifpaf.video --source test\\videos\\test.mp4 \\\n", + "# --checkpoint=model/mobilenetv2-GrandPrix_v1_15.pkl.№1.epoch510 --video-output --json-output \\\n", + "# --keypoint-threshold-rel=0.01 --cif-th=0.01 --caf-th=0.01 --seed-threshold=0.01 \\\n", + "# --keypoint-threshold=0.01 --tr-minimum-threshold=0.01 --tr-single-pose-threshold=0.01 \\\n", + "# --tr-multi-pose-threshold=0.01 --instance-threshold=0.1 --line-width=4 --video-fps=25 \\\n", + "# --scale=1 --loader-workers=3" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Grand_Prix/Inference/test/images/test.png b/Grand_Prix/Inference/test/images/test.png new file mode 100644 index 0000000..58e28e4 Binary files /dev/null and b/Grand_Prix/Inference/test/images/test.png differ diff --git a/Grand_Prix/Inference/test/images/test.png.predictions.jpeg b/Grand_Prix/Inference/test/images/test.png.predictions.jpeg new file mode 100644 index 0000000..0834ff3 Binary files /dev/null and b/Grand_Prix/Inference/test/images/test.png.predictions.jpeg differ diff --git a/Grand_Prix/Inference/test/images/test.png.predictions.json b/Grand_Prix/Inference/test/images/test.png.predictions.json new file mode 100644 index 0000000..c718af4 --- /dev/null +++ b/Grand_Prix/Inference/test/images/test.png.predictions.json @@ -0,0 +1 @@ +[{"keypoints": [838.75, 615.73, 0.88, 909.25, 613.23, 0.96, 1016.17, 620.18, 0.97, 1061.86, 628.27, 0.97, 1009.92, 566.12, 0.97, 1058.38, 501.94, 0.97, 1009.72, 476.08, 0.97, 936.14, 503.76, 0.99, 887.17, 524.44, 1.0, 800.59, 530.07, 0.99, 692.88, 533.28, 0.93, 649.33, 581.98, 0.97, 703.06, 585.64, 0.96, 912.56, 581.72, 0.96, 921.69, 479.73, 0.87], "bbox": [639.74, 465.77, 433.49, 173.86], "score": 0.957, "category_id": 1}] \ No newline at end of file diff --git a/Grand_Prix/Supervisely/Bbox from Pose.ipynb b/Grand_Prix/Supervisely/Bbox from Pose.ipynb new file mode 100644 index 0000000..d8725a1 --- /dev/null +++ b/Grand_Prix/Supervisely/Bbox from Pose.ipynb @@ -0,0 +1,227 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "07bdc0da", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import numpy as np\n", + "from tqdm.notebook import tqdm\n", + "path_dataset = r'D:\\GrandPrix\\Grand-Prix'" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ca890aa0", + "metadata": {}, + "outputs": [], + "source": [ + "def find_image(id):\n", + " for row in coco['images']:\n", + " if row['id'] == id:\n", + " return row" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "b8135031", + "metadata": {}, + "outputs": [], + "source": [ + "def ltrb_from_cloud(cloud_2d, imgSize, expansion=0.1):\n", + " height, width = imgSize\n", + " ltrb = np.round((cloud_2d[:, 0].min(), cloud_2d[:, 1].min(),\n", + " cloud_2d[:, 0].max(), cloud_2d[:, 1].max())).astype(int)\n", + " \n", + " if expansion > 0:\n", + " dx = np.round((ltrb[2]-ltrb[0])*expansion/2)\n", + " dy = np.round((ltrb[3]-ltrb[1])*expansion/2)\n", + " ltrb += np.array([-dx, -2*dy, dx, dy], dtype=int)\n", + " \n", + " ltrb[[0,2]] = np.clip(ltrb[[0,2]], 0, width)\n", + " ltrb[[1,3]] = np.clip(ltrb[[1,3]], 0, height)\n", + " \n", + " return ltrb\n", + "\n", + "def ltrb2ltwh(ltrb):\n", + " return np.array([ltrb[0], ltrb[1], ltrb[2]-ltrb[0], ltrb[3]-ltrb[1]], dtype=int)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "79762c08", + "metadata": {}, + "outputs": [], + "source": [ + "with open(os.path.join(path_dataset, 'GrandPrix_COCO.json'), 'r') as file:\n", + " coco = json.load(file)" + ] + }, + { + "cell_type": "markdown", + "id": "a1cfe0e2", + "metadata": {}, + "source": [ + "### Bboxes from pose" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "f9440b54", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "758138a872a9485885387a5ffe5a9696", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/148 [00:00