CVSplit
This commit is contained in:
parent
27184025c9
commit
1badfb9710
@ -34,7 +34,7 @@
|
|||||||
"sys.path.append(str(Path('..').resolve()))\n",
|
"sys.path.append(str(Path('..').resolve()))\n",
|
||||||
"import ld2dap\n",
|
"import ld2dap\n",
|
||||||
"\n",
|
"\n",
|
||||||
"sys.path.append(str(Path('../triskele/').resolve()))\n",
|
"sys.path.append(str(Path('../triskele/python').resolve()))\n",
|
||||||
"import triskele"
|
"import triskele"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -77,7 +77,7 @@
|
|||||||
" '../Data/phase1_rasters/Intensity_C3/UH17_GI3F051_TR.tif',\n",
|
" '../Data/phase1_rasters/Intensity_C3/UH17_GI3F051_TR.tif',\n",
|
||||||
" #'../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif',\n",
|
" #'../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif',\n",
|
||||||
" #'../Res/HVR/C123_num_returns_0_5_nearest.tif',\n",
|
" #'../Res/HVR/C123_num_returns_0_5_nearest.tif',\n",
|
||||||
" '../Res/HVR noisy/C123_num_returns_0_5_nearest.tif'\n",
|
" #'../Res/HVR noisy/C123_num_returns_0_5_nearest.tif'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"]"
|
"]"
|
||||||
]
|
]
|
||||||
@ -177,15 +177,6 @@
|
|||||||
"out_vectors.run()"
|
"out_vectors.run()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"out_vectors.data.shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -209,6 +200,35 @@
|
|||||||
"### Vectors"
|
"### Vectors"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"out_vectors.data.shape"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Ground Truth"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"gt = triskele.read('../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif')\n",
|
||||||
|
"\n",
|
||||||
|
"plt.figure(figsize=figsize)\n",
|
||||||
|
"plt.imshow(gt)\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
"# Triskele\n",
|
"# Triskele\n",
|
||||||
"import sys\n",
|
"import sys\n",
|
||||||
"from pathlib import Path\n",
|
"from pathlib import Path\n",
|
||||||
"triskele_path = Path('../triskele/python/')\n",
|
"triskele_path = Path('../triskele')\n",
|
||||||
"sys.path.append(str(triskele_path.resolve()))\n",
|
"sys.path.append(str(triskele_path.resolve()))\n",
|
||||||
"import triskele"
|
"import triskele"
|
||||||
]
|
]
|
||||||
@ -62,7 +62,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"count = np.unique(gt, return_counts=True)\n",
|
"count = np.unique(gt, return_counts=True)\n",
|
||||||
"lbl = pd.read_csv('../Data/ground_truth/labels.csv', header=None, names=['Label'], index_col=0)\n",
|
"lbl = pd.read_csv('../labels.csv', index_col=0)\n",
|
||||||
"lbl['Count'] = count[1]\n",
|
"lbl['Count'] = count[1]\n",
|
||||||
"lbl"
|
"lbl"
|
||||||
]
|
]
|
||||||
@ -74,11 +74,11 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"plt.bar(*count, log=True)\n",
|
"plt.bar(*count, log=True)\n",
|
||||||
"plt.xticks(lbl.index.values,lbl['Label'], rotation=90)\n",
|
"plt.xticks(lbl.index.values,lbl['label'], rotation=90)\n",
|
||||||
"plt.show()\n",
|
"plt.show()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"plt.bar(count[0][1:], count[1][1:])\n",
|
"plt.bar(count[0][1:], count[1][1:])\n",
|
||||||
"plt.xticks(lbl.index.values[1:], lbl['Label'][1:], rotation=90)\n",
|
"plt.xticks(lbl.index.values[1:], lbl['label'][1:], rotation=90)\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -134,23 +134,31 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"nb_split = 10\n",
|
"nb_split = 10\n",
|
||||||
"step = 0\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"test_part = 1 / nb_split\n",
|
"def semantic_cvg(gt, nb_split, step=0):\n",
|
||||||
|
" test_part = 1 / nb_split\n",
|
||||||
"\n",
|
"\n",
|
||||||
"split = np.zeros_like(gt)\n",
|
" split = np.zeros_like(gt)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for lbli, lblc in zip(count[0][1:], count[1][1:]):\n",
|
" for lbli, lblc in zip(count[0][1:], count[1][1:]):\n",
|
||||||
" treshold = int(lblc * test_part)\n",
|
" treshold = int(lblc * test_part)\n",
|
||||||
" #print('lbli:{}, count:{}, train:{}'.format(lbli, lblc, treshold))\n",
|
" #print('lbli:{}, count:{}, train:{}'.format(lbli, lblc, treshold))\n",
|
||||||
" f = np.nonzero(gt == lbli)\n",
|
" f = np.nonzero(gt == lbli)\n",
|
||||||
" train, test\n",
|
" t_int, t_ext = treshold * step, treshold * (step + 1)\n",
|
||||||
" split[f[0][treshold * step:treshold * (step + 1)], f[1][:treshold]] = 2\n",
|
" split[f[0], f[1]] = 1\n",
|
||||||
" split[f[0][treshold:], f[1][treshold:]] = 1\n",
|
" split[f[0][t_int:t_ext], f[1][t_int:t_ext]] = 2\n",
|
||||||
" \n",
|
"\n",
|
||||||
"plt.figure(figsize=fs)\n",
|
" return split\n",
|
||||||
"plt.imshow(split)\n",
|
"\n",
|
||||||
|
"fig, axs = plt.subplots(nb_split, figsize=fs * nb_split)\n",
|
||||||
|
"\n",
|
||||||
|
"for i in range(nb_split):\n",
|
||||||
|
" split = semantic_cvg(gt, nb_split, i)\n",
|
||||||
|
"\n",
|
||||||
|
" axs[i].imshow(split)\n",
|
||||||
|
" axs[i].set_title(i)\n",
|
||||||
"#plt.imshow(split * (gt==1))\n",
|
"#plt.imshow(split * (gt==1))\n",
|
||||||
|
"plt.savefig('../Res/cross_valid_split_{}.png'.format(nb_split))\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user