Spaces:
Running
Running
File size: 8,020 Bytes
1803579 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import sys\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"import os \n",
"sns.set()\n",
"\n",
"%matplotlib inline\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"# https://abdalimran.github.io/2019-06-01/Drawing-multiple-ROC-Curves-in-a-single-plot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#labels = ['Baseline', 'MaskSup']\n",
"labels = ['VOC07', 'VOC12', 'COCO20K']\n",
"\n",
"# VOC\n",
"auc = [71.7, 75.6, 62] # base\n",
"acc_nst = [72.7, 75.9, 64.0]\n",
"\n",
"# COCO\n",
"# auc = [54.2,36.0,48.4] # base\n",
"# acc_nst = [74.8,59.4,68.8]\n",
"\n",
"x = np.arange(len(labels)) # the label locations\n",
"dummy = np.arange(10)\n",
"\n",
"width = 0.35 #0.4 # the width of the bars\n",
"\n",
"\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"rects1 = ax.bar(x - width/2, auc, width, label='low masking', color='#E96479') # #FFAE6D\n",
"rects2 = ax.bar(x + width/2, acc_nst, width, label='high masking', color='#7DB9B6') # #9ED2C6\n",
"#rects211 = ax.bar(x + width/2 * 3.08, acc, width, label='CF1')\n",
"\n",
"#ax.set_ylabel('CorLoc (%)', fontsize=20)\n",
"#ax.set_title('Results')\n",
"ax.set_xticks(x)\n",
"ax.set_xticklabels(labels, rotation=0, fontsize=20)\n",
"\n",
"#for i in range(18):\n",
"# ax.get_xticklabels()[i].set_color(\"white\")\n",
"\n",
"#ax.set_ylim([30,80]) # coc\n",
"ax.set_ylim([60,80]) # voc\n",
"\n",
"#ax.legend(loc=\"upper left\", prop={'size': 14})\n",
"ax.grid(True)\n",
"#ax.patch.set_facecolor('white')\n",
"\n",
"def autolabel(rects):\n",
" \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
" for rect in rects:\n",
" height = rect.get_height()\n",
" ax.annotate('{:.1f}'.format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha='center', va='bottom', rotation=0, fontsize=15)\n",
" #ax.set_ylim(ymin=1)\n",
" \n",
"\n",
"def autolabel_(rects):\n",
" \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
" for rect in rects:\n",
" height = rect.get_height()\n",
" ax.annotate('{:.1f}'.format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha='center', va='bottom', rotation=0, fontsize=15)\n",
" #ax.set_ylim(ymin=1)\n",
"\n",
"\n",
"autolabel(rects1) # %\n",
"autolabel(rects2)\n",
"#autolabel_(rects211) # %\n",
"\n",
"fig.tight_layout()\n",
"fig.set_size_inches(12, 4, forward=True)\n",
"plt.title('Impact of masking (\\u2191)', loc='left', fontsize=25, color='gray', pad=12)\n",
"#plt.title('VOC2007 (\\u2191)', loc='left', fontsize=25, color='gray', pad=12)\n",
"plt.legend(loc='upper right', fontsize=18)\n",
"plt.savefig(\"../logs/masking_ablation.pdf\", bbox_inches='tight', pad_inches=0, dpi=300)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#labels = ['Baseline', 'MaskSup']\n",
"labels = ['VOC07', 'VOC12', 'COCO20K']\n",
"\n",
"# VOC\n",
"auc_b = [71.6, 75.2, 61.8] # base\n",
"auc = [72.2, 75.5, 62.3] # base\n",
"acc_nst = [72.7, 75.9, 64.0]\n",
"\n",
"# COCO\n",
"# auc = [54.2,36.0,48.4] # base\n",
"# acc_nst = [74.8,59.4,68.8]\n",
"\n",
"x = np.arange(len(labels)) # the label locations\n",
"dummy = np.arange(10)\n",
"\n",
"width = 0.25 #0.4 # the width of the bars\n",
"\n",
"\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"rects1 = ax.bar(x - width/2, auc_b, width, label='Baseline', color='#E96479') # #FFAE6D\n",
"rects2 = ax.bar(x + width/2, auc, width, label='w/ MFP', color='#7DB9B6') # #9ED2C6\n",
"rects211 = ax.bar(x + width/2 * 3.08, acc_nst, width, label='w/ MFP + PCL', color='#FFAE6D')\n",
"\n",
"ax.set_ylabel('CorLoc (%)', fontsize=20)\n",
"#ax.set_title('Results')\n",
"ax.set_xticks(x)\n",
"ax.set_xticklabels(labels, rotation=0, fontsize=20)\n",
"\n",
"#for i in range(18):\n",
"# ax.get_xticklabels()[i].set_color(\"white\")\n",
"\n",
"#ax.set_ylim([30,80]) # coc\n",
"ax.set_ylim([60,80]) # voc\n",
"\n",
"#ax.legend(loc=\"upper left\", prop={'size': 14})\n",
"ax.grid(True)\n",
"#ax.patch.set_facecolor('white')\n",
"\n",
"def autolabel(rects):\n",
" \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
" for rect in rects:\n",
" height = rect.get_height()\n",
" ax.annotate('{:.1f}'.format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha='center', va='bottom', rotation=0, fontsize=15)\n",
" #ax.set_ylim(ymin=1)\n",
" \n",
"\n",
"def autolabel_(rects):\n",
" \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
" for rect in rects:\n",
" height = rect.get_height()\n",
" ax.annotate('{:.1f}'.format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha='center', va='bottom', rotation=0, fontsize=15)\n",
" #ax.set_ylim(ymin=1)\n",
"\n",
"\n",
"autolabel(rects1) # %\n",
"autolabel(rects2)\n",
"autolabel_(rects211) # %\n",
"\n",
"fig.tight_layout()\n",
"fig.set_size_inches(12, 4, forward=True)\n",
"plt.title('Effectiveness of MFP and PCL (\\u2191)', loc='left', fontsize=25, color='gray', pad=12)\n",
"#plt.title('VOC2007 (\\u2191)', loc='left', fontsize=25, color='gray', pad=12)\n",
"plt.legend(loc='upper right', fontsize=18)\n",
"plt.savefig(\"../logs/msl_ablation.pdf\", bbox_inches='tight', pad_inches=0, dpi=300)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "bdstreets",
"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.8.17"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|