Neural art check-point viewer

Simple notebook to load the images saved during an nstyle training run and view them together.


In [1]:
import glob
dir_name = 'output/'
prefix = dir_name + 'e_'
files = glob.glob(prefix+'*.jpg')

In [2]:
# Sort by numeric part
files.sort(key=lambda x: int(x[len(prefix):-4]))
files.append(dir_name+'final.jpg')
files[:5]


Out[2]:
['output/e_50.jpg', 'output/e_100.jpg', 'output/e_150.jpg', 'output/final.jpg']

In [3]:
# Set up some code to display the images in a notebook
import IPython.display
def show_img(fn):
    h = IPython.display.HTML("<img src='"+fn+"'>")
    IPython.display.display(h)

Animated display

Flip through the frames fairly quickly for a movie-like experience.
NOTE: this tends to work much better the second time through after the browser has cached all the images.


In [4]:
# Animated Display
import time
for img in files:
    IPython.display.clear_output()
    print(img)
    show_img(img)
    time.sleep(1)


output/final.jpg

In [5]:
%matplotlib inline
import matplotlib.pyplot as plt
from skimage import io

for img_fn in files:
    print(img_fn)
    im = io.imread(img_fn)
    plt.figure(figsize=(3,2))
    plt.axis('off')
    plt.imshow(im)
    plt.show()


output/e_50.jpg
output/e_100.jpg
output/e_150.jpg
output/final.jpg

In [ ]: