diff --git a/data_process/data_process.ipynb b/data_process/data_process.ipynb index 449e4d61b..485f3e37c 100644 --- a/data_process/data_process.ipynb +++ b/data_process/data_process.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 4, "id": "335bf1ae", "metadata": {}, "outputs": [], @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "id": "b8fe5313", "metadata": {}, "outputs": [], @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 13, "id": "101e48e9", "metadata": {}, "outputs": [], @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 14, "id": "6edd8ee3", "metadata": {}, "outputs": [], @@ -88,7 +88,18 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 15, + "id": "6c24ffe6", + "metadata": {}, + "outputs": [], + "source": [ + "img_height = content['images'][0]['height']\n", + "img_width = content['images'][0]['height']" + ] + }, + { + "cell_type": "code", + "execution_count": 16, "id": "a9923894", "metadata": {}, "outputs": [], @@ -97,8 +108,8 @@ "for label_info in content['annotations']:\n", " img_name = dict_id2img[label_info['image_id']]\n", " class_name = label_info['category_id']\n", - " x_center = (label_info['bbox'][0] + label_info['bbox'][2] / 2) / 640\n", - " y_center = (label_info['bbox'][1] + label_info['bbox'][3] / 2) / 640\n", + " x_center = (label_info['bbox'][0] + label_info['bbox'][2] / 2) / img_height\n", + " y_center = (label_info['bbox'][1] + label_info['bbox'][3] / 2) / img_width\n", " w = label_info['bbox'][1] / 640\n", " h = label_info['bbox'][3] / 640\n", " with open(os.path.join(img_folder.replace(\"images\", \"labels\"), img_name.replace(\".jpg\", \".txt\")), 'a') as f:\n",