def _visualize_model(self, img_dir): print("Sampling images from model...") batch_z = np.random.uniform(-1.0, 1.0, size=[self.batch_size, self.z_dim]).astype(np.float32) correct_tag = np.zeros( [self.batch_size, self.eyes_dim + self.hair_dim], dtype=np.float32) correct_tag[:, 1] = 1. correct_tag[:-1] = 1. feed_dict = { self.z_vec: batch_z, self.eyes_vec: correct_tag[:, :11], self.hair_vec: correct_tag[:, 11:], self.train_phase: False } images = self.sess.run(self.gen_images, feed_dict=feed_dict) images = ops.unprocess_image(images, 127.5, 127.5).astype(np.uint8) shape = [4, self.batch_size // 4] print(images.shape) ops.save_imshow_grid(images, img_dir, "generated_%d.png" % self.global_steps, shape)
def save_test_img(self, feature, index): batch_z = np.random.uniform(-1.0, 1.0, size=[self.batch_size, self.z_dim]).astype(np.float32) correct_tag = np.tile(feature, (self.batch_size, 1)) feed_dict = { self.z_vec: batch_z, self.tag_vec: correct_tag, self.train_phase: False } images = self.sess.run(self.gen_images, feed_dict=feed_dict) images = ops.unprocess_image(images, 127.5, 127.5).astype(np.uint8) ops.save_test_image(images, index)
def _visualize_model(self, img_dir): print("Sampling images from model...") batch_z = np.random.uniform(-1.0, 1.0, size=[self.batch_size, self.z_dim]).astype(np.float32) correct_tag = np.load('test_embedding.npy') correct_tag = np.tile(correct_tag, (self.batch_size, 1)) feed_dict = { self.z_vec: batch_z, self.tag_vec: correct_tag, self.train_phase: False } images = self.sess.run(self.gen_images, feed_dict=feed_dict) images = ops.unprocess_image(images, 127.5, 127.5).astype(np.uint8) shape = [4, self.batch_size // 4] print(images.shape) ops.save_imshow_grid(images, img_dir, "generated_%d.png" % self.global_steps, shape)