dataset_88kps+some-updates

This commit is contained in:
2022-08-14 09:59:01 +03:00
parent ac04526fe1
commit 998aec2b80
943 changed files with 945 additions and 938 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"id": "07bdc0da",
"metadata": {},
"outputs": [],
@@ -11,17 +11,17 @@
"import json\n",
"import numpy as np\n",
"from tqdm.notebook import tqdm\n",
"path_dataset = r'D:\\downloads\\Nurburg-karussel'\n",
"path_dataset = r'D:\\Karusel\\Nurburg-karussel_88'\n",
"from SuperviselyKeypointsGUI.SuperviselyKeypointsGUI import *\n",
"\n",
"\n",
"keypoints_3d_path = r'SuperviselyKeypointsGUI\\karussel_24kps.csv'\n",
"keypoints_3d_path = r'C:\\Users\\Kir\\Jupiter\\Nurburg\\keypoints_88\\karussel_88kps.csv'\n",
"keypoints_3d = pd.read_csv(keypoints_3d_path, index_col=0).astype(float)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"id": "ca890aa0",
"metadata": {},
"outputs": [],
@@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"id": "b8135031",
"metadata": {},
"outputs": [],
@@ -60,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"id": "79762c08",
"metadata": {},
"outputs": [],
@@ -79,10 +79,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "f9440b54",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1a27ecccf8054a5082d0a51178c0f2a9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/448 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for obj in tqdm(coco['annotations']):\n",
" keypoints_2d = np.array(obj['keypoints']).reshape((-1, 3))[:, :2]\n",
@@ -96,13 +111,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "dfcb675b",
"metadata": {},
"outputs": [],
"source": [
"# with open(os.path.join(path_dataset, 'karusel_COCO.json'), 'w') as file:\n",
"# json.dump(coco, file)"
"with open(os.path.join(path_dataset, 'karusel_COCO.json'), 'w') as file:\n",
" json.dump(coco, file)"
]
},
{
@@ -115,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "3aec7a2b",
"metadata": {},
"outputs": [],
@@ -150,17 +165,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "aafd54fb",
"metadata": {},
"outputs": [],
"source": [
"train, test = split_coco_json(coco, 0.1, random_state=777)"
"train, test = split_coco_json(coco, 0.1, random_state=77)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "f6af98fc",
"metadata": {},
"outputs": [],
@@ -169,7 +184,7 @@
"train_path_images = [os.path.join(path_dataset, 'images', 'img', x['file_name']) for x in train['images']]\n",
"\n",
"import shutil\n",
"path_new_dataset = r'C:\\Users\\Kir\\Jupiter\\Nurburg\\OpenPifPaf\\Training\\Karusel_dataset'\n",
"path_new_dataset = r'C:\\Users\\Kir\\Jupiter\\Drivecast\\place6D_Nurbsurgring\\Karussell\\Training\\Karusel_dataset_v2_88'\n",
"\n",
"path_train_img = os.path.join(path_new_dataset, 'images', 'train')\n",
"path_test_img = os.path.join(path_new_dataset, 'images', 'val')\n",

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "283f6e9c",
"metadata": {},
"outputs": [],
@@ -14,7 +14,7 @@
"import json\n",
"from tqdm.notebook import tqdm\n",
"\n",
"path_dataset = r'D:\\downloads\\Nurburg-karussel'\n",
"path_dataset = r'D:\\Karusel\\Nurburg-karussel_88'\n",
"with open(os.path.join(path_dataset, 'meta.json'), 'r') as j:\n",
" meta = json.load(j)\n",
"\n",
@@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"id": "7af948d4",
"metadata": {},
"outputs": [],
@@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "7ea0771e",
"metadata": {},
"outputs": [],
@@ -54,13 +54,14 @@
" keypoints_2d.loc[i] = nodes[label2hash(meta_json, obj)[str(i)]]['loc']\n",
"\n",
" keypoints_2d['v'] = 2\n",
" keypoints_2d[(keypoints_2d.x==0)&(keypoints_2d.y==0)] = 0\n",
" keypoints_2d = keypoints_2d.astype(float).round().astype(int)\n",
" return keypoints_2d[:24]"
" return keypoints_2d"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"id": "26b6abf4",
"metadata": {},
"outputs": [],
@@ -93,7 +94,26 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"id": "7c4d21a7",
"metadata": {},
"outputs": [],
"source": [
"def skeleton_supervisely(meta):\n",
" meta_nodes = meta['classes'][0]['geometry_config']['nodes']\n",
" label2hash = {}\n",
" for name in meta_nodes:\n",
" label2hash[meta_nodes[name]['label']] = name\n",
"\n",
" skeleton_supervisely = []\n",
" for edge in meta['classes'][0]['geometry_config']['edges']:\n",
" skeleton_supervisely.append([meta_nodes[edge['src']]['label'], meta_nodes[edge['dst']]['label']])\n",
" return skeleton_supervisely"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "155be42d",
"metadata": {},
"outputs": [],
@@ -113,21 +133,22 @@
" for obj in ann['objects']:\n",
" keypoints = annotations(meta, obj)\n",
" annotations_list.append(ann_json(keypoints, i, obj))\n",
" return image_list, annotations_list"
" return image_list, annotations_list, meta"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"id": "6593f677",
"metadata": {},
"outputs": [],
"source": [
"def COCO(image_list, annotations_list):\n",
"def COCO(image_list, annotations_list, meta):\n",
" num_kpts = len(meta['classes'][0]['geometry_config']['nodes'])\n",
" coco = {\n",
"\n",
" \"info\": {\n",
" \"description\": \"karusel Dataset\", \"version\": \"2.0\"\n",
" \"description\": \"karusel Dataset\", \"version\": \"2.0\", \"keypoints\":num_kpts\n",
" },\n",
"\n",
" \"categories\": [\n",
@@ -135,13 +156,8 @@
" \"supercategory\": \"NurburgRing\",\n",
" \"id\": 1,\n",
" \"name\": \"karusel\",\n",
" \"keypoints\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\n",
" 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],\n",
" \"skeleton\": [\n",
" [1, 2],[2, 3],[3, 4],[4, 5],[5, 6],[6, 7],[7, 8],[8, 9],[9, 10],[10, 11],\n",
" [11, 12],[12, 13],[13, 14],[14, 15],[15, 16],[16, 17],[17, 18],[18, 19],[19, 20],\n",
" [20, 21],[21, 22],[22, 23],[23, 24],[24, 1],[24, 3],[1, 5]\n",
" ]\n",
" \"keypoints\": list(range(num_kpts)),\n",
" \"skeleton\": skeleton_supervisely(meta)\n",
" }\n",
" ]\n",
" }\n",
@@ -153,14 +169,14 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"id": "38880d13",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "96021bfc91ce425dbef57ae348321005",
"model_id": "219ba034d89346f188cf37dc9a722263",
"version_major": 2,
"version_minor": 0
},
@@ -178,7 +194,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"id": "314565c2",
"metadata": {},
"outputs": [],