Commit f1263495 authored by Jiri Borovec's avatar Jiri Borovec

fix loading tiff in expt

parent 6e62a79b
......@@ -30,7 +30,7 @@ IMAGE_SIZE_3D = (16, 128, 128)
NB_ATM_PATTERNS = 9
NB_SAMPLES = 50
RND_PATTERN_OCCLUSION = 0.25
IMAGE_POSIX = '.png'
IMAGE_POSIXS = ['.png', '.tif', '.tiff']
IMAGE_PATTERN = 'pattern_{:03d}'
SEGM_PATTERN = 'sample_{:05d}'
BLOCK_NB_LOAD_IMAGES = 50
......@@ -437,8 +437,25 @@ def wrapper_load_images(list_path_img):
return list_names_imgs
def dataset_load_images(path_dir, im_pattern='*', im_posix=IMAGE_POSIX,
nb_spls=None, nb_jobs=1):
def find_images(path_dir, im_pattern='*', img_posixs=IMAGE_POSIXS):
""" in given folder find largest group of equal images types
:param path_dir: str
:param im_pattern: str
:param img_posixs: [str]
:return: [str]
"""
paths_img_most = []
for im_posix in img_posixs:
path_search = os.path.join(path_dir, im_pattern + im_posix)
paths_img = glob.glob(path_search)
logger.debug('images found %i for search "%s"', len(paths_img), path_search)
if len(paths_img) > len(paths_img_most):
paths_img_most = paths_img
return paths_img_most
def dataset_load_images(path_dir, im_pattern='*', nb_spls=None, nb_jobs=1):
""" load complete dataset or just a subset
:param name: str, name od particular dataset
......@@ -451,12 +468,10 @@ def dataset_load_images(path_dir, im_pattern='*', im_posix=IMAGE_POSIX,
"""
logger.info('loading folder (%s) <- "%s"', os.path.exists(path_dir), path_dir)
assert os.path.exists(path_dir)
path_search = os.path.join(path_dir, im_pattern + im_posix)
logger.debug('image search "%s"', path_search)
paths_img = glob.glob(path_search)
paths_img = find_images(path_dir, im_pattern)
paths_img = sorted(paths_img)[:nb_spls]
logger.debug('number samples %i in dataset "%s"', len(paths_img),
os.path.basename(path_dir))
paths_img = sorted(paths_img)[:nb_spls]
if nb_jobs > 1:
logger.debug('running in %i threads...', nb_jobs)
......@@ -483,7 +498,7 @@ def dataset_load_images(path_dir, im_pattern='*', im_posix=IMAGE_POSIX,
def load_image(path_img):
assert os.path.exists(path_img)
n_img, img_ext = os.path.splitext(os.path.basename(path_img))
if img_ext == '.tiff':
if img_ext in ['.tif', '.tiff']:
im = libtiff.TiffFile(path_img).get_tiff_array()
img = np.empty(im.shape)
for i in range(img.shape[0]):
......
......@@ -49,7 +49,7 @@ PATH_RESULTS = '/datagrid/Medical/microscopy/drosophila/TEMPORARY/experiments_AP
DEFAULT_PARAMS = {
'computer': os.uname(),
'nb_samples': None,
'init_tp': 'msc', # msc. rnd
'init_tp': 'rnd', # msc. rnd
'max_iter': 150,
'gc_regul': 1e-2,
'nb_labels': 20,
......
......@@ -3,9 +3,13 @@ run experiments with Atomic Learning Pattern Encoding
Example run:
>> python run_experiment_apd_apdl.py \
-in /datagrid/Medical/microscopy/drosophila/TEMPORARY \
-out /datagrid/Medical/microscopy/drosophila/TEMPORARY/experiments_APD_new \
--dataset type_1_segm_reg_binary --sub_dataset gene_ssmall
-in /datagrid/Medical/microscopy/drosophila/synthetic_data/atomicPatternDictionary_v1 \
-out /datagrid/Medical/microscopy/drosophila/TEMPORARY/experiments_APDL_synth
>> python run_experiment_apd_apdl.py --type real \
-in /datagrid/Medical/microscopy/drosophila/TEMPORARY/type_1_segm_reg_binary \
-out /datagrid/Medical/microscopy/drosophila/TEMPORARY/experiments_APDL_real \
--dataset gene_ssmall
Copyright (C) 2015-2016 Jiri Borovec <jiri.borovec@fel.cvut.cz>
"""
......@@ -212,6 +216,7 @@ def experiments_test(dict_params=SYNTH_PARAMS):
# GRAPHCUT_REGUL = [0.0, 1e-3, 0.1]
INIT_TYPES = DICT_ATLAS_INIT.keys()
GRAPHCUT_REGUL = [0., 0e-12, 1e-9, 1e-6, 1e-3, 1e-1, 1.0]
NB_PATTERNS_REAL = [5, 8, 10, 12, 14, 16, 18, 20, 25, 30, 40, 60]
def experiments_synthetic(params=SYNTH_PARAMS):
......@@ -268,8 +273,7 @@ def experiments_real(params=REAL_PARAMS):
l_params = [copy.deepcopy(params)]
# l_params = expt_apd.extend_list_params(l_params, 'init_tp', ['msc', 'rnd'])
# l_params = expt_apd.extend_list_params(l_params, 'ptn_split', [True, False])
l_params = expt_apd.extend_list_params(l_params, 'gc_regul',
[0., 1e-9, 1e-6, 1e-3, 1e-2, 1e-1])
l_params = expt_apd.extend_list_params(l_params, 'gc_regul', GRAPHCUT_REGUL)
# l_params = expt_apd.extend_list_params(l_params, 'nb_labels',
# [5, 9, 12, 15, 20, 25, 30, 40])
logging.debug('list params: %i', len(l_params))
......@@ -281,8 +285,7 @@ def experiments_real(params=REAL_PARAMS):
else:
expt = ExperimentALPE_raw(params)
# exp.run(gt=False, iter_var='case', iter_values=range(params['nb_runs']))
expt.run(gt=False, iter_var='nb_labels',
iter_vals=[9, 12, 15, 20, 25, 30])
expt.run(gt=False, iter_var='nb_labels', iter_vals=NB_PATTERNS_REAL)
tqdm_bar.update(1)
gc.collect(), time.sleep(1)
......
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