Commit 3216706a authored by Ines Filipa Fernandes Ramos's avatar Ines Filipa Fernandes Ramos
Browse files

optimization of LN model and simple CNN

parent cad60d6c
This diff is collapsed.
......@@ -285,14 +285,14 @@ def deepdraw(net, base_img, octaves, random_crop=True, original_size=None,
# stopping iterations if mean activation of net declines for generated image
mean_activation = net(src).mean()
if i>1 and mean_activation <= mean_activation_hist:
image = image_hist
break
else:
image_hist = image
mean_activation_hist = net(src).mean()
continue
#mean_activation = net(src).mean()
#if i>1 and mean_activation <= mean_activation_hist:
# image = image_hist
# break
#else:
# image_hist = image
# mean_activation_hist = net(src).mean()
# continue
# returning the resulting image
return unprocess(image, mu=bias, sigma=scale)
......@@ -344,7 +344,7 @@ def contrast_tuning(model, img, bias, scale, min_contrast=0.01, n=1000, linear=T
return cont, vals, lim_contrast
def MEI_multi_seed(dataset_name, dat, dataloaders, models, n_seeds, MEIParameter, TargetUnit, bk_color, track=False):
def MEI_multi_seed(dataset_name, dat, dataloaders, models, n_seeds, MEIParameter, TargetUnit, bk_color, init_gen_image, track=False):
"""
dataset_name : string # string with dataset_name of dataset used for training
dat : object # FileTreeDataset object with data schema of data
......@@ -399,7 +399,10 @@ def MEI_multi_seed(dataset_name, dat, dataloaders, models, n_seeds, MEIParameter
# the background color of the initial image
background_color = np.float32([bk_color] * channels)
# generate initial random image
gen_image = np.random.normal(background_color, 8, (original_h, original_w, channels))
if init_gen_image is not None:
gen_image = init_gen_image
else:
gen_image = np.random.normal(background_color, 8, (original_h, original_w, channels))
gen_image = np.clip(gen_image, 0, 255)
# generate class visualization via octavewise gradient ascent
......
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