<s> import h5py <EOL> from sklearn . manifold import TSNE <EOL> from model import Model <EOL> import numpy <EOL> import PIL , PIL . Image , PIL . ImageOps <EOL> f = h5py . File ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> data = f [ '<STR_LIT>' ] <EOL> n , k = data . shape [ <NUM_LIT:0> ] , data . shape [ <NUM_LIT:1> ] <EOL> wh = data . shape [ <NUM_LIT:2> ] * data . shape [ <NUM_LIT:3> ] <EOL> model = Model ( n , k , wh ) <EOL> model . try_load ( ) <EOL> X = model . get_font_embeddings ( ) <EOL> print X <EOL> tsne = TSNE ( verbose = <NUM_LIT> ) <EOL> x = tsne . fit_transform ( X [ : <NUM_LIT> ] ) <EOL> x -= numpy . min ( x , axis = <NUM_LIT:0> ) <EOL> M = <NUM_LIT> <EOL> x *= M / numpy . max ( x ) <EOL> canvas = PIL . Image . new ( '<STR_LIT:L>' , ( M + <NUM_LIT> , M + <NUM_LIT:64> ) , <NUM_LIT:255> ) <EOL> for i in xrange ( len ( x ) ) : <EOL> cx , cy = map ( int , x [ i ] ) <EOL> img_black = PIL . Image . new ( '<STR_LIT:L>' , ( <NUM_LIT:64> , <NUM_LIT:64> ) , <NUM_LIT:0> ) <EOL> img = PIL . Image . fromarray ( numpy . uint8 ( data [ i ] [ <NUM_LIT:0> ] ) ) <EOL> canvas . paste ( img_black , ( cx , cy ) , img ) <EOL> canvas . save ( '<STR_LIT>' ) </s>
