Commit 40a82528 authored by walker's avatar walker
Browse files

major updates: bugfixes in data augmentation and padding. new features: pad...

major updates: bugfixes in data augmentation and padding. new features: pad training data automatically, can itnensity normalize full img stack jointly
parent 32634b70
......@@ -56,7 +56,7 @@
"\n",
"from unet2d.visualize import show_image, show_image_and_onehotmask\n",
"from unet2d.visualize import show_some_images_and_onehotmasks, show_some_images\n",
"from unet2d.data import normalize, pad_image, remove_padding\n",
"from unet2d.data import normalize, pad_image, remove_padding, normalize_list_jointly\n",
"from unet2d.io import load_images, save_images\n",
"from unet2d.postprocess import create_segmentations, cleanup_segmentations\n",
"from unet2d.utils import limit_gpu_memory, infer_network_downsampling\n",
......@@ -78,23 +78,31 @@
"outputs": [],
"source": [
"# == paths ==\n",
"model_file=\"models/instance/model_best.h5\"\n",
"prediction_images=\"../data/kaggle2018/for_deploy/*tif\" # path with asterix\n",
"save_dir=\"../results/\"\n",
"model_file=\"model_best.h5\";#\"models/instance/model_best.h5\"\n",
"prediction_images=\"../data/wingdisk/96h/unused/images/*tif\" # path with asterix\n",
"save_dir=\"../data/wingdisk/96h/resultspreds/\"\n",
"\n",
"# intensity normalization (use the same as in training!)\n",
"#axis_norm = (0,1) # normalize channels independently (normalize per image)\n",
"axis_norm = (0,1,2) # normalize channels jointly (normalize per image)\n",
"norm_all_together=True # if True: ignores the axis_norm and normalizes all images and channels together\n",
"\n",
"\n",
"# == create label images from prediction probabilities ==\n",
"sigma=1 # if >0: smooth prediction probabities\n",
"\n",
"# predicted classes. correspondence to one-hot encoding: 0 -> [1,0,0...], 1 -> [0,1,0...]. \n",
"class_objects=1 # default=1. usually don't change (typical: background=0, objects=1). assumes that one class belongs to object of interest\n",
"class_borders=2 # None or 2. (use None if no border class)\n",
"class_borders=None # None or 2. (use None if no border class)\n",
"\n",
"expand_to_border=True #if True (and a border class exists), then objects are first labelled and then expanded \n",
" #in size to object+border (watershedding with object seeds)\n",
"\n",
"# clean up segmentation\n",
"min_area=10 # minimum required object size\n",
"fill_holes=True # slow\n"
"fill_holes=True # slow\n",
"\n",
"\n"
]
},
{
......@@ -124,7 +132,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Load image data**"
"#### Load image data\n",
"Data is loaded as list of arrays -> varying image size is supported"
]
},
{
......@@ -150,7 +159,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"normalize intensity (independent for each image)"
"**Normalize intensity** (independent for each image, or all images & channels together - use the same setting as in training)"
]
},
{
......@@ -159,13 +168,15 @@
"metadata": {},
"outputs": [],
"source": [
"#axis_norm = (0,1) # normalize channels independently\n",
"axis_norm = (0,1,2) # normalize channels jointly\n",
"if n_channels > 1:\n",
" print(\"Normalizing image channels %s.\" % ('jointly' if axis_norm is None or 2 in axis_norm else 'independently'))\n",
" sys.stdout.flush()\n",
"if norm_all_together:\n",
" print(\"Normalizing all images and channels together\")\n",
" imgs=normalize_list_jointly(imgs,1,99.8)\n",
"else:\n",
" if n_channels > 1:\n",
" print(\"Normalizing image channels %s.\" % ('jointly' if axis_norm is None or 2 in axis_norm else 'independently'))\n",
" sys.stdout.flush()\n",
"\n",
"imgs=[normalize(x,1,99.8,axis=axis_norm) for x in tqdm(imgs)]"
" imgs=[normalize(x,1,99.8,axis=axis_norm) for x in tqdm(imgs)]"
]
},
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment