Newer
Older
" # ---- done\n",
" size=os.path.getsize(filename)/(1024*1024)\n",
" print('Dataset : {:24s} shape : {:22s} size : {:6.1f} Mo (saved)\\n'.format(filename, str(x_train.shape),size))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class='todo'>\n",
" Create enhanced datasets and save them will take about 7-8' and using about 9 GB<br>\n",
" To perform tests, change the code below to use :\n",
" <li> a local folder (./data),\n",
" <li>a subset of the dataset, for example 2000 images.\n",
"</div>"
"# ---- Uncomment to write h5 datasets in the project place\n",
"#\n",
"output_dir = dataset_dir\n",
"\n",
"# ---- Uncomment to write h5 datasets in a local place (for small tests only !)\n",
"#\n",
"# output_dir = './data'\n",
"# ooo.mkdir(output_dir)\n",
"\n",
"for s in [24, 48]:\n",
" for m in ['RGB', 'RGB-HE', 'L', 'L-LHE']:\n",
" # ---- A nice dataset name\n",
" filename = f'{output_dir}/set-{s}x{s}-{m}.h5'\n",
" print(\"\\nDataset : \",filename)\n",
" # ---- Enhancement\n",
" x_train_new = images_enhancement( x_train, width=s, height=s, mode=m )\n",
" x_test_new = images_enhancement( x_test, width=s, height=s, mode=m )\n",
" x_meta_new = images_enhancement( x_meta, width=s, height=s, mode='RGB' )\n",
" save_h5_dataset( x_train_new, y_train, x_test_new, y_test, x_meta_new,y_meta, filename)\n",
"\n",
"x_train_new,x_test_new=0,0\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class='todo'>\n",
" Adapt the code below to read :\n",
" <ul>\n",
" <li>the different h5 datasets you saved in ./data,</li>\n",
" <li>The h5 datasets available in the Fidle project datasets directory.</li>\n",
" </ul>\n",
" \n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"with h5py.File(f'{output_dir}/{dataset}.h5','r') as f:\n",
" x_tmp = f['x_train'][:]\n",
" y_tmp = f['y_train'][:]\n",
" print(\"dataset loaded from h5 file.\")\n",
"\n",
"ooo.plot_images(x_tmp,y_tmp, samples, columns=8, x_size=2, y_size=2, colorbar=False, y_pred=None, cm='binary')\n",
"x_tmp,y_tmp=0,0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img width=\"80px\" src=\"../fidle/img/00-Fidle-logo-01.svg\"></img>"
]
}
],
"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",
}
},
"nbformat": 4,
"nbformat_minor": 4
}