You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20_Final_Project/thesis_model_test.ipynb

377 lines
403 KiB
Plaintext

7 months ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualize"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import cv2\n",
"from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, confusion_matrix, precision_recall_curve\n",
"\n",
"base_dirs = ['./2nd_Battery/unet',\n",
" './2nd_Battery/unet-mini',\n",
" './2nd_Battery/unet-sgd',\n",
" './2nd_Battery/unet-rmsprop',\n",
6 months ago
" './2nd_Battery/unet-dice-loss',\n",
" './2nd_Battery/unet-focal-loss',\n",
7 months ago
" './2nd_Battery/unet-l1',\n",
" './2nd_Battery/unet-l2',\n",
" './2nd_Battery/unet-l1+l2']\n",
"colors = ['red', 'orange', 'yellow', 'pink', 'green', 'gold', 'magenta', 'cyan', 'violet']\n",
6 months ago
"losses = [0.2072, 0.1324, 0.1787, 0.1666, 0.3879, 0.0112, 0.0357, 0.0241, 0.0550]"
7 months ago
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"unet - precision: 0.582, recall: 0.895, accuracy: 0.958, f1: 0.685, iou: 0.550\n",
"unet-mini - precision: 0.708, recall: 0.929, accuracy: 0.973, f1: 0.794, iou: 0.676\n",
"unet-sgd - precision: 0.541, recall: 0.960, accuracy: 0.956, f1: 0.681, iou: 0.530\n",
"unet-rmsprop - precision: 0.855, recall: 0.789, accuracy: 0.984, f1: 0.794, iou: 0.696\n",
6 months ago
"unet-dice-loss - precision: 0.509, recall: 0.934, accuracy: 0.946, f1: 0.642, iou: 0.492\n",
"unet-focal-loss - precision: 0.894, recall: 0.762, accuracy: 0.984, f1: 0.818, iou: 0.711\n",
7 months ago
"unet-l1 - precision: 0.670, recall: 0.885, accuracy: 0.971, f1: 0.752, iou: 0.618\n",
"unet-l2 - precision: 0.778, recall: 0.788, accuracy: 0.977, f1: 0.777, iou: 0.649\n",
"unet-l1+l2 - precision: 0.714, recall: 0.908, accuracy: 0.976, f1: 0.790, iou: 0.667\n"
]
}
],
"source": [
"lst_rst, lst_cdata = [], []\n",
"idx = 0\n",
"\n",
"for base_dir in base_dirs:\n",
" result_dir = os.path.join(base_dir, 'result')\n",
"\n",
" ##\n",
" lst_data = os.listdir(os.path.join(result_dir, 'numpy'))\n",
"\n",
" lst_gt = [f for f in lst_data if f.startswith('gt')]\n",
" lst_pr = [f for f in lst_data if f.startswith('pr')]\n",
"\n",
" lst_gt.sort()\n",
" lst_pr.sort()\n",
"\n",
" ##\n",
" # id = 0\n",
" length = 1000\n",
" tp_list, tn_list, fp_list, fn_list, rst_list = [], [], [], [], []\n",
"\n",
" for id in range(0, length):\n",
" # img = np.load(os.path.join(result_dir,\"numpy\", lst_img[id]))\n",
" gt = np.load(os.path.join(result_dir,\"numpy\", lst_gt[id]))\n",
" pr = np.load(os.path.join(result_dir,\"numpy\", lst_pr[id]))\n",
"\n",
" tp = np.sum(np.logical_and(gt == 1, pr == 1))\n",
" tn = np.sum(np.logical_and(gt == 0, pr == 0))\n",
" fp = np.sum(np.logical_and(gt == 0, pr == 1))\n",
" fn = np.sum(np.logical_and(gt == 1, pr == 0))\n",
"\n",
" precision = tp / (tp + fp) # precision = TP / (TP + FP)\n",
" recall = tp / (tp + fn) # recall = TP / (TP + FN), SE(Sensitivity), hit rate\n",
" accuracy = (tp + tn) / (tp + tn + fp + fn)\n",
" f1 = 2 * precision * recall / (precision + recall)\n",
" iou = tp / (tp + fn + fp) \n",
"\n",
" tp_list.append(tp)\n",
" tn_list.append(tn)\n",
" fp_list.append(fp)\n",
" fn_list.append(fn)\n",
"\n",
"\n",
" # output_binary = (pr > 0).astype(np.int32)\n",
" # label_flat = gt.flatten().astype(np.int32)\n",
" # output_flat = output_binary.flatten().astype(np.int32)\n",
"\n",
" # accuracy = accuracy_score(label_flat, output_flat)\n",
" # precision = precision_score(label_flat, output_flat)\n",
" # recall = recall_score(label_flat, output_flat)\n",
" # f1 = f1_score(label_flat, output_flat)\n",
"\n",
" rst_list.append((precision, recall, accuracy, f1, iou))\n",
" \n",
" # avg_precision = sum(item[0] for item in rst_list) / len(rst_list)\n",
" # avg_recall = sum(item[1] for item in rst_list) / len(rst_list)\n",
" # avg_accuracy = sum(item[2] for item in rst_list) / len(rst_list)\n",
" # avg_f1 = sum(item[3] for item in rst_list) / len(rst_list)\n",
" # avg_iou = sum(item[4] for item in rst_list) / len(rst_list)\n",
" avg_precision = np.mean([item[0] for item in rst_list])\n",
" avg_recall = np.mean([item[1] for item in rst_list])\n",
" avg_accuracy = np.mean([item[2] for item in rst_list])\n",
" avg_f1 = np.mean([item[3] for item in rst_list])\n",
" avg_iou = np.mean([item[4] for item in rst_list])\n",
" print(f'{os.path.basename(base_dir)} - precision: {avg_precision:.3f}, recall: {avg_recall:.3f}, accuracy: {avg_accuracy:.3f}, f1: {avg_f1:.3f}, iou: {avg_iou:.3f}')\n",
"\n",
" total_tp = np.sum(tp_list)\n",
" total_tn = np.sum(tn_list)\n",
" total_fp = np.sum(fp_list)\n",
" total_fn = np.sum(fn_list)\n",
" y_true = np.concatenate([np.ones(total_tp + total_fn), np.zeros(total_tn + total_fp)])\n",
" y_score = np.concatenate([np.ones(total_tp), np.zeros(total_fn), np.ones(total_fp), np.zeros(total_tn)])\n",
"\n",
" lst_cdata.append((y_true, y_score))\n",
" lst_rst.append((losses[idx], avg_precision, avg_recall, avg_accuracy, avg_f1, avg_iou))\n",
" idx += 1"
]
},
{
"cell_type": "code",
6 months ago
"execution_count": 4,
7 months ago
"metadata": {},
"outputs": [
{
"data": {
6 months ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGzCAYAAAD9pBdvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcn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moI9TFFkmVu3bgFQqlQpAGbOnMlnn33GgAEDGD16NEFBQcydO5fnn3+eM2fOGI28goOD6d69O4MGDeK1116jbNmyNG3alF9//ZXjx48nTyu0atUKkJ6Y5cuX069fPz744AOOHTvGrFmzuHLlCn/88YeRXdeuXWPw4MGMHTuWMWPG4O3tnfzarFmzsLe3Z/Lkydy8eZO5c+dibW2NhYUFISEh+Pr68t9//7Fs2TKqVKnC1KlTk7edP38+derU4aWXXsLKyoqtW7fy1ltvodfrGT9+vJENN2/epF+/fowaNYrhw4ezZMkSRowYQZMmTahTpw4AkZGRtG3blitXrvD666/TuHFjnjx5wpYtW7h//z6lS5dGr9fz0ksvcfjwYd544w1q167NhQsXmDNnDtevX08OQMyMlOImCRsbG1xcXGjatClVq1Zl/fr1DB8+3GiddevWUaJECbp27QrIQMd///2XQYMGUbFiRfz8/Jg/fz7t27fn8uXLuTJdFx4ezqJFixg8eDBjxowhIiKCxYsX07VrV44fP07Dhg1xd3dn/vz5jBs3jpdffplXXnkFgPr166e736x8h0w5f2khhOCll15i//79jBo1ioYNG7Jz504mTZpEQEAAc+bMwd3dnZUrVzJz5kwiIyOTp15q166drc/L0tKSwYMH89lnn3H48GF69uyZap1XXnkFNzc33nvvPQYPHkyPHj1wcnKibNmyeHh48OWXXzJhwgSaNWtG2bJlAbh06RKtW7fGw8ODyZMn4+joyPr16+nTpw+///47L7/8stEx3nrrLdzd3Zk6dSpRUVEArFy5kuHDh9O1a1e+/vproqOjmT9/Pm3atOHMmTN4eXklb6/T6ejatSstWrRg9uzZ7Nmzh2+//ZZq1aoxbty4bJ3zJBwcHOjduzdr1qxh3LhxAJw7d45Lly6xaNEizp8/n2obU78vU6dOZcaMGfTo0YMePXpw+vRpunTpQnx8vNH+oqOjadeuHQEBAYwdO5ZKlSrx77//MmXKFB4+fMj333+frv1vvvkmGzdu5O2338bHx4fg4GAOHz7MlStXaNy4cabvX/EMQlEoWbp0qQDEnj17RFBQkPD39xdr164VpUqVEvb29uL+/fvCz89PWFpaipkzZxpte+HCBWFlZWW0vF27dgIQCxYsSHWs4cOHC0dHR6NlZ8+eFYAYPXq00fIPP/xQAGLfvn3JyypXriwA8ffffxutu3//fgGIunXrivj4+OTlgwcPFhqNRnTv3t1o/ZYtW4rKlSsbLYuOjk5lb9euXUXVqlWNliXZcOjQoeRlgYGBwtbWVnzwwQfJy6ZOnSoAsWnTplT71ev1QgghVq5cKSwsLMQ///xj9PqCBQsEII4cOZJq25QMHz5cAGk+unbtmrzelClThLW1tXj69Gnysri4OOHm5iZef/31DD+Do0ePCkCsWLEieVnS571//36jz2X48OGptm/Xrp1o165d8nOtVivi4uKM1gkJCRFly5Y1siUoKEgAYtq0aan2OW3aNJHykpOd71Bm5y8tNm/eLAAxY8YMo+X9+vUTGo1G3Lx50+h916lTJ8P9mbruH3/8IQDxww8/GL2PlJ/3nTt3BCC++eYbo22TztWGDRuMlnfq1EnUq1dPxMbGJi/T6/WiVatWokaNGsnLkq4Pbdq0EVqtNnl5RESEcHNzE2PGjDHa76NHj4Srq6vR8qTv6eeff260bqNGjUSTJk2Sn2d0ztMi5Xv766+/hEajEffu3RNCCDFp0qTk3+6zn6+p35fAwEBhY2Mjevbsmfy
7 months ago
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"avg_loss_list = [item[0] for item in lst_rst]\n",
"avg_precision_list = [item[1] for item in lst_rst]\n",
"avg_recall_list = [item[2] for item in lst_rst]\n",
"avg_accuracy_list = [item[3] for item in lst_rst]\n",
"avg_f1_list = [item[4] for item in lst_rst]\n",
"avg_iou_list = [item[5] for item in lst_rst]\n",
6 months ago
"model_list = ['U-Net', 'Mini', 'SGD', 'RMSProp', 'Dice', 'Focal', 'L1', 'L2', 'L1+L2']\n",
7 months ago
"\n",
"plt.plot(model_list, avg_loss_list, '-', color='blue', label=f'Avg Loss')\n",
"plt.plot(model_list, avg_precision_list, '-', color='green', label=f'Avg Precision')\n",
"plt.plot(model_list, avg_recall_list, '-', color='red', label=f'Avg Recall')\n",
"plt.plot(model_list, avg_accuracy_list, '-', color='gold', label=f'Avg Accuracy')\n",
"plt.plot(model_list, avg_f1_list, '-', color='orange', label=f'Avg F1-Score')\n",
"plt.plot(model_list, avg_iou_list, '-', color='pink', label=f'mIoU')\n",
"plt.title('Performance Evaluation of Different Models')\n",
"plt.legend(bbox_to_anchor=(0.69, 0.4))\n",
"plt.show()"
]
},
{
"cell_type": "code",
6 months ago
"execution_count": 5,
7 months ago
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"unet PR AUC: 0.704, minDist: 0.497, (0.885424512257604, 0.51682025846915)\n",
"unet-mini PR AUC: 0.780, minDist: 0.375, (0.9224052152557138, 0.6334823172698756)\n",
"unet-sgd PR AUC: 0.731, minDist: 0.497, (0.9538732855195041, 0.5053105923119683)\n",
"unet-rmsprop PR AUC: 0.813, minDist: 0.283, (0.7531937969524044, 0.8625253033281114)\n",
6 months ago
"unet-dice-loss PR AUC: 0.692, minDist: 0.555, (0.931617865125619, 0.44876511258753)\n",
"unet-focal-loss PR AUC: 0.822, minDist: 0.277, (0.7487617009547043, 0.8840717896362793)\n",
7 months ago
"unet-l1 PR AUC: 0.754, minDist: 0.393, (0.8766366499467493, 0.626387811957221)\n",
"unet-l2 PR AUC: 0.760, minDist: 0.349, (0.7813983872652583, 0.7285129156027101)\n",
"unet-l1+l2 PR AUC: 0.789, minDist: 0.341, (0.9011364203573499, 0.6734219064478764)\n"
]
},
{
"data": {
6 months ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAHHCAYAAABTMjf2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3hUVfrHP9PSGzWEEEjoSC+hKAgCShFQEEWkSlEkuLbV3+oWy666u5a1JII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9pxv9jVYiFWzUPE1j9V1p7z6GGLRZssWAGUl3vZJBiyVATTLXBI0yKJWMt+TDVAmMI6EzufVEUCoVCobgL2bMnjqtXU+nduz4Affo0KJP73FFCqFOnTvz6669OY2vWrKFTp075XuPp6Ymnp2eu8cHPvUlAQACx+xYyedl/MJ0bQJvKTxFaJZRaOiuVMwXtLxjhQgugBUmef2FZqCAh5BpBQXto47GUUNthMFwF/TXQWUFcBstlsOyC9LxWowN9sBRGHmFaNMlUSxNMxpqgz71ehUKhUCjuBWw2wccfb+Vvf1uHn58H+/e/QK1aAWV2v3IVQikpKZw8eTLn+zNnzrB3714qV65M7dq1efPNN7l06RKzZs0CYMKECURHR/PGG28wZswY1q1bx4IFC1i+fHmJ1xDZ8kkiWz7J9dRrTFv6Eu8e/4UGxx5kYPIY6tbuhmctD2rpLARkCjqf1sHp6kBvbnj3YWEdHUm1DFQKNtNWf5E6aSfBfAEsF4F40F/NFkpX5L86C9jiISsesnblvyh9sBRHplq
7 months ago
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from sklearn.metrics import precision_recall_curve, auc\n",
"\n",
"idx = 0\n",
"for cdata in lst_cdata:\n",
" y_true, y_score = cdata\n",
"\n",
" # PR 커브 계산 및 그리기\n",
" precision, recall, _ = precision_recall_curve(y_true, y_score)\n",
"\n",
" # AUC 계산\n",
" pr_auc = auc(recall, precision)\n",
" plt.plot(recall, precision, '-', color=colors[idx], label=f'{os.path.basename(base_dirs[idx])}(AUC = {pr_auc:.3f})')\n",
"\n",
" # (1, 1)에 가장 가까운 점 찾기\n",
" min_distance = float('inf')\n",
" closest_point = None\n",
" for i in range(len(recall)):\n",
" distance = ((1 - recall[i])**2 + (1 - precision[i])**2)**0.5\n",
" if distance < min_distance:\n",
" min_distance = distance\n",
" closest_point = i\n",
" plt.scatter(recall[closest_point], precision[closest_point], color=colors[idx], marker='o')\n",
"\n",
" print(f'{os.path.basename(base_dirs[idx])} PR AUC: {pr_auc:.3f}, minDist: {min_distance:.3f}, {(recall[closest_point], precision[closest_point])}')\n",
" idx += 1\n",
"\n",
"plt.plot([0.0, 1.05], [0.0, 1.05], '--', color='navy', label='baseline')\n",
"plt.xlabel('Recall')\n",
"plt.ylabel('Precision')\n",
"plt.title('PR Curve')\n",
"plt.legend()\n",
"plt.xlim([0.0, 1.0])\n",
"plt.ylim([0.0, 1.05])\n",
"plt.show()"
]
},
{
"cell_type": "code",
6 months ago
"execution_count": 9,
7 months ago
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
6 months ago
"unet ROC AUC: 0.923, minDist: 0.121, (0.03855843283619862, 0.885424512257604)\n",
"unet-mini ROC AUC: 0.949, minDist: 0.081, (0.02485883834974988, 0.9224052152557138)\n",
"unet-sgd ROC AUC: 0.955, minDist: 0.063, (0.0434974242368962, 0.9538732855195041)\n",
"unet-rmsprop ROC AUC: 0.874, minDist: 0.247, (0.0055918602005307965, 0.7531937969524044)\n",
"unet-dice-loss ROC AUC: 0.939, minDist: 0.087, (0.05330329573045489, 0.931617865125619)\n",
"unet-focal-loss ROC AUC: 0.872, minDist: 0.251, (0.004573449270014527, 0.7487617009547043)\n",
"unet-l1 ROC AUC: 0.926, minDist: 0.126, (0.024355441418179306, 0.8766366499467493)\n",
"unet-l2 ROC AUC: 0.884, minDist: 0.219, (0.013563852969138058, 0.7813983872652583)\n",
"unet-l1+l2 ROC AUC: 0.940, minDist: 0.101, (0.020355838523738234, 0.9011364203573499)\n"
7 months ago
]
},
{
"data": {
6 months ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAHHCAYAAABTMjf2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD3G0lEQVR4nOydd5xTVd6Hn5uezEymMMPQhiIIA0hTiqgoIgqivIK6Ik2xoO5iwbIqq66iK6yLBRSVXaoI9gYqi7oCioogIr33OsAwfdKT8/5xk0wySabANJjz+Lmf5J57z70nkUm++VVFCCGQSCQSiUQiqYdoansBEolEIpFIJLWFFEISiUQikUjqLVIISSQSiUQiqbdIISSRSCQSiaTeIoWQRCKRSCSSeosUQhKJRCKRSOotUghJJBKJRCKpt0ghJJFIJBKJpN4ihZBEIpFIJJJ6ixRCEolEIpFI6i1SCEkkkjKZN28eiqIEN51OR9OmTRkzZgxHjhyJOkcIwbvvvsvll19OUlISFouFTp068fzzz1NcXBzzXp9//jnXXnstqampGAwGmjRpwi233MKyZcsqtFaHw8Frr71Gr169SExMxGQy0bZtW+6//3527tx5Wq9fIpGc2yiy15hEIimLefPmcccdd/D888/TqlUrHA4Hv/76K/PmzaNly5Zs3rwZk8kUPN/r9TJixAg++ugj+vTpw4033ojFYmHlypW89957dOjQgf/973+kp6cH5wghuPPOO5k3bx7dunXj5ptvplGjRhw7dozPP/+c33//nZ9//plLLrkk5jqzs7MZOHAgv//+O9dffz39+/cnPj6eHTt28MEHH5CVlYXL5arW90oikZyFCIlEIimDuXPnCkD89ttvYeNPPPGEAMSHH34YNj5p0iQBiMceeyziWosXLxYajUYMHDgwbHzKlCkCEOPHjxc+ny9i3vz588Xq1avLXOd1110nNBqN+OSTTyKOORwO8eijj5Y5v6K43W7hdDqr5FoSiaT2kUJIIpGUSSwh9NVXXwlATJo0KThms9lEcnKyaNu2rXC73VGvd8cddwhArFq1KjgnJSVFZGZmCo/Hc1pr/PXXXwUgxo4dW6Hzr7jiCnHFFVdEjN9+++2iRYsWwf19+/YJQEyZMkW89tpr4rzzzhMajUb8+uuvQqvViueeey7iGtu3bxeAeOONN4Jjubm54qGHHhLNmjUTBoNBtG7dWvzzn/8UXq+30q9VIpFULTJGSCKRnBb79+8HIDk5OTj2008/kZuby4gRI9DpdFHn3XbbbQB89dVXwTk5OTmMGDECrVZ7WmtZvHgxAKNHjz6t+eUxd+5c3njjDe655x5eeeUVGjduzBVXXMFHH30Uce6HH36IVqvlT3/6EwA2m40rrriCBQsWcNttt/H6669z6aWXMmHCBB555JFqWa9EIqk40T+pJBKJpBT5+flkZ2fjcDhYvXo1EydOxGg0cv311wfP2bp1KwBdunSJeZ3AsW3btoU9durU6bTXVhXXKIvDhw+ze/du0tLSgmPDhg3j3nvvZfPmzVxwwQXB8Q8//JArrrgiGAP16quvsmfPHv744w/OP/98AO69916aNGnClClTePTRR8nIyKiWdUskkvKRFiGJRFIh+vfvT1paGhkZGdx8883ExcWxePFimjVrFjynsLAQgISEhJjXCRwrKCgIeyxrTnlUxTXK4qabbgoTQQA33ngjOp2ODz/8MDi2efNmtm7dyrBhw4JjH3/8MX369CE5OZns7Ozg1r9/f7xeLz/++GO1rFkikVQMaRGSSCQV4s0336Rt27bk5+czZ84cfvzxR4xGY9g5ASESEETRKC2WrFZruXPKI/QaSUlJp32dWLRq1SpiLDU1lauuuoqPPvqIF154AVCtQTqdjhtvvDF43q5du9i4cWOEkApw4sSJKl+vRCKpOFIISSSSCtGzZ0+6d+8OwJAhQ7jssssYMWIEO3bsID4+HoD27dsDsHHjRoYMGRL1Ohs3bgSgQ4cOAGRmZgKwadOmmHPKI/Qaffr0Kfd8RVEQUSqHeL3eqOebzeao47feeit33HEH69evp2vXrnz00UdcddVVpKamBs/x+XxcffXVPP7441Gv0bZt23LXK5FIqg/pGpNIJJVGq9UyefJkjh49yvTp04Pjl112GUlJSbz33nsxRcX8+fMBgrFFl112GcnJybz//vsx55TH4MGDAViwYEGFzk9OTiYvLy9i/MCBA5W675AhQzAYDHz44YesX7+enTt3cuutt4ad07p1a4qKiujfv3/UrXnz5pW6p0QiqVqkEJJIJKdF37596dmzJ1OnTsXhcABgsVh47LHH2LFjB0899VTEnK+//pp58+YxYMAALr744uCcJ554gm3btvHEE09EtdQsWLCANWvWxFxL7969GThwILNmzeKLL76IOO5yuXjssceC+61bt2b79u2cPHkyOLZhwwZ+/vnnCr9+gKSkJAYMGMBHH33EBx98g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hVCxcXFdOnShTfffLNC5+/bt4/rrruOK6+8kvXr1zN+/Hjuvvtuvvnmm2peqUQikUgkknORWm26eu2113LttddW+PwZM2bQqlUrXnnlFQDat2/PTz/9xGuvvcaAAQOqa5kSiUQikUjOUc6q7vOrVq2if//+YWMDBgxg/PjxtbMgiUQikUgkVYAA3IAdsON051BYfITCU0dw7s6j8IiWTUdM1XLns0oIZWVlkZ6eHjaWnp5OQUEBdrsds9kcMcfpdOJ0OoP7BQUF1b5OiUQikUjOXgTgJCBK1M1R5r5P2Ch2FVDgyKXQmUehI5dCRz6FzkIKncXYbQpumwmPPQ5RbMWc14S4gmbE2xoT72xIvKcBcb4k9IZEDCYLen06JqUxSXQHIM0nGDl9VrW82rNKCJ0OkydPZuLEibW9DIlEIpFITgMf4aKjtCApX6TE2nd6iil0FVPotFPoslPocFDgdFDodlP
7 months ago
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from sklearn.metrics import roc_curve, roc_auc_score\n",
"\n",
"idx = 0\n",
"for cdata in lst_cdata:\n",
" y_true, y_score = cdata\n",
"\n",
" # AUC 계산\n",
6 months ago
" roc_auc = roc_auc_score(y_true, y_score)\n",
7 months ago
"\n",
" # ROC 커브 계산 및 그리기\n",
" fpr, tpr, _ = roc_curve(y_true, y_score)\n",
6 months ago
" plt.plot(fpr, tpr, color=colors[idx], label=f'{os.path.basename(base_dirs[idx])}(AUC = {roc_auc:.3f})')\n",
7 months ago
"\n",
" # (0, 1)에 가장 가까운 점 찾기\n",
" min_distance = float('inf')\n",
" closest_point = None\n",
" for i in range(len(fpr)):\n",
" distance = ((0 - fpr[i])**2 + (1 - tpr[i])**2)**0.5\n",
" if distance < min_distance:\n",
" min_distance = distance\n",
" closest_point = i\n",
" plt.scatter(fpr[closest_point], tpr[closest_point], color=colors[idx], marker='o')\n",
"\n",
6 months ago
" print(f'{os.path.basename(base_dirs[idx])} ROC AUC: {roc_auc:.3f}, minDist: {min_distance:.3f}, {(fpr[closest_point], tpr[closest_point])}')\n",
7 months ago
" idx += 1\n",
"\n",
"plt.plot([0.0, 1.05], [0.0, 1.05], '--', color='navy', label='baseline')\n",
"plt.xlabel('FPR')\n",
"plt.ylabel('TPR')\n",
"plt.title('ROC Curve')\n",
"plt.legend()\n",
"plt.xlim([0.0, 1.0])\n",
"plt.ylim([0.0, 1.05])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA8YAAAPeCAYAAADOFAM3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1gUV/s//nuXXgUUsUuQKFGiJPooXyWWTyzhMRqJlScaNWoSoybymFhSjCW2WKOJqLFg/MTejVhjibFXJPaGoKggXfru3r8//LEfkTbAzJ6Bfb+u631diSxnzpxdj3PvzJzRMDMTAAAAAAAAgJnSiu4AAAAAAAAAgEgojAEAAAAAAMCsoTAGAAAAAAAAs4bCGAAAAAAAAMwaCmMAAAAAAAAwayiMAQAAAAAAwKyhMAYAAAAAAACzhsIYAAAAAAAAzBoKYwAAAAAAADBrKIwBAAAqoUmTJpFGoynT74aFhZFGo6GoqCh5OwUA8BJPT08aNGiQ8f+PHDlCGo2Gjhw5YtJ+YN4DFMagarGxsTRp0iS6dOmS6K4AAJQZ5jIAqEwwp0FlhMIYVC02NpYmT56MiRcAKjQRc9m3335LmZmZZfrdAQMGUGZmJtWvX1/mXgFAZaDknNa2bVvKzMyktm3byt42QHEsRXcAAAAA5GdpaUmWlmX7Z97CwoIsLCxk7hEAQMm0Wi3Z2tqK7gaYIZwxBkkGDRpEnp6eBf785XvYNBoNjRw5krZv306+vr5kY2NDTZo0ob179xb43YcPH9JHH31EHh4extetXLnS+PMjR47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HGC2rRpQ0uWLKEffviBiJ4/hurtt9+mt99+m+bNm0fTp0+nb775hg4fPlzieINp4Nw9SNKgQQNKSUmhy5cvG//s0aNHtG3btlK3ZWFhQT179qQtW7bQP//8U+DnL17i4uDgQERU6KQPAFBaapvLvLy8qGPHjsa0adOm1P0AAPNVUea0jh07kpWVFS1atCjf1SkLFiwosV9vvvkmvfLKK7RgwYIC28trq3r16tS+fXtaunQpPXr0qMi+29ra5utfx44di7yUu2PHjmRtbU0LFy7M1+cVK1ZQSkoKde3alYiIUlNTSafT5fvd119/nbRaLWVnZxPR83ugX+bn50dEZHwNiIczxiBJv379aNy4cRQUFESff/45ZWRkUGhoKDVs2LBMCzHMnDmTDh8+TK1ataJhw4ZR48aNKTExkS5cuEAHDx40TiANGjQgFxcXWrJkCTk5OZGDgwO1atWqwGUwAABSYC4DgMqkosxp7u7u9OWXX9KMGTPo3XffpX//+9908eJF2rNnD1WrVq3YPmm1WgoNDaVu3bqRn58fDR48mGrWrEnXr1+nK1eu0L59+4iI6JdffqGAgAB6/fXXadiwYeTl5UVPnjyhkydP0oMHDygiIqJUY+Hu7k4TJkygyZMn0zvvvEPdu3enGzdu0OLFi+lf//oX9e/fn4iIDh06RCNHjqTevXtTw4YNSafT0Zo1a4xfNBARTZkyhf766y/q2rUr1a9fn+Li4mjx4sVUp06dfGfYQSwUxiBJ1apVadu2bfTf//6Xxo4dS6+88grNmDGDbt26VaaJ18PDg86cOUNTpkyhrVu30uLFi6lq1arUpEkTmjVrlvF1VlZWtHr1apowYQJ9+umnpNPpaNWqVTiYBIAywVwGAJVJRZrTfvjhB7K1taUlS5YYi+/9+/cbz7wWp0uXLnT48GGaPHkyzZ07lwwGAzVo0ICGDRtmfE3jxo3p3LlzNHnyZAoLC6OEhASqXr06vfHGGzRx4sRSjwXR8+cYu7u7088//0whISHk5uZGH3/8MU2
"text/plain": [
"<Figure size 1000x1000 with 9 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"id = 7\n",
"\n",
"fig, axs = plt.subplots(3, 3, figsize=(10, 10))\n",
"idx = 0\n",
"for base_dir in base_dirs:\n",
" result_dir = os.path.join(base_dir, 'result')\n",
"\n",
" ##\n",
" lst_data = os.listdir(os.path.join(result_dir, 'numpy'))\n",
"\n",
" lst_gt = [f for f in lst_data if f.startswith('gt')]\n",
" lst_pr = [f for f in lst_data if f.startswith('pr')]\n",
"\n",
" lst_gt.sort()\n",
" lst_pr.sort()\n",
"\n",
" ##\n",
" # img = np.load(os.path.join(result_dir,\"numpy\", lst_img[id]))\n",
" # gt = np.load(os.path.join(result_dir,\"numpy\", lst_gt[id]))\n",
" pr = np.load(os.path.join(result_dir,\"numpy\", lst_pr[id]))\n",
"\n",
" axs[idx//3,idx%3].imshow(pr, cmap='gray')\n",
" axs[idx//3,idx%3].axis('off')\n",
" axs[idx//3,idx%3].set_title(f'{os.path.basename(base_dir)}')\n",
"\n",
" idx += 1\n",
"\n",
"plt.tight_layout()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 2
}