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.
377 lines
407 KiB
Plaintext
377 lines
407 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-dice-loss',\n",
|
||
|
" './2nd_Battery/unet-focal-loss',\n",
|
||
|
" './2nd_Battery/unet-sgd',\n",
|
||
|
" './2nd_Battery/unet-rmsprop',\n",
|
||
|
" './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",
|
||
|
"losses = [0.2072, 0.1324, 0.3879, 0.0112, 0.1787, 0.1666, 0.0357, 0.0241, 0.0550]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"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-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",
|
||
|
"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",
|
||
|
"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",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAGzCAYAAADaCpaHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAADr0UlEQVR4nOydd3hTZRuH7zTdk9WyoZS9LBvZW/aSDQrIUKYCiop+LBURBVFxoGzZG1FBkCV7711W2VAK3TPJ+/3xtklDd5vu976uXG1OznjOSM7vPO8zNEIIgUKhUCgUCkUOxSqrDVAoFAqFQqFID0rMKBQKhUKhyNEoMaNQKBQ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54/f26cFhkZKfLlyyeGDBmS5DE4cuSIAMTvv/9unBZ7vPfu3Wt2XAYNGhRv+WbNmolmzZoZ3+t0OhEZGWk2z4sXL0ThwoXNbPHz8xOAmDp1arx1Tp06VcT9yUnLNZTc+UuILVu2CEB88cUXZtN79uwpNBqNuHHjhtl+V61aNcn1pXTezZs3C0B8//33ZvsR93jfvn1bAOKbb74xWzb2XK1fv95seqtWrUT16tVFRESEcZrBYBANGzYU5cuXN06L/X1o3Lix0Ol0xunBwcEiX758Yvjw4Wbrffz4sXBzczObHnudfvbZZ2bz1qxZU9SuXdv4PqlznhBx9+2vv/4SGo1G3L17VwghxMSJE43f3ZePb0qvl6dPnwpbW1vRsWNH43dWCCE++eQ
|
||
|
"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",
|
||
|
"model_list = ['unet', 'mini', 'dice-loss', 'focal-loss', 'SGD', 'RMSProp', 'L1-loss', 'L2-loss', 'L1+L2-loss']\n",
|
||
|
"\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",
|
||
|
"execution_count": 4,
|
||
|
"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-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",
|
||
|
"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",
|
||
|
"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": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAHHCAYAAABTMjf2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3iUZfq2z2npjRpCCEnoNaEjCoKAAgooiCACEw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bsWMHR48edVWVhBA88cQT3HHHHXz33XfodDoAHn/8cdq3b89f//pXvv/++xq7b4VCcWUoIaRQKK6YgQMHenwcHR3N3LlziYyM9Ng+adIkj48bNGjA7Nmz6d69e7nXz8rKAiA4ONgLd1s6TzzxRIltY8aM4bnnnuPIkSM0b94cgIULF+Lr6+sSZTt37uTQoUP89a9/5dKlSx7nDxgwgNmzZ2O329HrVQFeobgWUUJIoVBcMVOnTqVVq1YYjUbCw8Np3bp1qW/8f//73+nTpw85OTksXbqUBQsWVEoghISEALKiVFPExsaW2PbAAw/wwgsvsHDhQl599VWEECxevJghQ4a47unQoUMAJCQklHntzMzMSi3/KRSKq48SQgqF4orp0aOHa2qsPDp27OiqHt13333k5eXx6KOP0rt3b6Kioso8LyQkhMaNG7N79+5K3Y9zeao4NputzHP8/f1LbGvcuDF9+vRh0aJFvPrqq2zbto0TJ07wr3/9y3WM3W4H4N1336VTp06lXjsoKKhS961QKK4+qlarUChqjX/+858UFBTw1ltvVXjs0KFDOXLkCFu3bq3wWGf1JSMjw2N7aRNgFTFmzBiSk5M5cOAACxcuJCAggGHDhrn2O5fMQkJCGDhwYKkPk8lU5edVKBRXByWEFApFrdG8eXPuv/9+Zs2aRVpaWrnHvvzyywQGBvLII494uFY7OXLkCB999BEgRUn9+vXZuHGjxzH/+9//qnyP999/PwaDgfnz57N48WKGDh3q4THUtWtXmjdvznvvvUdOTk6J8y9cuFDl51QoFFcPtTSmUChqlZdeeolFixbx4Ycf8s9//rPM45o3b868efMYM2YMbdu29XCW3rJlC4sXL2bixImu4x955BH++c9/8sgjj9CtWzc2btzIwYMHq3x/DRs25I477uCDDz4gOzubMWPGeOzX6/VMnz6dIUOG0L59ex5++GEiIyM5ffo069atIyQkhBUrVlT5eRUKxdVBVYQUCkWt0q1bN/r168e0adPIzMws99jhw4eTkpLCqFGjWLZsGU899RR//vOfSU1N5f333+fjjz92Hfv3v/+dyZMn8+WXX/Lyyy9js9n47rvvqnWPY8aMITs7m+DgYO6+++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I6xcbryX0Ibf0tl/Do3EMnkRG5AH5PqCLQJsjeVDFwV6h1AyNQO/+lIk+fqAr0mKJf11tRqpUCgUCkWt8NtvZzl/PpfBg1sAMGRIyxp5nutKCPXq1Ytvv/3WY9uaNWvo1atXmef4+vri6+tbYvudE18hJCSEzFOLWfnDvzi7czgRPqOJrBdJE52NuoWCHieNcDIOiCPL98+siLSR0fgYYfVX08X3MyLtJ8GYKh/FsQHZwZDRWBNKtkjQNXUsv8WAb7CbSHITTEosKRQKheImxW4XvPfeFv7617UEBfmQkvIkTZqE1Njz1aoQysnJ4fDhw66Pjx07xs6dO6lbty5NmzbllVde4fTp0yQlJQHwxBNPMGXKFF5++WUmTZrE2rVrWbRoEStXrqz2PYQ2eYCHJj4A4gLHUv7IgmMrOfbd7fQ8M4lmTfvh28SHJjorIYWC3kcNcLQF0IJL/k+zOBqyogqoE3mUrj4biC74DSzHwHYcxEXQZ4P+AJgOlP7khfUhz00kOf/VR4E
|
||
|
"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",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"unet ROC AUC: 0.789, minDist: 0.121, (0.03855843283619862, 0.885424512257604)\n",
|
||
|
"unet-mini ROC AUC: 0.789, minDist: 0.081, (0.02485883834974988, 0.9224052152557138)\n",
|
||
|
"unet-dice-loss ROC AUC: 0.789, minDist: 0.087, (0.05330329573045489, 0.931617865125619)\n",
|
||
|
"unet-focal-loss ROC AUC: 0.789, minDist: 0.251, (0.004573449270014527, 0.7487617009547043)\n",
|
||
|
"unet-sgd ROC AUC: 0.789, minDist: 0.063, (0.0434974242368962, 0.9538732855195041)\n",
|
||
|
"unet-rmsprop ROC AUC: 0.789, minDist: 0.247, (0.0055918602005307965, 0.7531937969524044)\n",
|
||
|
"unet-l1 ROC AUC: 0.789, minDist: 0.126, (0.024355441418179306, 0.8766366499467493)\n",
|
||
|
"unet-l2 ROC AUC: 0.789, minDist: 0.219, (0.013563852969138058, 0.7813983872652583)\n",
|
||
|
"unet-l1+l2 ROC AUC: 0.789, minDist: 0.101, (0.020355838523738234, 0.9011364203573499)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAHHCAYAAABTMjf2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD3UklEQVR4nOydeXxTVd6Hn5s9adqmpaVQWvalBZVVFBBFRAGVEVBBAQVR1BlcEPdxHLd3cGbcQHHEYVVBEdz3ZRBcERVl32STraxtumbPef+4SZo0SRdoaaHn8XM/Te49595zI0m++a2KEEIgkUgkEolE0gjR1PcCJBKJRCKRSOoLKYQkEolEIpE0WqQQkkgkEolE0miRQkgikUgkEkmjRQohiUQikUgkjRYphCQSiUQikTRapBCSSCQSiUTSaJFCSCKRSCQSSaNFCiGJRCKRSCSNFimEJBKJRCKRNFqkEJJIJJWyYMECFEUJbTqdjhYtWjBhwgT2798fc44Qgtdee43zzz8fm82GxWLhzDPP5PHHH6e0tDTutd59912GDh1KWloaBoOBzMxMRo0axVdffVWttTqdTp577jnOOecckpOTMZlMdOzYkdtuu41t27Yd1/1LJJLTG0X2GpNIJJWxYMECbrjhBh5//HHatGmD0+nkxx9/ZMGCBbRu3ZoNGzZgMplC430+H2PGjGHJkiX079+fkSNHYrFY+Pbbb3n99dfp3Lkz//vf/8jIyAjNEUIwceJEFixYQPfu3bnqqqto1qwZeXl5vPvuu6xevZrvv/+evn37xl3n0aNHGTJkCKtXr+byyy9n0KBBWK1Wtm7dyuLFizl48CBut7tOXyuJRHIKIiQSiaQS5s+fLwDx888/R+y///77BSDefPPNiP3Tpk0TgLjnnnuizvXBBx8IjUYjhgwZErH/qaeeEoCYMmWK8Pv9UfNeffVVsWrVqkrXedlllwmNRiPeeuutqGNOp1Pcfffdlc6vLh6PR7hcrlo5l0QiqX+kEJJIJJUSTwh99NFHAhDTpk0L7SsrKxMpKSmiY8eOwuPxxDzfDTfcIACxcuXK0JzU1FSRk5MjvF7vca3xxx9/FICYNGlStcZfcMEF4oILLojaP378eNGqVavQ8127dglAPPXUU+K5554Tbdu2FRqNRvz4449Cq9WKRx99NOocW7ZsEYB44YUXQvsKCgrEnXfeKbKysoTBYBDt2rUT//znP4XP56vxvUokktpFxghJJJLjYvfu3QCkpKSE9n333XcUFBQwZswYdDpdzHnXX389AB999FFoTn5+PmPGjEGr1R7XWj744AMArrvuuuOaXxXz58/nhRde4Oabb+aZZ56hefPmXHDBBSxZsiRq7JtvvolWq+Xqq68GoKysjAsuuICFCxdy/fXX8/zzz9OvXz8efPBBpk6dWifrlUgk1Sf2J5VEIpFUoLCwkKNHj+J0Olm1ahWPPfYYRqORyy+/PDRm06ZNAHTt2jXueYLHNm/eHPH3zDPPPO611cY5KmPfvn1s376d9PT00L7Ro0dzyy23sGHDBs4444zQ/jfffJMLLrggFAP17LPPsmPHDn777Tc6dOgAwC233EJmZiZPPfUUd999N9nZ2XWybolEUjXSIiSRSKrFoEGDSE9PJzs7m6uuuoqEhAQ++OADsrKyQmOKi4sBSExMjHue4LGioqKIv5XNqYraOEdlXHnllREiCGDkyJHodDrefPPN0L4NGzawadMmRo8eHdq3dOlS+vfvT0pKCkePHg1tgwYNwufz8c0339TJmiUSSfWQFiGJRFItXnzxRTp27EhhYSHz5s3jm2++wWg0RowJCpGgIIpFRbGUlJRU5ZyqCD+HzWY77vPEo02bNlH70tLSuOiii1iyZAlPPPEEoFqDdDodI0eODI37/fffWbduXZSQCnL48OFaX69EIqk+UghJJJJq0bt3b3r16gXA8OHDOe+88xgzZgxbt27FarUCkJubC8C6desYPnx4zPOsW7cOgM6dOwOQk5MDwPr16+POqYrwc/Tv37/K8YqiIGJUDvH5fDHHm83mmPuvueYabrjhBtasWUO3bt1YsmQJF110EWlpaaExfr+fiy++mPvuuy/mOTp27FjleiUSSd0hXWMSiaTGaLVannzySQ4cOMDMmTND+8877zxsNhuvv/56XFHx6quvAoRii8477zxSUlJ444034s6pimHDhgGwcOHCao1PSUnBbrdH7f/jjz9qdN3hw4djMBh48803WbNmDdu2beOaa66JGNOuXTtKSkoYNGhQzK1ly5Y1uqZEIqldpBCSSCTHxYABA+jduzfTp0/H6XQCYLFYuOeee9i6dSsPPfRQ1JyPP/6YBQsWMHjwYM4999zQnPvvv5/Nmzdz//33x7TULFy4kJ9++inuWvr06cOQIUOYM2cO7733XtRxt9vNPffcE3rerl07tmzZwpEjR0L71q5dy/fff1/t+wew2WwMHjyYJUuWsHjxYgwGQ5RVa9SoUaxcuZLPP/88ar7dbsfr9dbomhKJpHaRlaUlEkmlBCtL//zzzyHXWJC33nqLq6++mpdeeolbb70VUN1Lo0eP5u233+b888/nyiuvxGw2891337Fw4UJyc3NZtmxZRGVpv9/PhAkTeO211+jRo0eosvTBgwd57733+Omnn/jhhx/o06dP3HUeOXKESy65hLVr1zJs2DAuuugiEhIS+P3331m8eDF5eXm4XC5AzTI744wz6Nq1KzfeeCOHDx9m1qxZZGRkUFRUFCoNsHv3btq0acNTTz0VIaTCWbRoEePGjSMxMZEBAwaEUvmDlJWV0b9/f9atW8eECRPo2bMnpaWlrF+/nrfeeovdu3dHuNIkEslJpn7LGEkkkoZOvIKKQgjh8/lEu3btRLt27SKKIfp8PjF//nzRr18/kZSUJEwmk+jSpYt47LHHRElJSdxrvfXWW+KSSy4RqampQqfTiebNm4vRo0eLFStWVGutZWVl4umnnxZnn322sFqtwmAwiA4dOojbb79dbN++PWLswoULRdu2bYXBYBDdunUTn3/+eaUFFeNRVFQkzGazAMTChQtjjikuLhYPPvigaN++vTAYDCItLU307dtXPP3008Ltdlfr3iQSSd0gLUISiUQikUgaLTJGSCKRSCQSSaNFCiGJRCKRSCSNFimEJBKJRCKRNFqkEJJIJBKJRNJokUJIIpFIJBJJo0UKIYlEIpFIJI2WRtdrzO/3c+DAARITE1EUpb6XI5FIJBKJpBoIISguLiYzMxONpvbsOI1OCB04cIDs7Oz6XoZEIpFIJJLjYO/evWRlZdXa+RqdEEpMTATUFzIpKameVyORSCQSiaQ6FBUVkZ2dHfoery0anRAKusOSkpKkEJJIJBKJ5BSjtsNaZLC0RCKRSCSSRosUQhKJRCKRSBotUghJJBKJRCJptEghJJFIJBKJpNEihZBEIpFIJJJGixRCEolEIpFIGi1SCEkkEolEImm0SCEkkUgkEomk0SKFkEQikUgkkkaLFEISiUQikUgaLfUqhL755huGDRtGZmYmiqLw3nvvVTlnxYoV9OjRA6PRSPv27VmwYEGdr1MikUgkEsnpSb0KodLSUrp27cqLL75YrfG7du3isssu48ILL2TNmjVMmTKFm266ic8//7yOVyqRSCQSieR0pF6brg4dOpShQ4dWe/ysWbNo06YNzzzzDAC5ubl89913PPfccwwePLiulimRSCQSieQ05ZTqPr9y5UoGDRoUsW/w4MFMmTKlfhYkkUgkEonkhBFC4PF7cHgcOLwOHO4CnM59OAv2499px3VQy6Y8U51c+5QSQgcPHiQjIyNiX0ZGBkVFRTgcDsxmc9Qcl8uFy+UKPS8qKqrzdUokEolEcqoihMDlc5WLEo8Dp9cZeuzwBp5HHHfg8Bbi8NhxuAtUIeMpxOEpxuEpRbgV9B4zBo8FozuJJqUtSC9rQZq7Oaneptj8TbApNkzGZIxmC3p9UxKVZmjpBYDfL5gwc06d3O8pJYSOhyeffJLHHnusvpchkUgkEkmN8Qt/hOioKEBii5IYoiXm+DIcntKAiCnD4XHi8Dp
|
||
|
"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",
|
||
|
" auc = roc_auc_score(y_true, y_score)\n",
|
||
|
"\n",
|
||
|
" # ROC 커브 계산 및 그리기\n",
|
||
|
" fpr, tpr, _ = roc_curve(y_true, y_score)\n",
|
||
|
" plt.plot(fpr, tpr, color=colors[idx], label=f'{os.path.basename(base_dirs[idx])}(AUC = {auc:.3f})')\n",
|
||
|
"\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",
|
||
|
" print(f'{os.path.basename(base_dirs[idx])} ROC AUC: {pr_auc:.3f}, minDist: {min_distance:.3f}, {(fpr[closest_point], tpr[closest_point])}')\n",
|
||
|
" 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": "iVBORw0KGgoAAAANSUhEUgAAA8YAAAPeCAYAAADOFAM3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90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uIU7SMAQElMMZc9e/aMnj17Zvx/CwsLcnd3L7IPeQdgdevWLfTP8/pWnJL2CwAqJ5Fz2v3794mI6NVXX833end3d3J1dS22zTt37hARka+vb5GvuX37NjEzfffdd/Tdd98V2fcaNWpQfHx8vj93c3Mja2vrAq/P63OjRo3y/bm1tTV5eXkZf/7KK6/Qf//7X5o3bx79/vvv9NZbb1H37t2pf//+xrm5b9++tHz5cho6dCiNHz+e3n77bXr//fepV69eJd7+AqaDwhgkeXkBlzx6vb7AnxW1kikzExEZvynr378/DRw4sNDXNm3atCzdBAAoltrmsjlz5tDkyZON/1+/fv18C14V1YeS+lac8vwuAKhLRZvTlJLX9y+//JK6dOlS6Gu8vb0pJiaGXnnllXx/fvjwYWrfvn25tj937lwaNGgQ7dixg/bv30+ff/45zZgxg06dOkV16tQhOzs7+uuvv+jw4cO0e/du2rt3L23YsIH+53/+h/bv34+nAKgECmOQxNXVtcAKfET/921aabi7u5OTkxPp9Xrq2LFjsa8tasIHACgLtc1lH374IQUEBBj/387OrtT9AADzVVHmtLxnot+6dYu8vLyMP4+Pjy/xapW8y7//+eefIvuV16aVlVWxfbeysqIDBw7k+7NmzZoV+tq8Pt+4cSNfn3NycujevXsFtvP666/T66+/Tt9++y2dOHGC2rRpQ0uWLKEffviBiJ4/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
|
||
|
}
|