atom-predict/msunet/DataPostprocess_xj.ipynb

159 lines
4.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"id": "50d8ca6f-b598-42c1-899c-b1ba79626ea3",
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-19T14:59:12.510556Z",
"start_time": "2024-06-19T14:59:12.508427Z"
}
},
"outputs": [],
"source": [
"import os\n",
"import cv2\n",
"import json\n",
"import glob\n",
"import seaborn as sns\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from PIL import Image\n",
"from skimage.measure import label\n",
"from skimage.measure import regionprops\n",
"from utils.labelme import save_pred_to_json"
]
},
{
"cell_type": "markdown",
"id": "ae3b40f8-562b-4e5f-b932-6509312dfbf4",
"metadata": {},
"source": [
"# Results 2 Json"
]
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
},
"id": "c0ff45ece0c1cbce"
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-19T14:59:12.513555Z",
"start_time": "2024-06-19T14:59:12.512256Z"
}
},
"id": "6432dcb82eeece17",
"execution_count": 10
},
{
"cell_type": "code",
"execution_count": 11,
"id": "c17ce107-cac1-4b58-96f2-a183adb730d6",
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-19T14:59:12.515700Z",
"start_time": "2024-06-19T14:59:12.514193Z"
}
},
"outputs": [],
"source": [
"json_path = '/home/gao/mouclear/cc/code/egnn_xj/logs/0/version_0/e2e.json'\n",
"save_path = '/home/gao/mouclear/cc/data/xj/e2e/test_result'\n",
"\n",
"os.makedirs(save_path, exist_ok=True)"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "1a19235160edda72"
},
{
"cell_type": "code",
"execution_count": 12,
"id": "a1328c78-b657-488c-a444-fa737732e6b3",
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-19T14:59:12.535474Z",
"start_time": "2024-06-19T14:59:12.516392Z"
}
},
"outputs": [
{
"ename": "KeyError",
"evalue": "'img_path'",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mKeyError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[12], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43msave_pred_to_json\u001B[49m\u001B[43m(\u001B[49m\u001B[43mjson_path\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msave_path\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/mouclear/cc/code/msunet/utils/labelme.py:187\u001B[0m, in \u001B[0;36msave_pred_to_json\u001B[0;34m(json_path, save_path)\u001B[0m\n\u001B[1;32m 185\u001B[0m pred \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39marray(data[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mpred\u001B[39m\u001B[38;5;124m'\u001B[39m])\n\u001B[1;32m 186\u001B[0m lb \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39marray(data[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mlabel\u001B[39m\u001B[38;5;124m'\u001B[39m], dtype\u001B[38;5;241m=\u001B[39mnp\u001B[38;5;241m.\u001B[39muint8)\n\u001B[0;32m--> 187\u001B[0m img_path \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39marray(\u001B[43mdata\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mimg_path\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m]\u001B[49m)\n\u001B[1;32m 188\u001B[0m nums \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlen\u001B[39m(img_path)\n\u001B[1;32m 190\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m i \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mrange\u001B[39m(nums):\n",
"\u001B[0;31mKeyError\u001B[0m: 'img_path'"
]
}
],
"source": [
"save_pred_to_json(json_path, save_path)"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-19T14:59:12.536233Z",
"start_time": "2024-06-19T14:59:12.536167Z"
}
},
"id": "b397dc686cd9faed",
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
"id": "b026e354-a04f-4f93-99c7-6159e94391c3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3 (ipykernel)"
},
"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.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}