Пример #1
0
def run_model_on_dir():
    data_location = os.path.join(DATA_DIR, PREFIX, 'set1')
    output_location = os.path.join(RESULTS_DIR, PREFIX)
    channel_names = ['phase']
    image_size_x, image_size_y = get_image_sizes(data_location, channel_names)

    model_name = '2018-06-13_ecoli_kc_polaris_channels_last_sample__0.h5'
    weights = os.path.join(MODEL_DIR, PREFIX, model_name)

    n_features = 3
    window_size = (30, 30)

    model_fn = bn_feature_net_61x61 if DATA_OUTPUT_MODE == 'sample' else bn_dense_feature_net

    predictions = run_models_on_directory(data_location=data_location,
                                          channel_names=channel_names,
                                          output_location=output_location,
                                          n_features=n_features,
                                          model_fn=model_fn,
                                          list_of_weights=[weights],
                                          image_size_x=image_size_x,
                                          image_size_y=image_size_y,
                                          win_x=window_size[0],
                                          win_y=window_size[1],
                                          split=False)
	cyto_weights = os.path.join(trained_network_cyto_directory,  cyto_prefix + str(j) + ".h5")
	list_of_cyto_weights += [cyto_weights]

# list_of_nuclear_weights = []
# for j in xrange(1):
# 	nuclear_weights = os.path.join(trained_network_nuclear_directory,  nuclear_prefix + str(j) + ".h5")
# 	list_of_nuclear_weights += [nuclear_weights]

# print list_of_nuclear_weights

"""
Run model on directory
"""

cytoplasm_predictions = run_models_on_directory(data_location, cyto_channel_names, cyto_location, n_features = 4, model_fn = cyto_fn, 
	list_of_weights = list_of_cyto_weights, image_size_x = image_size_x, image_size_y = image_size_y, 
	win_x = win_cyto, win_y = win_cyto, std = True, split = False)

# nuclear_predictions = run_models_on_directory(data_location, nuclear_channel_names, nuclear_location, model_fn = nuclear_fn, 
# 	list_of_weights = list_of_nuclear_weights, image_size_x = image_size_x, image_size_y = image_size_y, 
# 	win_x = win_nuclear, win_y = win_nuclear, std = False, split = False)

"""
Refine segmentation with active contours
"""

# nuclear_masks = segment_nuclei(img = None, color_image = True, load_from_direc = nuclear_location, mask_location = mask_location, area_threshold = 100, solidity_threshold = 0, eccentricity_threshold = 1)
# cytoplasm_masks = segment_cytoplasm(img = None, load_from_direc = cyto_location, color_image = True, nuclear_masks = nuclear_masks, mask_location = mask_location, smoothing = 1, num_iters = 120)


"""
Пример #3
0
nuclear_channel_names = ['nuclear']

trained_network_nuclear_directory = "/data/trained_networks/nuclei_broad/"

nuclear_prefix = "2018-01-20_nuclei_broad_same_conv_61x61_bn_dense_feature_net_"

win_nuclear = 30

image_size_x, image_size_y = get_image_sizes(data_location, nuclear_channel_names)

"""
Define model
"""

list_of_nuclear_weights = []
for j in xrange(1):
	nuclear_weights = os.path.join(trained_network_nuclear_directory,  nuclear_prefix + str(j) + ".h5")
	list_of_nuclear_weights += [nuclear_weights]

print list_of_nuclear_weights

"""
Run model on directory
"""

nuclear_predictions = run_models_on_directory(data_location, nuclear_channel_names, nuclear_location, model_fn = nuclear_fn, 
	list_of_weights = list_of_nuclear_weights, image_size_x = image_size_x, image_size_y = image_size_y, 
	win_x = win_nuclear, win_y = win_nuclear, std = False, split = False)