Skip to content

Commit

Permalink
Corrected compactness metric
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkenely committed Jul 25, 2023
1 parent 80c77f7 commit 1eebd94
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 47 deletions.
67 changes: 37 additions & 30 deletions COCO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 132,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -2638,7 +2638,7 @@
" bounding_rect = cv2.boundingRect(mask)\n",
" box = bounding_rect[2] * bounding_rect[3]\n",
" \n",
" area = np.sum(mask == 0)\n",
" area = np.sum(mask != 0)\n",
"\n",
" return area / box"
]
Expand Down Expand Up @@ -2670,7 +2670,7 @@
},
{
"cell_type": "code",
"execution_count": 117,
"execution_count": 133,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2865,22 +2865,7 @@
"------------------------------------------------------------------------------------------------------------------------\n",
"\n",
" Annotating image: 000000263146.jpg\n",
"\u001b[92m"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Programming\\Python\\Environments\\anaconda\\envs\\coco\\lib\\site-packages\\ipykernel_launcher.py:9: RuntimeWarning: divide by zero encountered in long_scalars\n",
" if __name__ == '__main__':\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" Succesfully saved image: 000000263146.jpg \u001b[0m\n",
"\u001b[92m Succesfully saved image: 000000263146.jpg \u001b[0m\n",
"\n",
"\n",
"------------------------------------------------------------------------------------------------------------------------\n",
Expand Down Expand Up @@ -2915,7 +2900,22 @@
"\n",
"------------------------------------------------------------------------------------------------------------------------\n",
"\n",
" Annotating image: 000000047263.jpg\n",
" Annotating image: "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Programming\\Python\\Environments\\anaconda\\envs\\coco\\lib\\site-packages\\ipykernel_launcher.py:9: RuntimeWarning: invalid value encountered in long_scalars\n",
" if __name__ == '__main__':\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 000000047263.jpg\n",
"\u001b[92m Succesfully saved image: 000000047263.jpg \u001b[0m\n",
"\n",
"\n",
Expand Down Expand Up @@ -3700,7 +3700,7 @@
"\n",
"\n",
"------------------------------------------------------------------------------------------------------------------------\n",
"PA time: 0.8621692657470703\n"
"PA time: 0.7726449966430664\n"
]
}
],
Expand Down Expand Up @@ -3734,7 +3734,7 @@
},
{
"cell_type": "code",
"execution_count": 118,
"execution_count": 134,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -3788,7 +3788,7 @@
},
{
"cell_type": "code",
"execution_count": 119,
"execution_count": 135,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -4299,7 +4299,7 @@
"\n",
" Annotating image: 000000107516.jpg\n",
"------------------------------------------------------------------------------------------------------------------------\n",
"PA time: 1.673271656036377\n"
"PA time: 1.4737472534179688\n"
]
}
],
Expand Down Expand Up @@ -4333,7 +4333,7 @@
},
{
"cell_type": "code",
"execution_count": 120,
"execution_count": 136,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -4483,21 +4483,21 @@
},
{
"cell_type": "code",
"execution_count": 128,
"execution_count": 137,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Programming\\Python\\Environments\\anaconda\\envs\\coco\\lib\\site-packages\\ipykernel_launcher.py:23: RuntimeWarning: divide by zero encountered in long_scalars\n"
"c:\\Programming\\Python\\Environments\\anaconda\\envs\\coco\\lib\\site-packages\\ipykernel_launcher.py:23: RuntimeWarning: invalid value encountered in long_scalars\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"KMC time: 0.5746200084686279\n"
"KMC time: 0.576115608215332\n"
]
}
],
Expand All @@ -4522,7 +4522,7 @@
" bounding_rect = cv2.boundingRect(mask)\n",
" box = bounding_rect[2] * bounding_rect[3]\n",
" \n",
" area = np.sum(mask == 0)\n",
" area = np.sum(mask != 0)\n",
"\n",
" score = area / box\n",
" if score < np.inf:\n",
Expand All @@ -4534,7 +4534,7 @@
},
{
"cell_type": "code",
"execution_count": 131,
"execution_count": 138,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -4578,6 +4578,13 @@
"\n",
"plt.savefig('./Figures/Compactness per Image - COCO (Segment Anything).png')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
70 changes: 53 additions & 17 deletions Evaluation.ipynb

Large diffs are not rendered by default.

Binary file modified Figures/Compactness per Image - COCO (K-Means Clustering).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Compactness per Image - COCO (Segment Anything).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1eebd94

Please sign in to comment.