print('loaded VGG!') # ############学習の高速化のためにパラメータを事前に整理しておく################### if args.usevgg == 1: print('preprocessing vgg data') vgg_img_param = [] start = time.time() if os.path.isfile('features/vggparam_yahoo.pickle'): print('vgg checkpoint pickle is exist! loading pickle') with open('features/vggparam_yahoo.pickle', mode='rb') as f: vgg_img_param = pickle.load(f) else: for filename in filenames: vgg_img_param.append(vggparamater(filename, args.gpu, vgg)[0]) with open('features/vggparam_yahoo.pickle', mode='wb') as f: pickle.dump(vgg_img_param, f) calctime = time.time() - start print('VGG time: ' + str(calctime), '[sec]') print('vgg end') ############################################################################# print('training start') dataset = [] if os.path.isfile('style.npy'): print('the file is exists! load...') styleg = np.load('styleg.npy') style = np.load('style.npy') else:
model = args.model model_path = 'models/yahoo100m_gan/epoch_{}.model'.format(model) vgg = VGGNet() serializers.load_hdf5('/tmp/VGG.model', vgg) if args.usevgg == 1: tinynet = Generator() else: tinynet = Generator() serializers.load_npz(model_path, tinynet) tinynet.to_gpu() words = ['outdoor', 'black', 'urban', 'white', 'indoor', 'new', 'serene', 'red', 'light', 'tree', 'country', 'old', 'dark'] for word in words: for count in range(28): filename = 'images/valid/{}.jpg'.format(count) vgg_param = vggparamater(filename, 0, vgg)[0] if args.usevgg == 1: concatted = concatData(word, vgg_param) else: concatted = w2v(word) print('moto:') # print(concatted[0][400:420]) # print(concatted[0][0:10]) if args.usevgg == 0: concatted = np.reshape(concatted, (1, 200)) print(concatted.shape) concatted_g = Variable(cuda.to_gpu(concatted)) style_params = tinynet(concatted_g, train=False) # print(style_params.data.shape,concatted_g.data.shape) print('params:') print(style_params.data[0][0:10])