{ "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 }