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

Addes sim with checkerboard

parent e9d2337f
......@@ -227,6 +227,15 @@ def deepdraw(net, base_img, octaves, random_crop=True, original_size=None,
src = torch.zeros(1, c, w, h, requires_grad=True, device=device)
# start figure to plot activation values at each 10 iterations
fig, ax = plt.subplots(2)
x = np.linspace(0,octaves[0]['iter_n'],10)
ax[0].set_xlabel('iter number')
ax[0].set_ylabel('activation for generated MEI')
ax[0].set_xlim(0,1000)
mean_activation = []
for e, o in enumerate(octaves):
if 'scale' in o:
# resize by o['scale'] if it exists
......@@ -262,15 +271,25 @@ def deepdraw(net, base_img, octaves, random_crop=True, original_size=None,
make_step(net, src, bias=bias, scale=scale, sigma=sigma, step_size=step_size, **step_params)
if i % 10 == 0:
if i % 100 == 0:
print('finished step %d in octave %d' % (i, e))
ax[0].scatter(i,net(src).mean())
ax[1].imshow(src)
# insert modified image back into original image (if necessary)
image[:, ox:ox + w, oy:oy + h] = src.data[0].cpu().numpy()
# stopping iterations if mean activation of net declines for generated image
mean_activation.append(net(src).mean())
if mean_activation[-1] <= mean_activation[-2]:
break
else:
continue
# returning the resulting image
return unprocess(image, mu=bias, sigma=scale)
def contrast_tuning(model, img, bias, scale, min_contrast=0.01, n=1000, linear=True, use_max_lim=False):
mu = img.mean()
delta = img - img.mean()
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
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