├── .github └── FUNDING.yml ├── AnimeGAN.py ├── README.md ├── Requirements installation tutorial.md ├── checkpoint ├── AnimeGAN_Hayao_lsgan_300_300_1_2_10 │ └── checkpoints files └── generator_Hayao_weight │ ├── Hayao-60.ckpt.data-00000-of-00001 │ ├── Hayao-60.ckpt.index │ ├── Hayao-60.ckpt.meta │ └── checkpoint ├── dataset ├── Hayao │ ├── smooth │ │ └── smooth dir │ └── style │ │ └── style images dir ├── Paprika │ ├── smooth dir │ │ └── smooth images │ └── style │ │ └── style images dir ├── Shinkai │ └── sytle │ │ └── sytle images dir ├── test │ ├── HR_photo │ │ └── HR photos │ ├── real │ │ └── photos │ ├── test_photo │ │ └── none │ └── test_photo256 │ │ └── 256x256 photos ├── train_photo │ └── train photos └── val │ └── valid images ├── doc ├── 3-1block.png ├── Chen2020_Chapter_AnimeGAN.pdf ├── GD.png ├── Japanese_README.md ├── e2.png ├── e3.png ├── e4.png └── sota.png ├── net ├── discriminator.py └── generator.py ├── result └── Hayao │ ├── SOTA_comparison │ ├── AnimeGAN │ │ ├── 105.jpg │ │ ├── 185.jpg │ │ ├── 19.jpg │ │ ├── 190.jpg │ │ ├── 198.jpg │ │ ├── 204.jpg │ │ ├── 208.jpg │ │ ├── 246.jpg │ │ ├── 256.jpg │ │ ├── 258.jpg │ │ ├── 26.jpg │ │ ├── 35.jpg │ │ ├── 447.jpg │ │ ├── 539.jpg │ │ ├── 599.jpg │ │ ├── 618.jpg │ │ ├── 632.jpg │ │ ├── 675.jpg │ │ ├── 681.jpg │ │ ├── 69.jpg │ │ ├── 75.jpg │ │ └── 762.jpg │ ├── CartoonGAN │ │ ├── 105_1562736508.jpg │ │ ├── 185_1562736844.jpg │ │ ├── 190_1562737136.jpg │ │ ├── 198_1562737236.jpg │ │ ├── 19_1562736964.jpg │ │ ├── 204_1562737290.jpg │ │ ├── 208_1562737392.jpg │ │ ├── 246_1562737460.jpg │ │ ├── 256_1562739338.jpg │ │ ├── 258_1562737714.jpg │ │ ├── 26_1562737803.jpg │ │ ├── 35_1562737865.jpg │ │ ├── 447_1562737943.jpg │ │ ├── 539_1562738321.jpg │ │ ├── 599_1562739505.jpg │ │ ├── 618_1562739199.jpg │ │ ├── 632_1562738596.jpg │ │ ├── 675_1562738662.jpg │ │ ├── 681_1562738765.jpg │ │ ├── 69_1562738956.jpg │ │ ├── 75_1562739149.jpg │ │ └── 762_1562739095.jpg │ ├── ComixGAN │ │ ├── 105.png │ │ ├── 185.png │ │ ├── 19.png │ │ ├── 190.png │ │ ├── 198.png │ │ ├── 204.png │ │ ├── 208.png │ │ ├── 246.png │ │ ├── 256.png │ │ ├── 258.png │ │ ├── 26.png │ │ ├── 35.png │ │ ├── 447.png │ │ ├── 539.png │ │ ├── 599.png │ │ ├── 618.png │ │ ├── 632.png │ │ ├── 675.png │ │ ├── 681.png │ │ ├── 69.png │ │ ├── 75.png │ │ └── 762.png │ └── real │ │ ├── 105.jpg │ │ ├── 185.jpg │ │ ├── 19.jpg │ │ ├── 190.jpg │ │ ├── 198.jpg │ │ ├── 204.jpg │ │ ├── 208.jpg │ │ ├── 246.jpg │ │ ├── 256.jpg │ │ ├── 258.jpg │ │ ├── 26.jpg │ │ ├── 35.jpg │ │ ├── 447.jpg │ │ ├── 539.jpg │ │ ├── 599.jpg │ │ ├── 618.jpg │ │ ├── 632.jpg │ │ ├── 675.jpg │ │ ├── 681.jpg │ │ ├── 69.jpg │ │ ├── 75.jpg │ │ └── 762.jpg │ ├── photo │ ├── 1.jpg │ ├── 10.jpg │ ├── 11.jpg │ ├── 12.jpg │ ├── 13.jpg │ ├── 14.jpg │ ├── 15.jpg │ ├── 16.jpg │ ├── 17.jpg │ ├── 18.jpg │ ├── 19.jpg │ ├── 2.jpg │ ├── 20.jpg │ ├── 21.jpg │ ├── 22.jpg │ ├── 23.jpg │ ├── 24.jpg │ ├── 25.jpg │ ├── 26.jpg │ ├── 27.jpg │ ├── 28.jpg │ ├── 29.jpg │ ├── 3.jpg │ ├── 30.jpg │ ├── 31.jpg │ ├── 32.jpg │ ├── 33.jpg │ ├── 34.jpg │ ├── 35.jpg │ ├── 36.jpg │ ├── 37.jpg │ ├── 38.jpg │ ├── 39.jpg │ ├── 4.jpg │ ├── 40.jpg │ ├── 41.jpg │ ├── 42.jpg │ ├── 43.jpg │ ├── 44.jpg │ ├── 45.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ └── AE86.png │ └── photo_result │ ├── 1.jpg │ ├── 10.jpg │ ├── 11.jpg │ ├── 12.jpg │ ├── 13.jpg │ ├── 14.jpg │ ├── 15.jpg │ ├── 16.jpg │ ├── 17.jpg │ ├── 18.jpg │ ├── 19.jpg │ ├── 2.jpg │ ├── 20.jpg │ ├── 21.jpg │ ├── 22.jpg │ ├── 23.jpg │ ├── 24.jpg │ ├── 25.jpg │ ├── 26.jpg │ ├── 27.jpg │ ├── 28.jpg │ ├── 29.jpg │ ├── 3.jpg │ ├── 30.jpg │ ├── 31.jpg │ ├── 32.jpg │ ├── 33.jpg │ ├── 34.jpg │ ├── 35.jpg │ ├── 36.jpg │ ├── 37.jpg │ ├── 38.jpg │ ├── 39.jpg │ ├── 4.jpg │ ├── 40.jpg │ ├── 41.jpg │ ├── 42.jpg │ ├── 43.jpg │ ├── 44.jpg │ ├── 45.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ └── AE86.png ├── test.py ├── tools ├── adjust_brightness.py ├── data_loader.py ├── data_mean.py ├── edge_smooth.py ├── get_generator_ckpt.py ├── ops.py ├── utils.py └── vgg19.py ├── train.py ├── vgg19_weight └── vgg19.npy file ├── video ├── input │ └── お花見.mp4 └── output │ └── お花見.mp4 └── video2anime.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: Asher_Chan 5 | # Replace with a single Patreon username 6 | open_collective: # Replace with a single Open Collective username 7 | ko_fi: # Replace with a single Ko-fi username 8 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 9 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 10 | liberapay: # Replace with a single Liberapay username 11 | issuehunt: # Replace with a single IssueHunt username 12 | otechie: # Replace with a single Otechie username 13 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /AnimeGAN.py: -------------------------------------------------------------------------------- 1 | from tools.ops import * 2 | from tools.utils import * 3 | from glob import glob 4 | import time 5 | import numpy as np 6 | from net import generator 7 | from net.discriminator import D_net 8 | from tools.data_loader import ImageGenerator 9 | from tools.vgg19 import Vgg19 10 | 11 | class AnimeGAN(object) : 12 | def __init__(self, sess, args): 13 | self.model_name = 'AnimeGAN' 14 | 15 | self.sess = sess 16 | self.checkpoint_dir = args.checkpoint_dir 17 | self.log_dir = args.log_dir 18 | self.dataset_name = args.dataset 19 | 20 | self.epoch = args.epoch 21 | self.init_epoch = args.init_epoch # args.epoch // 20 22 | 23 | self.gan_type = args.gan_type 24 | 25 | self.batch_size = args.batch_size 26 | 27 | self.save_freq = args.save_freq 28 | 29 | self.init_lr = args.init_lr 30 | self.d_lr = args.d_lr 31 | self.g_lr = args.g_lr 32 | 33 | 34 | """ Weight """ 35 | self.g_adv_weight = args.g_adv_weight 36 | self.d_adv_weight = args.d_adv_weight 37 | self.con_weight = args.con_weight 38 | self.sty_weight = args.sty_weight 39 | self.color_weight = args.color_weight 40 | 41 | self.training_rate = args.training_rate 42 | self.ld = args.ld 43 | 44 | self.img_size = args.img_size 45 | self.img_ch = args.img_ch 46 | 47 | """ Discriminator """ 48 | self.n_dis = args.n_dis 49 | self.ch = args.ch 50 | self.sn = args.sn 51 | 52 | self.sample_dir = os.path.join(args.sample_dir, self.model_dir) 53 | check_folder(self.sample_dir) 54 | 55 | self.real = tf.placeholder(tf.float32, [self.batch_size, self.img_size[0], self.img_size[1], self.img_ch], name='real_A') 56 | self.anime = tf.placeholder(tf.float32, [self.batch_size, self.img_size[0], self.img_size[1], self.img_ch], name='anime_A') 57 | self.anime_smooth = tf.placeholder(tf.float32, [self.batch_size, self.img_size[0], self.img_size[1], self.img_ch], name='anime_smooth_A') 58 | self.test_real = tf.placeholder(tf.float32, [1, None, None, self.img_ch], name='test_input') 59 | 60 | self.anime_gray = tf.placeholder(tf.float32, [self.batch_size, self.img_size[0], self.img_size[1], self.img_ch],name='anime_B') 61 | 62 | 63 | self.real_image_generator = ImageGenerator('./dataset/train_photo', self.img_size, self.batch_size) 64 | self.anime_image_generator = ImageGenerator('./dataset/{}'.format(self.dataset_name + '/style'), self.img_size, self.batch_size) 65 | self.anime_smooth_generator = ImageGenerator('./dataset/{}'.format(self.dataset_name + '/smooth'), self.img_size, self.batch_size) 66 | self.dataset_num = max(self.real_image_generator.num_images, self.anime_image_generator.num_images) 67 | 68 | self.vgg = Vgg19() 69 | 70 | print() 71 | print("##### Information #####") 72 | print("# gan type : ", self.gan_type) 73 | print("# dataset : ", self.dataset_name) 74 | print("# max dataset number : ", self.dataset_num) 75 | print("# batch_size : ", self.batch_size) 76 | print("# epoch : ", self.epoch) 77 | print("# init_epoch : ", self.init_epoch) 78 | print("# training image size [H, W] : ", self.img_size) 79 | print("# g_adv_weight,d_adv_weight,con_weight,sty_weight,color_weight : ", self.g_adv_weight,self.d_adv_weight,self.con_weight,self.sty_weight,self.color_weight) 80 | print("# init_lr,g_lr,d_lr : ", self.init_lr,self.g_lr,self.d_lr) 81 | print(f"# training_rate G -- D: {self.training_rate} : 1" ) 82 | print() 83 | 84 | ################################################################################## 85 | # Generator 86 | ################################################################################## 87 | 88 | def generator(self,x_init, reuse=False, scope="generator"): 89 | 90 | with tf.variable_scope(scope, reuse=reuse) : 91 | G = generator.G_net(x_init) 92 | return G.fake 93 | 94 | ################################################################################## 95 | # Discriminator 96 | ################################################################################## 97 | 98 | def discriminator(self, x_init, reuse=False, scope="discriminator"): 99 | 100 | D = D_net(x_init, self.ch, self.n_dis, self.sn, reuse=reuse, scope=scope) 101 | 102 | return D 103 | 104 | ################################################################################## 105 | # Model 106 | ################################################################################## 107 | def gradient_panalty(self, real, fake, scope="discriminator"): 108 | if self.gan_type.__contains__('dragan') : 109 | eps = tf.random_uniform(shape=tf.shape(real), minval=0., maxval=1.) 110 | _, x_var = tf.nn.moments(real, axes=[0, 1, 2, 3]) 111 | x_std = tf.sqrt(x_var) # magnitude of noise decides the size of local region 112 | 113 | fake = real + 0.5 * x_std * eps 114 | 115 | alpha = tf.random_uniform(shape=[self.batch_size, 1, 1, 1], minval=0., maxval=1.) 116 | interpolated = real + alpha * (fake - real) 117 | 118 | logit, _= self.discriminator(interpolated, reuse=True, scope=scope) 119 | 120 | 121 | grad = tf.gradients(logit, interpolated)[0] # gradient of D(interpolated) 122 | grad_norm = tf.norm(flatten(grad), axis=1) # l2 norm 123 | 124 | GP = 0 125 | # WGAN - LP 126 | if self.gan_type.__contains__('lp'): 127 | GP = self.ld * tf.reduce_mean(tf.square(tf.maximum(0.0, grad_norm - 1.))) 128 | 129 | elif self.gan_type.__contains__('gp') or self.gan_type == 'dragan' : 130 | GP = self.ld * tf.reduce_mean(tf.square(grad_norm - 1.)) 131 | 132 | return GP 133 | 134 | def build_model(self): 135 | 136 | """ Define Generator, Discriminator """ 137 | self.generated = self.generator(self.real) 138 | self.test_generated = self.generator(self.test_real, reuse=True) 139 | 140 | anime_logit = self.discriminator(self.anime) 141 | anime_gray_logit = self.discriminator(self.anime_gray, reuse=True) 142 | 143 | generated_logit = self.discriminator(self.generated, reuse=True) 144 | smooth_logit = self.discriminator(self.anime_smooth, reuse=True) 145 | 146 | """ Define Loss """ 147 | if self.gan_type.__contains__('gp') or self.gan_type.__contains__('lp') or self.gan_type.__contains__('dragan') : 148 | GP = self.gradient_panalty(real=self.anime, fake=self.generated) 149 | else : 150 | GP = 0.0 151 | 152 | # init pharse 153 | init_c_loss = con_loss(self.vgg, self.real, self.generated) 154 | init_loss = self.con_weight * init_c_loss 155 | 156 | self.init_loss = init_loss 157 | 158 | # gan 159 | c_loss, s_loss = con_sty_loss(self.vgg, self.real, self.anime_gray, self.generated) 160 | t_loss = self.con_weight * c_loss + self.sty_weight * s_loss + color_loss(self.real,self.generated) * self.color_weight 161 | 162 | g_loss = self.g_adv_weight * generator_loss(self.gan_type, generated_logit) 163 | d_loss = self.d_adv_weight * discriminator_loss(self.gan_type, anime_logit, anime_gray_logit, generated_logit, smooth_logit) + GP 164 | 165 | self.Generator_loss = t_loss + g_loss 166 | self.Discriminator_loss = d_loss 167 | 168 | """ Training """ 169 | t_vars = tf.trainable_variables() 170 | G_vars = [var for var in t_vars if 'generator' in var.name] 171 | D_vars = [var for var in t_vars if 'discriminator' in var.name] 172 | 173 | self.init_optim = tf.train.AdamOptimizer(self.init_lr, beta1=0.5, beta2=0.999).minimize(self.init_loss, var_list=G_vars) 174 | self.G_optim = tf.train.AdamOptimizer(self.g_lr , beta1=0.5, beta2=0.999).minimize(self.Generator_loss, var_list=G_vars) 175 | self.D_optim = tf.train.AdamOptimizer(self.d_lr , beta1=0.5, beta2=0.999).minimize(self.Discriminator_loss, var_list=D_vars) 176 | 177 | 178 | """" Summary """ 179 | self.G_loss = tf.summary.scalar("Generator_loss", self.Generator_loss) 180 | self.D_loss = tf.summary.scalar("Discriminator_loss", self.Discriminator_loss) 181 | 182 | self.G_gan = tf.summary.scalar("G_gan", g_loss) 183 | self.G_vgg = tf.summary.scalar("G_vgg", t_loss) 184 | self.G_init_loss = tf.summary.scalar("G_init", init_loss) 185 | 186 | self.V_loss_merge = tf.summary.merge([self.G_init_loss]) 187 | self.G_loss_merge = tf.summary.merge([self.G_loss, self.G_gan, self.G_vgg, self.G_init_loss]) 188 | self.D_loss_merge = tf.summary.merge([self.D_loss]) 189 | 190 | 191 | def train(self): 192 | # initialize all variables 193 | self.sess.run(tf.global_variables_initializer()) 194 | 195 | # saver to save model 196 | self.saver = tf.train.Saver(max_to_keep=self.epoch) 197 | 198 | # summary writer 199 | self.writer = tf.summary.FileWriter(self.log_dir + '/' + self.model_dir, self.sess.graph) 200 | 201 | """ Input Image""" 202 | real_img_op, anime_img_op, anime_smooth_op = self.real_image_generator.load_images(), self.anime_image_generator.load_images(), self.anime_smooth_generator.load_images() 203 | 204 | 205 | # restore check-point if it exits 206 | could_load, checkpoint_counter = self.load(self.checkpoint_dir) 207 | if could_load: 208 | start_epoch = checkpoint_counter + 1 209 | 210 | print(" [*] Load SUCCESS") 211 | else: 212 | start_epoch = 0 213 | 214 | print(" [!] Load failed...") 215 | 216 | # loop for epoch 217 | init_mean_loss = [] 218 | mean_loss = [] 219 | # training times , G : D = self.training_rate : 1 220 | j = self.training_rate 221 | for epoch in range(start_epoch, self.epoch): 222 | 223 | for idx in range(int(self.dataset_num / self.batch_size)): 224 | 225 | anime, anime_smooth, real = self.sess.run([anime_img_op, anime_smooth_op, real_img_op]) 226 | 227 | train_feed_dict = { 228 | self.real:real[0], 229 | self.anime:anime[0], 230 | self.anime_gray:anime[1], 231 | self.anime_smooth:anime_smooth[1] 232 | } 233 | 234 | if epoch < self.init_epoch : 235 | # Init G 236 | start_time = time.time() 237 | 238 | real_images, generator_images, _, v_loss, summary_str = self.sess.run([self.real, self.generated, 239 | self.init_optim, 240 | self.init_loss, self.V_loss_merge], feed_dict = train_feed_dict) 241 | self.writer.add_summary(summary_str, epoch) 242 | init_mean_loss.append(v_loss) 243 | 244 | print("Epoch: %3d Step: %5d / %5d time: %f s init_v_loss: %.8f mean_v_loss: %.8f" % (epoch, idx,int(self.dataset_num / self.batch_size), time.time() - start_time, v_loss, np.mean(init_mean_loss))) 245 | if (idx+1)%200 ==0: 246 | init_mean_loss.clear() 247 | else : 248 | start_time = time.time() 249 | 250 | if j == self.training_rate: 251 | # Update D 252 | _, d_loss, summary_str = self.sess.run([self.D_optim, self.Discriminator_loss, self.D_loss_merge], 253 | feed_dict=train_feed_dict) 254 | self.writer.add_summary(summary_str, epoch) 255 | 256 | # Update G 257 | real_images, generator_images, _, g_loss, summary_str = self.sess.run([self.real, self.generated,self.G_optim, 258 | self.Generator_loss, self.G_loss_merge], feed_dict = train_feed_dict) 259 | self.writer.add_summary(summary_str, epoch) 260 | 261 | mean_loss.append([d_loss, g_loss]) 262 | if j == self.training_rate: 263 | 264 | print( 265 | "Epoch: %3d Step: %5d / %5d time: %f s d_loss: %.8f, g_loss: %.8f -- mean_d_loss: %.8f, mean_g_loss: %.8f" % ( 266 | epoch, idx, int(self.dataset_num / self.batch_size), time.time() - start_time, d_loss, g_loss, np.mean(mean_loss, axis=0)[0], 267 | np.mean(mean_loss, axis=0)[1])) 268 | else: 269 | print( 270 | "Epoch: %3d Step: %5d / %5d time: %f s , g_loss: %.8f -- mean_g_loss: %.8f" % ( 271 | epoch, idx, int(self.dataset_num / self.batch_size), time.time() - start_time, g_loss, np.mean(mean_loss, axis=0)[1])) 272 | 273 | if (idx + 1) % 200 == 0: 274 | mean_loss.clear() 275 | 276 | j = j - 1 277 | if j < 1: 278 | j = self.training_rate 279 | 280 | 281 | if (epoch + 1) >= self.init_epoch and np.mod(epoch + 1, self.save_freq) == 0: 282 | self.save(self.checkpoint_dir, epoch) 283 | 284 | if epoch >= self.init_epoch -1: 285 | """ Result Image """ 286 | val_files = glob('./dataset/{}/*.*'.format('val')) 287 | save_path = './{}/{:03d}/'.format(self.sample_dir, epoch) 288 | check_folder(save_path) 289 | for i, sample_file in enumerate(val_files): 290 | print('val: '+ str(i) + sample_file) 291 | sample_image = np.asarray(load_test_data(sample_file, self.img_size)) 292 | test_real,test_generated = self.sess.run([self.test_real,self.test_generated],feed_dict = {self.test_real:sample_image} ) 293 | 294 | save_images(test_real, save_path+'{:03d}_a.jpg'.format(i), None) 295 | save_images(test_generated, save_path + '{:03d}_b.jpg'.format(i), None) 296 | # adjust_brightness_from_photo_to_fake 297 | # save_images(test_generated, save_path+'{:03d}_b.jpg'.format(i), sample_file) 298 | 299 | 300 | @property 301 | def model_dir(self): 302 | return "{}_{}_{}_{}_{}_{}_{}_{}".format(self.model_name, self.dataset_name, 303 | self.gan_type, 304 | int(self.g_adv_weight), int(self.d_adv_weight), int(self.con_weight), int(self.sty_weight), int(self.color_weight)) 305 | 306 | def save(self, checkpoint_dir, step): 307 | checkpoint_dir = os.path.join(checkpoint_dir, self.model_dir) 308 | 309 | if not os.path.exists(checkpoint_dir): 310 | os.makedirs(checkpoint_dir) 311 | 312 | self.saver.save(self.sess, os.path.join(checkpoint_dir, self.model_name + '.model'), global_step=step) 313 | 314 | def load(self, checkpoint_dir): 315 | print(" [*] Reading checkpoints...") 316 | checkpoint_dir = os.path.join(checkpoint_dir, self.model_dir) 317 | 318 | ckpt = tf.train.get_checkpoint_state(checkpoint_dir) # checkpoint file information 319 | 320 | if ckpt and ckpt.model_checkpoint_path: 321 | ckpt_name = os.path.basename(ckpt.model_checkpoint_path) # first line 322 | self.saver.restore(self.sess, os.path.join(checkpoint_dir, ckpt_name)) 323 | counter = int(ckpt_name.split('-')[-1]) 324 | print(" [*] Success to read {}".format(ckpt_name)) 325 | return True, counter 326 | else: 327 | print(" [*] Failed to find a checkpoint") 328 | return False, 0 329 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnimeGAN 2 | A Tensorflow implementation of AnimeGAN for fast photo animation !     [日本語](https://github.com/TachibanaYoshino/AnimeGAN/blob/master/doc/Japanese_README.md) 3 | The paper can be accessed [here](https://github.com/TachibanaYoshino/AnimeGAN/blob/master/doc/Chen2020_Chapter_AnimeGAN.pdf) or on the [website](https://link.springer.com/chapter/10.1007/978-981-15-5577-0_18). 4 | 5 | ### If you like what I'm doing you can tip me on [*patreon*](https://www.patreon.com/Asher_Chan). 6 | 7 | Photos [](https://drive.google.com/file/d/1PbBkmj1EhULvEE8AXr2z84pZ2DQJN4hc/view?usp=sharing) 8 | 9 | Videos [](https://drive.google.com/file/d/1qhBxA72Wxbh6Eyhd-V0zY_jTIblP9rHz/view?usp=sharing) 10 | ____ 11 | * Added the AnimeGAN [Colab](https://drive.google.com/file/d/1PbBkmj1EhULvEE8AXr2z84pZ2DQJN4hc/view?usp=sharing). 12 | * [**AnimeGANv3**](https://github.com/TachibanaYoshino/AnimeGANv3) has been released. 13 | * [**AnimeGANv2, the improved version of AnimeGAN.**](https://github.com/TachibanaYoshino/AnimeGANv2) 14 | * **Online access**: Be grateful to [@TonyLianLong](https://github.com/TonyLianLong/AnimeGAN.js) for developing an online access project, you can implement photo animation through a browser without installing anything, [click here to have a try](https://animegan.js.org/). 15 | * **Pytorch version**: [pytorch-animeGAN](https://github.com/ptran1203/pytorch-animeGAN). Be grateful to @ptran1203. 16 | 17 | ----- 18 | **Some suggestions:** 19 | 1. since the real photos in the training set are all landscape photos, if you want to stylize the photos with people as the main body, you may as well add at least 3000 photos of people in the training set and retrain to obtain a new model. 20 | 2. In order to obtain a better face animation effect, when using 2 images as data pairs for training, it is suggested that the faces in the photos and the faces in the anime style data should be consistent in terms of gender as much as possible. 21 | 3. The generated stylized images will be affected by the overall brightness and tone of the style data, so try not to select the anime images of night as the style data, and it is necessary to make an exposure compensation for the overall style data to promote the consistency of brightness and darkness of the entire style data. 22 | 23 | **News:** 24 |       ***AnimeGANv2*** has been released and can be accessed [here](https://github.com/TachibanaYoshino/AnimeGANv2). 25 | ```yaml 26 | The improvement directions of AnimeGANv2 mainly include the following 4 points: 27 | ``` 28 |    1. Solve the problem of high-frequency artifacts in the generated image. 29 |    2. It is easy to train and directly achieve the effects in the paper. 30 |    3. Further reduce the number of parameters of the generator network. 31 |    4. Use new high-quality style data, which come from BD movies as much as possible. 32 | 33 | ___ 34 | 35 | ## Requirements 36 | - python 3.7 37 | - tensorflow-gpu 1.15.0 (ubuntu, GPU 2080Ti, cuda 10.0.130, cudnn 7.6.0) 38 | - opencv 39 | - tqdm 40 | - numpy 41 | - glob 42 | - argparse 43 | 44 | ## Usage 45 | ### 1. Inference 46 | e.g. `python test.py --checkpoint_dir checkpoint/generator_Hayao_weight --test_dir dataset/test/real --style_name H` 47 | 48 | ### 2. Convert video to anime 49 | e.g. `python video2anime.py --video video/input/お花見.mp4 --checkpoint_dir ./checkpoint/generator_Hayao_weight` 50 | 51 | ### 3. Train 52 | #### 1. Download vgg19 or Pretrained model 53 | > [vgg19.npy](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/vgg16%2F19.npy) 54 | 55 | > [Pretrained model](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/Haoyao-style_V1.0) 56 | 57 | #### 2. Download dataset 58 | > [Link](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/dataset-1) 59 | 60 | #### 3. Do edge_smooth 61 | e.g. `python edge_smooth.py --dataset Hayao --img_size 256` 62 | 63 | #### 4. Train 64 | e.g. `python train.py --dataset Hayao --epoch 101 --init_epoch 5` 65 | 66 | #### 5. Extract the weights of the generator 67 | e.g. `python get_generator_ckpt.py --checkpoint_dir ../checkpoint/AnimeGAN_Hayao_lsgan_300_300_1_1_10 --style_name Hayao` 68 | 69 | 70 | ____ 71 | ## Results 72 | :blush: pictures from the paper - *AnimeGAN: a novel lightweight GAN for photo animation* 73 | 74 |  75 |  76 |  77 |  78 | 79 | :heart_eyes: Photo to Hayao Style 80 | 81 |   82 |   83 |   84 |   85 |   86 |   87 |   88 |   89 |   90 |   91 |   92 | ____ 93 | ## License 94 | This repo is made freely available to academic and non-academic entities for non-commercial purposes such as academic research, teaching, scientific publications. Permission is granted to use the AnimeGAN given that you agree to my license terms. Regarding the request for commercial use, please contact us via email to help you obtain the authorization letter. 95 | ## Author 96 | Xin Chen, Gang Liu, Jie Chen 97 | ## Acknowledgment 98 | This code is based on the [CartoonGAN-Tensorflow](https://github.com/taki0112/CartoonGAN-Tensorflow/blob/master/CartoonGAN.py) and [Anime-Sketch-Coloring-with-Swish-Gated-Residual-UNet](https://github.com/pradeeplam/Anime-Sketch-Coloring-with-Swish-Gated-Residual-UNet). Thanks to the contributors of this project. 99 | 100 | -------------------------------------------------------------------------------- /Requirements installation tutorial.md: -------------------------------------------------------------------------------- 1 | 1. Linux os (Ubuntu 18.04 or 20.04), Nvidia GPU (e.g. 2080ti) , Install GPU Driver 2 | 2. Use Anaconda or Miniconda to build python environment. The Miniconda version I used can be downloaded [here](https://repo.anaconda.com/miniconda/Miniconda3-py37_4.9.2-Linux-x86_64.sh). 3 | 3. Install CUDA in conda command window : `conda install cudatoolkit=10` , Then install cudnn : `conda install cudnn=7.6.0` 4 | 4. Install other requirements by pip command, such as `pip install tensorflow-gpu==1.15.0`, `pip install tqdm`, `pip install glob` and so on. 5 | 5. Place the downloaded dataset in the corresponding directory, and then perform training and testing. 6 | 7 | -------------------------------------------------------------------------------- /checkpoint/AnimeGAN_Hayao_lsgan_300_300_1_2_10/checkpoints files: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /checkpoint/generator_Hayao_weight/Hayao-60.ckpt.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/checkpoint/generator_Hayao_weight/Hayao-60.ckpt.data-00000-of-00001 -------------------------------------------------------------------------------- /checkpoint/generator_Hayao_weight/Hayao-60.ckpt.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/checkpoint/generator_Hayao_weight/Hayao-60.ckpt.index -------------------------------------------------------------------------------- /checkpoint/generator_Hayao_weight/Hayao-60.ckpt.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/checkpoint/generator_Hayao_weight/Hayao-60.ckpt.meta -------------------------------------------------------------------------------- /checkpoint/generator_Hayao_weight/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "Hayao-60.ckpt" 2 | all_model_checkpoint_paths: "Hayao-60.ckpt" 3 | -------------------------------------------------------------------------------- /dataset/Hayao/smooth/smooth dir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/Hayao/style/style images dir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/Paprika/smooth dir/smooth images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/Paprika/style/style images dir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/Shinkai/sytle/sytle images dir: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/test/HR_photo/HR photos: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/test/real/photos: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/test/test_photo/none: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/test/test_photo256/256x256 photos: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/train_photo/train photos: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dataset/val/valid images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /doc/3-1block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/3-1block.png -------------------------------------------------------------------------------- /doc/Chen2020_Chapter_AnimeGAN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/Chen2020_Chapter_AnimeGAN.pdf -------------------------------------------------------------------------------- /doc/GD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/GD.png -------------------------------------------------------------------------------- /doc/Japanese_README.md: -------------------------------------------------------------------------------- 1 | # AnimeGAN 2 | このAnimeGANは写真をアニメに素早く変換するために使用できます! 3 | 論文は[ここ](https://github.com/TachibanaYoshino/AnimeGAN/blob/master/doc/Chen2020_Chapter_AnimeGAN.pdf) あるいはこの[サイト](https://link.springer.com/chapter/10.1007/978-981-15-5577-0_18) からアクセスできます。 4 | 5 | [**AnimeGANの改良版である AnimeGANv2.**](https://github.com/TachibanaYoshino/AnimeGANv2) 6 | **オンラインアクセス**: このオンラインサイトを開発してくれた[@TonyLianLong](https://github.com/TonyLianLong/AnimeGAN.js) のおかげで、何もインストールしなくてもブラウザから直接アクセスできます。[ここをクリックして試してみてください!](https://animegan.js.org/) 7 | **Pytorch version**: [pytorch-animeGAN](https://github.com/ptran1203/pytorch-animeGAN). 8 | 9 | ----- 10 | **いくつかのアドバイス** 11 | 1. 訓練セットの真実の写真は風景写真ですので、人物を主体として写真を様式化するなら、トレーニングセットに少なくとも3000人の写真を追加して、新たなモデルを獲得するようにトレーニングしてください。 12 | 2. より良い顔アニメーション効果を得るために、2枚の画像をデータとして使ってトレーニングする場合、写真の顔とアニメスタイルデータの中の顔は性別においてできるだけ一致するようにすることをおすすめします。 13 | 3. 生成された画風化画像は、スタイルデータの全体的な輝度と色調の影響を受けるので、できるだけ夜のアニメ画像をスタイルデータとして選択しないでください。また、全体のスタイルデータに対して露出補償を行う必要があります。全体のスタイルデータの明暗一致を促進します。 14 | 15 | **新しいニュース**: 16 |       **AnimeGANv2** がリリースされ、[**ここ**](https://github.com/TachibanaYoshino/AnimeGANv2)からアクセスできます。 17 | ```yaml 18 | AnimeGANv2 の改善方針には、主に以下の4点があります。 19 | ``` 20 |    1. 生成された画像の高周波アーティファクトの問題を解決する。 21 |    2. トレーニングが簡単で、論文の効果を直接達成できます。 22 |    3. ジェネレーターネットワークのパラメーターの数をさらに減らします。 23 |    4. 可能な限りBDムービーからの新しい高品質スタイルデータを使用します。 24 | 25 | ___ 26 | 27 | ## インストール依存項 28 | - python 3.7 29 | - tensorflow-gpu 1.15.0 (ubuntu, GPU 2080Ti, cuda 10.0.130, cudnn 7.6.0) 30 | - opencv 31 | - tqdm 32 | - numpy 33 | - glob 34 | - argparse 35 | 36 | ## 使い方 37 | ### 1. テスト 38 | e.g. `python test.py --checkpoint_dir checkpoint/generator_Hayao_weight --test_dir dataset/test/real --style_name H` 39 | 40 | ### 2. ビデオをアニメに変換します 41 | e.g. `python video2anime.py --video video/input/お花見.mp4 --checkpoint_dir ./checkpoint/generator_Hayao_weight` 42 | 43 | ### 3.トレーニング 44 | #### 1. vgg 19あるいは予備トレーニングのモデルをダウンロードします 45 | > [vgg19.npy](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/vgg16%2F19.npy) 46 | 47 | > [Pretrained model](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/Haoyao-style_v1.0) 48 | 49 | #### 2. データセットをダウンロード 50 | > [Link](https://github.com/TachibanaYoshino/AnimeGAN/releases/tag/dataset-1) 51 | 52 | #### 3. エッジブラーを実行する 53 | e.g. `python edge_smooth.py --dataset Hayao --img_size 256` 54 | 55 | #### 4. トレーニング 56 | e.g. `python train.py --dataset Hayao --epoch 101 --init_epoch 5` 57 | 58 | #### 5. ジェネレーターのパラメーターを抽出する 59 | e.g. `python get_generator_ckpt.py --checkpoint_dir ../checkpoint/AnimeGAN_Hayao_lsgan_300_300_1_1_10 --style_name Hayao` 60 | 61 | ____ 62 | ## 結果 63 | :blush: 論文からの画像。 64 | 65 |  66 |  67 |  68 |  69 | 70 | :heart_eyes: 写真は宮崎さんのアニメスタイルになります。 71 | 72 |   73 |   74 |   75 |   76 |   77 |   78 |   79 |   80 |   81 |   82 |   83 | _____ 84 | ## ライセンス 85 | このレポは、学術研究、教育、科学出版物などの非営利目的で、学術団体および非学術団体が自由に利用できるようになっています。 86 | 私のライセンス条項に同意すると、AnimeGANの使用が許可されます。 商用利用のリクエストについては、承認書を入手するためにメールでご連絡ください。 87 | ## 著者 88 | Xin Chen, Gang Liu, Jie Chen 89 | ## 感謝 90 | このコードは[CartoonGAN-Tensorflow](https://github.com/taki0112/CartoonGAN-Tensorflow/blob/master/CartoonGAN.py) と [Anime-Sketch-Coloring-with-Swish-Gated-Residual-UNet](https://github.com/pradeeplam/Anime-Sketch-Coloring-with-Swish-Gated-Residual-UNet) に基づいています。彼らの貢献に感謝します。 91 | 92 | -------------------------------------------------------------------------------- /doc/e2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/e2.png -------------------------------------------------------------------------------- /doc/e3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/e3.png -------------------------------------------------------------------------------- /doc/e4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/e4.png -------------------------------------------------------------------------------- /doc/sota.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/doc/sota.png -------------------------------------------------------------------------------- /net/discriminator.py: -------------------------------------------------------------------------------- 1 | 2 | from tools.ops import * 3 | 4 | def D_net(x_init,ch, n_dis,sn, scope, reuse): 5 | channel = ch // 2 6 | with tf.variable_scope(scope, reuse=reuse): 7 | x = conv(x_init, channel, kernel=3, stride=1, pad=1, use_bias=False, sn=sn, scope='conv_0') 8 | x = lrelu(x, 0.2) 9 | 10 | for i in range(1, n_dis): 11 | x = conv(x, channel * 2, kernel=3, stride=2, pad=1, use_bias=False, sn=sn, scope='conv_s2_' + str(i)) 12 | x = lrelu(x, 0.2) 13 | 14 | x = conv(x, channel * 4, kernel=3, stride=1, pad=1, use_bias=False, sn=sn, scope='conv_s1_' + str(i)) 15 | x = instance_norm(x, scope='ins_norm_' + str(i)) 16 | x = lrelu(x, 0.2) 17 | 18 | channel = channel * 2 19 | 20 | x = conv(x, channel * 2, kernel=3, stride=1, pad=1, use_bias=False, sn=sn, scope='last_conv') 21 | x = instance_norm(x, scope='last_ins_norm') 22 | x = lrelu(x, 0.2) 23 | 24 | x = conv(x, channels=1, kernel=3, stride=1, pad=1, use_bias=False, sn=sn, scope='D_logit') 25 | 26 | return x 27 | 28 | -------------------------------------------------------------------------------- /net/generator.py: -------------------------------------------------------------------------------- 1 | from tools.ops import * 2 | import tensorflow as tf 3 | 4 | 5 | def Conv2D(inputs, filters, kernel_size=3, strides=1, padding='VALID', Use_bias = None): 6 | if kernel_size == 3: 7 | inputs = tf.pad(inputs, [[0, 0], [1, 1], [1, 1], [0, 0]], mode="REFLECT") 8 | return tf.contrib.layers.conv2d( 9 | inputs, 10 | num_outputs=filters, 11 | kernel_size=kernel_size, 12 | stride=strides, 13 | biases_initializer= Use_bias, 14 | normalizer_fn=None, 15 | activation_fn=None, 16 | padding=padding) 17 | 18 | 19 | def Conv2DNormLReLU(inputs, filters, kernel_size=3, strides=1, padding='VALID', Use_bias = None): 20 | x = Conv2D(inputs, filters, kernel_size, strides,padding=padding, Use_bias = Use_bias) 21 | x = instance_norm(x,scope=None) 22 | return lrelu(x) 23 | 24 | def dwise_conv(input, k_h=3, k_w=3, channel_multiplier=1, strides=[1, 1, 1, 1], 25 | padding='VALID', stddev=0.02, name='dwise_conv', bias=False): 26 | input = tf.pad(input, [[0, 0], [1, 1], [1, 1], [0, 0]], mode="REFLECT") 27 | with tf.variable_scope(name): 28 | in_channel = input.get_shape().as_list()[-1] 29 | w = tf.get_variable('w', [k_h, k_w, in_channel, channel_multiplier],regularizer=None,initializer=tf.truncated_normal_initializer(stddev=stddev)) 30 | conv = tf.nn.depthwise_conv2d(input, w, strides, padding, rate=None, name=name, data_format=None) 31 | if bias: 32 | biases = tf.get_variable('bias', [in_channel * channel_multiplier],initializer=tf.constant_initializer(0.0)) 33 | conv = tf.nn.bias_add(conv, biases) 34 | return conv 35 | 36 | def Separable_conv2d(inputs, filters, kernel_size=3, strides=1, padding='VALID', Use_bias = None): 37 | if kernel_size==3 and strides==1: 38 | inputs = tf.pad(inputs, [[0, 0], [1, 1], [1, 1], [0, 0]], mode="REFLECT") 39 | if strides == 2: 40 | inputs = tf.pad(inputs, [[0, 0], [0, 1], [0, 1], [0, 0]], mode="REFLECT") 41 | return tf.contrib.layers.separable_conv2d( 42 | inputs, 43 | num_outputs=filters, 44 | kernel_size=kernel_size, 45 | depth_multiplier=1, 46 | stride=strides, 47 | biases_initializer=Use_bias, 48 | normalizer_fn=tf.contrib.layers.instance_norm, 49 | activation_fn=lrelu, 50 | padding=padding) 51 | 52 | def Conv2DTransposeLReLU(inputs, filters, kernel_size=2, strides=2, padding='SAME', Use_bias = None): 53 | 54 | return tf.contrib.layers.conv2d_transpose(inputs, 55 | num_outputs=filters, 56 | kernel_size=kernel_size, 57 | stride=strides, 58 | biases_initializer=Use_bias, 59 | normalizer_fn=tf.contrib.layers.instance_norm, 60 | activation_fn=lrelu, 61 | padding=padding) 62 | 63 | def Unsample(inputs, filters, kernel_size=3): 64 | ''' 65 | An alternative to transposed convolution where we first resize, then convolve. 66 | See http://distill.pub/2016/deconv-checkerboard/ 67 | For some reason the shape needs to be statically known for gradient propagation 68 | through tf.image.resize_images, but we only know that for fixed image size, so we 69 | plumb through a "training" argument 70 | ''' 71 | new_H, new_W = 2 * tf.shape(inputs)[1], 2 * tf.shape(inputs)[2] 72 | inputs = tf.image.resize_images(inputs, [new_H, new_W]) 73 | 74 | return Separable_conv2d(filters=filters, kernel_size=kernel_size, inputs=inputs) 75 | 76 | def Downsample(inputs, filters = 256, kernel_size=3): 77 | ''' 78 | An alternative to transposed convolution where we first resize, then convolve. 79 | See http://distill.pub/2016/deconv-checkerboard/ 80 | For some reason the shape needs to be statically known for gradient propagation 81 | through tf.image.resize_images, but we only know that for fixed image size, so we 82 | plumb through a "training" argument 83 | ''' 84 | 85 | new_H, new_W = tf.shape(inputs)[1] // 2, tf.shape(inputs)[2] // 2 86 | inputs = tf.image.resize_images(inputs, [new_H, new_W]) 87 | 88 | return Separable_conv2d(filters=filters, kernel_size=kernel_size, inputs=inputs) 89 | 90 | 91 | 92 | 93 | class G_net(object): 94 | 95 | def __init__(self, inputs): 96 | 97 | with tf.variable_scope('G_MODEL'): 98 | 99 | with tf.variable_scope('b1'): 100 | inputs = Conv2DNormLReLU(inputs, 64) 101 | inputs = Conv2DNormLReLU(inputs, 64) 102 | inputs = Separable_conv2d(inputs,128,strides=2) + Downsample(inputs, 128) 103 | 104 | with tf.variable_scope('b2'): 105 | inputs = Conv2DNormLReLU(inputs, 128) 106 | inputs = Separable_conv2d(inputs, 128) 107 | inputs = Separable_conv2d(inputs, 256, strides=2) + Downsample(inputs, 256) 108 | 109 | with tf.variable_scope('m'): 110 | inputs = Conv2DNormLReLU(inputs, 256) 111 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r1') 112 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r2') 113 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r3') 114 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r4') 115 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r5') 116 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r6') 117 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r7') 118 | inputs = self.InvertedRes_block(inputs, 2, 256, 1, 'r8') 119 | inputs = Conv2DNormLReLU(inputs, 256) 120 | with tf.variable_scope('u2'): 121 | inputs = Unsample(inputs, 128) 122 | inputs = Separable_conv2d(inputs, 128) 123 | inputs = Conv2DNormLReLU(inputs, 128) 124 | 125 | with tf.variable_scope('u1'): 126 | inputs = Unsample(inputs,128) # The number of the filters in this layer is 128 while it is 64 in the graph of the paper. Please refer to the code. 127 | inputs = Conv2DNormLReLU(inputs, 64) 128 | inputs = Conv2DNormLReLU(inputs, 64) 129 | 130 | out = Conv2D(inputs, filters =3, kernel_size=1, strides=1) 131 | self.fake = tf.tanh(out) 132 | 133 | 134 | def InvertedRes_block(self, input, expansion_ratio, output_dim, stride, name, reuse=False, bias=None): 135 | with tf.variable_scope(name, reuse=reuse): 136 | # pw 137 | bottleneck_dim = round(expansion_ratio * input.get_shape().as_list()[-1]) 138 | net = Conv2DNormLReLU(input, bottleneck_dim, kernel_size=1, Use_bias=bias) 139 | 140 | # dw 141 | net = dwise_conv(net, name=name) 142 | net = instance_norm(net,scope='1') 143 | net = lrelu(net) 144 | 145 | # pw & linear 146 | net = Conv2D(net, output_dim, kernel_size=1) 147 | net = instance_norm(net,scope='2') 148 | 149 | # element wise add, only for stride==1 150 | if (int(input.get_shape().as_list()[-1]) == output_dim) and stride == 1: 151 | net = input + net 152 | 153 | return net 154 | -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/105.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/185.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/185.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/19.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/190.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/190.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/198.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/198.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/204.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/204.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/208.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/208.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/246.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/246.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/256.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/256.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/258.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/258.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/26.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/35.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/447.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/447.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/539.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/539.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/599.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/599.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/618.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/618.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/632.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/632.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/675.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/675.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/681.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/681.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/69.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/69.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/75.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/75.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/AnimeGAN/762.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/AnimeGAN/762.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/105_1562736508.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/105_1562736508.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/185_1562736844.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/185_1562736844.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/190_1562737136.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/190_1562737136.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/198_1562737236.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/198_1562737236.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/19_1562736964.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/19_1562736964.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/204_1562737290.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/204_1562737290.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/208_1562737392.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/208_1562737392.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/246_1562737460.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/246_1562737460.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/256_1562739338.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/256_1562739338.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/258_1562737714.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/258_1562737714.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/26_1562737803.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/26_1562737803.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/35_1562737865.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/35_1562737865.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/447_1562737943.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/447_1562737943.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/539_1562738321.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/539_1562738321.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/599_1562739505.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/599_1562739505.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/618_1562739199.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/618_1562739199.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/632_1562738596.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/632_1562738596.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/675_1562738662.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/675_1562738662.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/681_1562738765.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/681_1562738765.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/69_1562738956.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/69_1562738956.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/75_1562739149.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/75_1562739149.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/CartoonGAN/762_1562739095.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/CartoonGAN/762_1562739095.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/105.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/105.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/185.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/185.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/19.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/190.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/190.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/198.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/198.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/204.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/204.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/208.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/208.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/246.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/246.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/256.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/258.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/258.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/26.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/35.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/447.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/447.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/539.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/539.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/599.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/599.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/618.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/618.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/632.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/632.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/675.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/675.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/681.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/681.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/69.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/75.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/ComixGAN/762.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/ComixGAN/762.png -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/105.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/185.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/185.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/19.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/190.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/190.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/198.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/198.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/204.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/204.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/208.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/208.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/246.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/246.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/256.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/256.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/258.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/258.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/26.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/35.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/447.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/447.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/539.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/539.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/599.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/599.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/618.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/618.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/632.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/632.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/675.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/675.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/681.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/681.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/69.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/69.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/75.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/75.jpg -------------------------------------------------------------------------------- /result/Hayao/SOTA_comparison/real/762.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/SOTA_comparison/real/762.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 1.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 10.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 11.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 12.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 13.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 14.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 15.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 16.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 17.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 18.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 19.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 2.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 20.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 21.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 22.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 23.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 24.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 25.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 26.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 27.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 28.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 29.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 3.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 30.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 31.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 32.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 33.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 34.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 35.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 36.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 37.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 38.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 39.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 4.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 40.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 41.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 42.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 43.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 44.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 45.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 5.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 6.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 7.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 8.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/ 9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/ 9.jpg -------------------------------------------------------------------------------- /result/Hayao/photo/AE86.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo/AE86.png -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 1.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 10.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 11.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 12.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 13.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 14.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 15.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 16.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 17.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 18.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 19.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 2.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 20.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 21.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 22.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 23.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 24.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 25.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 26.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 27.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 28.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 29.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 3.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 30.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 31.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 32.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 33.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 34.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 35.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 36.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 37.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 38.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 39.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 4.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 40.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 41.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 42.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 43.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 44.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 45.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 5.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 6.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 7.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 8.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/ 9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/ 9.jpg -------------------------------------------------------------------------------- /result/Hayao/photo_result/AE86.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/result/Hayao/photo_result/AE86.png -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | from tools.utils import * 3 | import os 4 | from tqdm import tqdm 5 | from glob import glob 6 | import time 7 | import numpy as np 8 | from net import generator 9 | os.environ["CUDA_VISIBLE_DEVICES"] = "0" 10 | 11 | def parse_args(): 12 | desc = "AnimeGAN" 13 | parser = argparse.ArgumentParser(description=desc) 14 | 15 | parser.add_argument('--checkpoint_dir', type=str, default='checkpoint/'+'generator_Hayao_weight/', 16 | help='Directory name to save the checkpoints') 17 | parser.add_argument('--test_dir', type=str, default='dataset/test/HR_photo', 18 | help='Directory name of test photos') 19 | parser.add_argument('--style_name', type=str, default='Hayao', 20 | help='what style you want to get') 21 | parser.add_argument('--if_adjust_brightness', type=bool, default=False, 22 | help='adjust brightness by the real photo') 23 | 24 | return parser.parse_args() 25 | 26 | def stats_graph(graph): 27 | flops = tf.profiler.profile(graph, options=tf.profiler.ProfileOptionBuilder.float_operation()) 28 | # params = tf.profiler.profile(graph, options=tf.profiler.ProfileOptionBuilder.trainable_variables_parameter()) 29 | print('FLOPs: {}'.format(flops.total_float_ops)) 30 | 31 | def test(checkpoint_dir, style_name, test_dir, if_adjust_brightness, img_size=[256,256]): 32 | # tf.reset_default_graph() 33 | test_files = glob('{}/*.*'.format(test_dir)) 34 | 35 | result_dir = 'results/'+style_name 36 | check_folder(result_dir) 37 | 38 | # test_real = tf.placeholder(tf.float32, [1, 256, 256, 3], name='test') 39 | test_real = tf.placeholder(tf.float32, [1, None, None, 3], name='test') 40 | 41 | with tf.variable_scope("generator", reuse=False): 42 | test_generated = generator.G_net(test_real).fake 43 | 44 | generator_var = [var for var in tf.trainable_variables() if var.name.startswith('generator')] 45 | saver = tf.train.Saver(generator_var) 46 | 47 | gpu_options = tf.GPUOptions(allow_growth=True) 48 | with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options)) as sess: 49 | # tf.global_variables_initializer().run() 50 | # load model 51 | ckpt = tf.train.get_checkpoint_state(checkpoint_dir) # checkpoint file information 52 | if ckpt and ckpt.model_checkpoint_path: 53 | ckpt_name = os.path.basename(ckpt.model_checkpoint_path) # first line 54 | saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name)) 55 | print(" [*] Success to read {}".format(ckpt_name)) 56 | else: 57 | print(" [*] Failed to find a checkpoint") 58 | return 59 | 60 | # FLOPs 61 | # stats_graph(tf.get_default_graph()) 62 | 63 | begin = time.time() 64 | for sample_file in tqdm(test_files) : 65 | # print('Processing image: ' + sample_file) 66 | sample_image = np.asarray(load_test_data(sample_file, img_size)) 67 | image_path = os.path.join(result_dir,'{0}'.format(os.path.basename(sample_file))) 68 | fake_img = sess.run(test_generated, feed_dict = {test_real : sample_image}) 69 | if if_adjust_brightness: 70 | save_images(fake_img, image_path, sample_file) 71 | else: 72 | save_images(fake_img, image_path, None) 73 | end = time.time() 74 | print(f'test-time: {end-begin} s') 75 | print(f'one image test time : {(end-begin)/len(test_files)} s') 76 | print(f'result path: {result_dir}') 77 | if __name__ == '__main__': 78 | arg = parse_args() 79 | print(arg.checkpoint_dir) 80 | test(arg.checkpoint_dir, arg.style_name, arg.test_dir, arg.if_adjust_brightness) 81 | -------------------------------------------------------------------------------- /tools/adjust_brightness.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | def read_img(image_path): 5 | img = cv2.imread(image_path) 6 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 7 | assert len(img.shape)==3 8 | return img 9 | 10 | 11 | # Calculates the average brightness in the specified irregular image 12 | def calculate_average_brightness(img): 13 | # Average value of three color channels 14 | B = img[..., 0].mean() 15 | G = img[..., 1].mean() 16 | R = img[..., 2].mean() 17 | 18 | brightness = 0.299 * R + 0.587 * G + 0.114 * B 19 | return brightness, B, G, R 20 | 21 | # Adjusting the average brightness of the target image to the average brightness of the source image 22 | def adjust_brightness_from_src_to_dst(dst, src,path=None,if_show=None, if_info=None): 23 | brightness1, B1, G1, R1 = calculate_average_brightness(src) 24 | brightness2, B2, G2, R2 = calculate_average_brightness(dst) 25 | brightness_difference = brightness1 / brightness2 26 | 27 | if if_info: 28 | print('Average brightness of original image', brightness1) 29 | print('Average brightness of target', brightness2) 30 | print('Brightness Difference between Original Image and Target', brightness_difference) 31 | 32 | # According to the average display brightness 33 | dstf = dst * brightness_difference 34 | 35 | # According to the average value of the three-color channel 36 | # dstf = dst.copy().astype(np.float32) 37 | # dstf[..., 0] = dst[..., 0] * (B1 / B2) 38 | # dstf[..., 1] = dst[..., 1] * (G1 / G2) 39 | # dstf[..., 2] = dst[..., 2] * (R1 / R2) 40 | 41 | # To limit the results and prevent crossing the border, 42 | # it must be converted to uint8, otherwise the default result is float32, and errors will occur. 43 | dstf = np.clip(dstf, 0, 255) 44 | dstf = np.uint8(dstf) 45 | 46 | ma,na,_ = src.shape 47 | mb,nb,_ = dst.shape 48 | result_show_img = np.zeros((max(ma, mb), 3 * max(na, nb), 3)) 49 | result_show_img[:mb, :nb, :] = dst 50 | result_show_img[:ma, nb:nb + na, :] = src 51 | result_show_img[:mb, nb + na:nb + na + nb, :] = dstf 52 | result_show_img = result_show_img.astype(np.uint8) 53 | 54 | if if_show: 55 | cv2.imshow('-', cv2.cvtColor(result_show_img, cv2.COLOR_BGR2RGB)) 56 | cv2.waitKey(0) 57 | cv2.destroyAllWindows() 58 | 59 | if path != None: 60 | cv2.imwrite(path, cv2.cvtColor(result_show_img, cv2.COLOR_BGR2RGB)) 61 | 62 | return dstf 63 | 64 | if __name__ == '__main__': 65 | 66 | A = read_img('../Brightness_tool/A.png') 67 | B = read_img('../Brightness_tool/B.png') 68 | 69 | # adjusted = adjust_brightness_from_src_to_dst(A, B, path='resA.png') 70 | adjusted = adjust_brightness_from_src_to_dst(A, B) 71 | -------------------------------------------------------------------------------- /tools/data_loader.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tensorflow as tf 3 | import cv2,random 4 | import numpy as np 5 | 6 | 7 | class ImageGenerator(object): 8 | 9 | def __init__(self, image_dir,size, batch_size, num_cpus = 16): 10 | self.paths = self.get_image_paths_train(image_dir) 11 | self.num_images = len(self.paths) 12 | self.num_cpus = num_cpus 13 | self.size = size 14 | self.batch_size = batch_size 15 | 16 | def get_image_paths_train(self, image_dir): 17 | paths = [] 18 | for path in os.listdir(image_dir): 19 | # Check extensions of filename 20 | if path.split('.')[-1] not in ['jpg', 'jpeg', 'png', 'gif']: 21 | continue 22 | 23 | # Construct complete path to anime image 24 | path_full = os.path.join(image_dir, path) 25 | 26 | # Validate if colorized image exists 27 | if not os.path.isfile(path_full): 28 | continue 29 | paths.append(path_full) 30 | return paths 31 | 32 | def read_image(self, img_path1): 33 | 34 | if 'style' in img_path1.decode() or 'smooth' in img_path1.decode(): 35 | # color image1 36 | image1 = cv2.imread(img_path1.decode()).astype(np.float32) 37 | image1 = cv2.cvtColor(image1, cv2.COLOR_BGR2RGB) 38 | 39 | # gray image2 40 | image2 = cv2.imread(img_path1.decode(),cv2.IMREAD_GRAYSCALE).astype(np.float32) 41 | image2 = np.asarray([image2,image2,image2]) 42 | image2= np.transpose(image2,(1,2,0)) 43 | 44 | else: 45 | # color image1 46 | image1 = cv2.imread(img_path1.decode()).astype(np.float32) 47 | image1 = cv2.cvtColor(image1, cv2.COLOR_BGR2RGB) 48 | 49 | image2 = np.zeros(image1.shape).astype(np.float32) 50 | 51 | return image1, image2 52 | 53 | def load_image(self, img1 ): 54 | image1, image2 = self.read_image(img1) 55 | processing_image1 = image1/ 127.5 - 1.0 56 | processing_image2 = image2/ 127.5 - 1.0 57 | return (processing_image1,processing_image2) 58 | 59 | def load_images(self): 60 | 61 | dataset = tf.data.Dataset.from_tensor_slices(self.paths) 62 | 63 | # Repeat indefinitely 64 | dataset = dataset.repeat() 65 | 66 | # Unform shuffle 67 | dataset = dataset.shuffle(buffer_size=len(self.paths)) 68 | 69 | # Map path to image 70 | dataset = dataset.map(lambda img: tf.py_func( 71 | self.load_image, [img], [tf.float32,tf.float32]), 72 | self.num_cpus) 73 | 74 | dataset = dataset.batch(self.batch_size) 75 | 76 | img1,img2 = dataset.make_one_shot_iterator().get_next() 77 | 78 | return img1,img2 79 | -------------------------------------------------------------------------------- /tools/data_mean.py: -------------------------------------------------------------------------------- 1 | 2 | import cv2, argparse, os 3 | from glob import glob 4 | from tqdm import tqdm 5 | 6 | def parse_args(): 7 | desc = "get the mean values of b,g,r on the whole dataset" 8 | parser = argparse.ArgumentParser(description=desc) 9 | parser.add_argument('--dataset', type=str, default='Hayao', help='dataset_name') 10 | 11 | return parser.parse_args() 12 | 13 | def read_img(image_path): 14 | img = cv2.imread(image_path) 15 | assert len(img.shape) == 3 16 | B = img[..., 0].mean() 17 | G = img[..., 1].mean() 18 | R = img[..., 2].mean() 19 | return B,G,R 20 | 21 | def get_mean(dataset_name): 22 | file_list = glob(os.path.dirname(os.path.dirname(__file__))+'/dataset/{}/{}/*.*'.format(dataset_name, 'style')) 23 | image_num = len(file_list) 24 | print('image_num:', image_num) 25 | 26 | B_total = 0 27 | G_total = 0 28 | R_total = 0 29 | for f in tqdm(file_list) : 30 | bgr = read_img(f) 31 | B_total += bgr[0] 32 | G_total += bgr[1] 33 | R_total += bgr[2] 34 | 35 | B_mean, G_mean, R_mean = B_total / image_num, G_total / image_num, R_total / image_num 36 | mean = (B_mean + G_mean + R_mean)/3 37 | 38 | return mean-B_mean, mean-G_mean, mean-R_mean 39 | 40 | """main""" 41 | def main(): 42 | # parse arguments 43 | args = parse_args() 44 | if args is None: 45 | exit() 46 | 47 | return get_mean(args.dataset) 48 | if __name__ == '__main__': 49 | result = main() 50 | print('style_data_mean_diff (B, G, R): ', result) -------------------------------------------------------------------------------- /tools/edge_smooth.py: -------------------------------------------------------------------------------- 1 | # The edge_smooth.py is from taki0112/CartoonGAN-Tensorflow https://github.com/taki0112/CartoonGAN-Tensorflow#2-do-edge_smooth 2 | from tools.utils import check_folder 3 | import numpy as np 4 | import cv2, os, argparse 5 | from glob import glob 6 | from tqdm import tqdm 7 | 8 | def parse_args(): 9 | desc = "Edge smoothed" 10 | parser = argparse.ArgumentParser(description=desc) 11 | parser.add_argument('--dataset', type=str, default='Paprika', help='dataset_name') 12 | parser.add_argument('--img_size', type=int, default=256, help='The size of image') 13 | 14 | return parser.parse_args() 15 | 16 | def make_edge_smooth(dataset_name, img_size) : 17 | check_folder(os.path.dirname(os.path.dirname(__file__))+'/dataset/{}/{}'.format(dataset_name, 'smooth')) 18 | 19 | file_list = glob(os.path.dirname(os.path.dirname(__file__))+'/dataset/{}/{}/*.*'.format(dataset_name, 'style')) 20 | save_dir = os.path.dirname(os.path.dirname(__file__))+'/dataset/{}/smooth'.format(dataset_name) 21 | 22 | kernel_size = 5 23 | kernel = np.ones((kernel_size, kernel_size), np.uint8) 24 | gauss = cv2.getGaussianKernel(kernel_size, 0) 25 | gauss = gauss * gauss.transpose(1, 0) 26 | 27 | for f in tqdm(file_list) : 28 | file_name = os.path.basename(f) 29 | 30 | bgr_img = cv2.imread(f) 31 | gray_img = cv2.imread(f, 0) 32 | 33 | bgr_img = cv2.resize(bgr_img, (img_size, img_size)) 34 | pad_img = np.pad(bgr_img, ((2, 2), (2, 2), (0, 0)), mode='reflect') 35 | gray_img = cv2.resize(gray_img, (img_size, img_size)) 36 | 37 | edges = cv2.Canny(gray_img, 100, 200) 38 | dilation = cv2.dilate(edges, kernel) 39 | 40 | gauss_img = np.copy(bgr_img) 41 | idx = np.where(dilation != 0) 42 | for i in range(np.sum(dilation != 0)): 43 | gauss_img[idx[0][i], idx[1][i], 0] = np.sum( 44 | np.multiply(pad_img[idx[0][i]:idx[0][i] + kernel_size, idx[1][i]:idx[1][i] + kernel_size, 0], gauss)) 45 | gauss_img[idx[0][i], idx[1][i], 1] = np.sum( 46 | np.multiply(pad_img[idx[0][i]:idx[0][i] + kernel_size, idx[1][i]:idx[1][i] + kernel_size, 1], gauss)) 47 | gauss_img[idx[0][i], idx[1][i], 2] = np.sum( 48 | np.multiply(pad_img[idx[0][i]:idx[0][i] + kernel_size, idx[1][i]:idx[1][i] + kernel_size, 2], gauss)) 49 | 50 | cv2.imwrite(os.path.join(save_dir, file_name), gauss_img) 51 | 52 | """main""" 53 | def main(): 54 | # parse arguments 55 | args = parse_args() 56 | if args is None: 57 | exit() 58 | 59 | make_edge_smooth(args.dataset, args.img_size) 60 | 61 | 62 | if __name__ == '__main__': 63 | main() 64 | -------------------------------------------------------------------------------- /tools/get_generator_ckpt.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | from tools.utils import * 3 | import os 4 | from net import generator 5 | 6 | os.environ["CUDA_VISIBLE_DEVICES"] = "0" 7 | 8 | def parse_args(): 9 | desc = "AnimeGAN" 10 | parser = argparse.ArgumentParser(description=desc) 11 | 12 | parser.add_argument('--checkpoint_dir', type=str, default='../checkpoint/' + 'AnimeGAN_Hayao_lsgan_300_300_1_2_10', 13 | help='Directory name to save the checkpoints') 14 | parser.add_argument('--style_name', type=str, default='Hayao', 15 | help='what style you want to get') 16 | 17 | return parser.parse_args() 18 | 19 | def save(saver, sess, checkpoint_dir, model_name): 20 | 21 | save_path = os.path.join(checkpoint_dir, model_name + '.ckpt') 22 | saver.save(sess, save_path, write_meta_graph=True) 23 | return save_path 24 | 25 | def main(checkpoint_dir, style_name, ): 26 | 27 | ckpt_dir = '../checkpoint/' + 'generator_'+style_name+'_weight' 28 | check_folder(ckpt_dir) 29 | 30 | placeholder = tf.placeholder(tf.float32, [1, None, None, 3], name='generator_input') 31 | with tf.variable_scope("generator", reuse=False): 32 | _ = generator.G_net(placeholder).fake 33 | 34 | generator_var = [var for var in tf.trainable_variables() if var.name.startswith('generator')] 35 | saver = tf.train.Saver(generator_var) 36 | 37 | gpu_options = tf.GPUOptions(allow_growth=True) 38 | with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options)) as sess: 39 | sess.run(tf.global_variables_initializer()) 40 | # load model 41 | ckpt = tf.train.get_checkpoint_state(checkpoint_dir) # checkpoint file information 42 | if ckpt and ckpt.model_checkpoint_path: 43 | print(ckpt.model_checkpoint_path) 44 | ckpt_name = os.path.basename(ckpt.model_checkpoint_path) # first line 45 | saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name)) 46 | counter = ckpt_name.split('-')[-1] 47 | print(" [*] Success to read {}".format(ckpt_name)) 48 | else: 49 | print(" [*] Failed to find a checkpoint") 50 | return 51 | 52 | info = save(saver, sess, ckpt_dir, style_name+'-'+counter) 53 | 54 | print(f'save over : {info} ') 55 | 56 | 57 | 58 | if __name__ == '__main__': 59 | arg = parse_args() 60 | print(arg.checkpoint_dir) 61 | main(arg.checkpoint_dir, arg.style_name) 62 | -------------------------------------------------------------------------------- /tools/ops.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | import tensorflow.contrib as tf_contrib 3 | 4 | 5 | # Xavier : tf_contrib.layers.xavier_initializer() 6 | # He : tf_contrib.layers.variance_scaling_initializer() 7 | # Normal : tf.random_normal_initializer(mean=0.0, stddev=0.02) 8 | # l2_decay : tf_contrib.layers.l2_regularizer(0.0001) 9 | 10 | 11 | weight_init = tf.random_normal_initializer(mean=0.0, stddev=0.02) 12 | weight_regularizer = None 13 | 14 | ################################################################################## 15 | # Layer 16 | ################################################################################## 17 | 18 | def conv(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, sn=False, scope='conv_0'): 19 | with tf.variable_scope(scope): 20 | if (kernel - stride) % 2 == 0 : 21 | pad_top = pad 22 | pad_bottom = pad 23 | pad_left = pad 24 | pad_right = pad 25 | 26 | else : 27 | pad_top = pad 28 | pad_bottom = kernel - stride - pad_top 29 | pad_left = pad 30 | pad_right = kernel - stride - pad_left 31 | 32 | if pad_type == 'zero' : 33 | x = tf.pad(x, [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]) 34 | if pad_type == 'reflect' : 35 | x = tf.pad(x, [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]], mode='REFLECT') 36 | 37 | if sn : 38 | w = tf.get_variable("kernel", shape=[kernel, kernel, x.get_shape()[-1], channels], initializer=weight_init, 39 | regularizer=weight_regularizer) 40 | x = tf.nn.conv2d(input=x, filter=spectral_norm(w), 41 | strides=[1, stride, stride, 1], padding='VALID') 42 | if use_bias : 43 | bias = tf.get_variable("bias", [channels], initializer=tf.constant_initializer(0.0)) 44 | x = tf.nn.bias_add(x, bias) 45 | 46 | else : 47 | x = tf.layers.conv2d(inputs=x, filters=channels, 48 | kernel_size=kernel, kernel_initializer=weight_init, 49 | kernel_regularizer=weight_regularizer, 50 | strides=stride, use_bias=use_bias) 51 | 52 | 53 | return x 54 | 55 | def deconv(x, channels, kernel=4, stride=2, use_bias=True, sn=False, scope='deconv_0'): 56 | with tf.variable_scope(scope): 57 | x_shape = x.get_shape().as_list() 58 | output_shape = [x_shape[0], tf.shape(x)[1]*stride, tf.shape(x)[2]*stride, channels] 59 | if sn : 60 | w = tf.get_variable("kernel", shape=[kernel, kernel, channels, x.get_shape()[-1]], initializer=weight_init, regularizer=weight_regularizer) 61 | x = tf.nn.conv2d_transpose(x, filter=spectral_norm(w), output_shape=output_shape, strides=[1, stride, stride, 1], padding='SAME') 62 | 63 | if use_bias : 64 | bias = tf.get_variable("bias", [channels], initializer=tf.constant_initializer(0.0)) 65 | x = tf.nn.bias_add(x, bias) 66 | 67 | else : 68 | x = tf.layers.conv2d_transpose(inputs=x, filters=channels, 69 | kernel_size=kernel, kernel_initializer=weight_init, kernel_regularizer=weight_regularizer, 70 | strides=stride, padding='SAME', use_bias=use_bias) 71 | 72 | return x 73 | 74 | 75 | ################################################################################## 76 | # Residual-block 77 | ################################################################################## 78 | 79 | def resblock(x_init, channels, use_bias=True, scope='resblock_0'): 80 | with tf.variable_scope(scope): 81 | with tf.variable_scope('res1'): 82 | x = conv(x_init, channels, kernel=3, stride=1, pad=1, pad_type='reflect', use_bias=use_bias) 83 | x = instance_norm(x) 84 | x = relu(x) 85 | 86 | with tf.variable_scope('res2'): 87 | x = conv(x, channels, kernel=3, stride=1, pad=1, pad_type='reflect', use_bias=use_bias) 88 | x = instance_norm(x) 89 | 90 | return x + x_init 91 | 92 | ################################################################################## 93 | # Sampling 94 | ################################################################################## 95 | 96 | def flatten(x) : 97 | return tf.layers.flatten(x) 98 | 99 | ################################################################################## 100 | # Activation function 101 | ################################################################################## 102 | 103 | def lrelu(x, alpha=0.2): 104 | return tf.nn.leaky_relu(x, alpha) 105 | 106 | 107 | def relu(x): 108 | return tf.nn.relu(x) 109 | 110 | 111 | def tanh(x): 112 | return tf.tanh(x) 113 | 114 | def sigmoid(x) : 115 | return tf.sigmoid(x) 116 | 117 | ################################################################################## 118 | # Normalization function 119 | ################################################################################## 120 | 121 | def instance_norm(x, scope='instance_norm'): 122 | return tf_contrib.layers.instance_norm(x, 123 | epsilon=1e-05, 124 | center=True, scale=True, 125 | scope=scope) 126 | 127 | def layer_norm(x, scope='layer_norm') : 128 | return tf_contrib.layers.layer_norm(x, 129 | center=True, scale=True, 130 | scope=scope) 131 | 132 | def batch_norm(x, is_training=True, scope='batch_norm'): 133 | return tf_contrib.layers.batch_norm(x, 134 | decay=0.9, epsilon=1e-05, 135 | center=True, scale=True, updates_collections=None, 136 | is_training=is_training, scope=scope) 137 | 138 | 139 | def spectral_norm(w, iteration=1): 140 | w_shape = w.shape.as_list() 141 | w = tf.reshape(w, [-1, w_shape[-1]]) 142 | 143 | u = tf.get_variable("u", [1, w_shape[-1]], initializer=tf.truncated_normal_initializer(), trainable=False) 144 | 145 | u_hat = u 146 | v_hat = None 147 | for i in range(iteration): 148 | """ 149 | power iteration 150 | Usually iteration = 1 will be enough 151 | """ 152 | v_ = tf.matmul(u_hat, tf.transpose(w)) 153 | v_hat = l2_norm(v_) 154 | 155 | u_ = tf.matmul(v_hat, w) 156 | u_hat = l2_norm(u_) 157 | 158 | sigma = tf.matmul(tf.matmul(v_hat, w), tf.transpose(u_hat)) 159 | w_norm = w / sigma 160 | 161 | with tf.control_dependencies([u.assign(u_hat)]): 162 | w_norm = tf.reshape(w_norm, w_shape) 163 | 164 | return w_norm 165 | 166 | def l2_norm(v, eps=1e-12): 167 | return v / (tf.reduce_sum(v ** 2) ** 0.5 + eps) 168 | 169 | ################################################################################## 170 | # Loss function 171 | ################################################################################## 172 | 173 | def L1_loss(x, y): 174 | loss = tf.reduce_mean(tf.abs(x - y)) 175 | return loss 176 | 177 | def L2_loss(x,y): 178 | size = tf.size(x) 179 | return tf.nn.l2_loss(x-y)* 2 / tf.to_float(size) 180 | 181 | def Huber_loss(x,y): 182 | return tf.losses.huber_loss(x,y) 183 | 184 | def discriminator_loss(loss_func, real, gray, fake, real_blur): 185 | real_loss = 0 186 | gray_loss = 0 187 | fake_loss = 0 188 | real_blur_loss = 0 189 | 190 | 191 | if loss_func == 'wgan-gp' or loss_func == 'wgan-lp': 192 | real_loss = -tf.reduce_mean(real) 193 | gray_loss = tf.reduce_mean(gray) 194 | fake_loss = tf.reduce_mean(fake) 195 | real_blur_loss = tf.reduce_mean(real_blur) 196 | 197 | if loss_func == 'lsgan' : 198 | real_loss = tf.reduce_mean(tf.square(real - 1.0)) 199 | gray_loss = tf.reduce_mean(tf.square(gray)) 200 | fake_loss = tf.reduce_mean(tf.square(fake)) 201 | real_blur_loss = tf.reduce_mean(tf.square(real_blur)) 202 | 203 | if loss_func == 'gan' or loss_func == 'dragan' : 204 | real_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.ones_like(real), logits=real)) 205 | gray_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.zeros_like(gray), logits=gray)) 206 | fake_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.zeros_like(fake), logits=fake)) 207 | real_blur_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.zeros_like(real_blur), logits=real_blur)) 208 | 209 | if loss_func == 'hinge': 210 | real_loss = tf.reduce_mean(relu(1.0 - real)) 211 | gray_loss = tf.reduce_mean(relu(1.0 + gray)) 212 | fake_loss = tf.reduce_mean(relu(1.0 + fake)) 213 | real_blur_loss = tf.reduce_mean(relu(1.0 + real_blur)) 214 | 215 | loss = real_loss + fake_loss + gray_loss + 0.1 * real_blur_loss 216 | 217 | return loss 218 | 219 | def generator_loss(loss_func, fake): 220 | fake_loss = 0 221 | 222 | if loss_func == 'wgan-gp' or loss_func == 'wgan-lp': 223 | fake_loss = -tf.reduce_mean(fake) 224 | 225 | if loss_func == 'lsgan' : 226 | fake_loss = tf.reduce_mean(tf.square(fake - 1.0)) 227 | 228 | if loss_func == 'gan' or loss_func == 'dragan': 229 | fake_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.ones_like(fake), logits=fake)) 230 | 231 | if loss_func == 'hinge': 232 | fake_loss = -tf.reduce_mean(fake) 233 | 234 | loss = fake_loss 235 | 236 | return loss 237 | 238 | def gram(x): 239 | shape_x = tf.shape(x) 240 | b = shape_x[0] 241 | c = shape_x[3] 242 | x = tf.reshape(x, [b, -1, c]) 243 | return tf.matmul(tf.transpose(x, [0, 2, 1]), x) / tf.cast((tf.size(x) // b), tf.float32) 244 | 245 | def con_loss(vgg, real, fake): 246 | 247 | vgg.build(real) 248 | real_feature_map = vgg.conv4_4_no_activation 249 | 250 | vgg.build(fake) 251 | fake_feature_map = vgg.conv4_4_no_activation 252 | 253 | loss = L1_loss(real_feature_map, fake_feature_map) 254 | 255 | return loss 256 | 257 | 258 | def style_loss(style, fake): 259 | return L1_loss(gram(style), gram(fake)) 260 | 261 | def con_sty_loss(vgg, real, anime, fake): 262 | 263 | vgg.build(real) 264 | real_feature_map = vgg.conv4_4_no_activation 265 | 266 | vgg.build(fake) 267 | fake_feature_map = vgg.conv4_4_no_activation 268 | 269 | vgg.build(anime[:fake_feature_map.shape[0]]) 270 | anime_feature_map = vgg.conv4_4_no_activation 271 | 272 | c_loss = L1_loss(real_feature_map, fake_feature_map) 273 | s_loss = style_loss(anime_feature_map, fake_feature_map) 274 | 275 | return c_loss,s_loss 276 | 277 | def color_loss(con, fake): 278 | con = rgb2yuv(con) 279 | fake = rgb2yuv(fake) 280 | 281 | return L1_loss(con[:,:,:,0], fake[:,:,:,0]) + Huber_loss(con[:,:,:,1],fake[:,:,:,1]) + Huber_loss(con[:,:,:,2],fake[:,:,:,2]) 282 | 283 | def rgb2yuv(rgb): 284 | """ 285 | Convert RGB image into YUV https://en.wikipedia.org/wiki/YUV 286 | """ 287 | rgb = (rgb + 1.0)/2.0 288 | # rgb2yuv_filter = tf.constant([[[[0.299, -0.169, 0.499], 289 | # [0.587, -0.331, -0.418], 290 | # [0.114, 0.499, -0.0813]]]]) 291 | # rgb2yuv_bias = tf.constant([0., 0.5, 0.5]) 292 | # temp = tf.nn.conv2d(rgb, rgb2yuv_filter, [1, 1, 1, 1], 'SAME') 293 | # temp = tf.nn.bias_add(temp, rgb2yuv_bias) 294 | # return temp 295 | return tf.image.rgb_to_yuv(rgb) 296 | 297 | -------------------------------------------------------------------------------- /tools/utils.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow.contrib import slim 3 | from tools.adjust_brightness import adjust_brightness_from_src_to_dst, read_img 4 | import os,cv2 5 | import numpy as np 6 | 7 | 8 | def load_test_data(image_path, size): 9 | img = cv2.imread(image_path).astype(np.float32) 10 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 11 | img = preprocessing(img,size) 12 | img = np.expand_dims(img, axis=0) 13 | return img 14 | 15 | def preprocessing(img, size): 16 | h, w = img.shape[:2] 17 | if h <= size[0]: 18 | h = size[0] 19 | else: 20 | x = h % 32 21 | h = h - x 22 | 23 | if w < size[1]: 24 | w = size[1] 25 | else: 26 | y = w % 32 27 | w = w - y 28 | # the cv2 resize func : dsize format is (W ,H) 29 | img = cv2.resize(img, (w, h)) 30 | return img/127.5 - 1.0 31 | 32 | 33 | def save_images(images, image_path, photo_path = None): 34 | fake = inverse_transform(images.squeeze()) 35 | if photo_path: 36 | return imsave(adjust_brightness_from_src_to_dst(fake, read_img(photo_path)), image_path) 37 | else: 38 | return imsave(fake, image_path) 39 | 40 | def inverse_transform(images): 41 | images = (images + 1.) / 2 * 255 42 | # The calculation of floating-point numbers is inaccurate, 43 | # and the range of pixel values must be limited to the boundary, 44 | # otherwise, image distortion or artifacts will appear during display. 45 | images = np.clip(images, 0, 255) 46 | return images.astype(np.uint8) 47 | 48 | 49 | def imsave(images, path): 50 | return cv2.imwrite(path, cv2.cvtColor(images, cv2.COLOR_BGR2RGB)) 51 | 52 | crop_image = lambda img, x0, y0, w, h: img[y0:y0+h, x0:x0+w] 53 | 54 | def random_crop(img1, img2, crop_H, crop_W): 55 | 56 | assert img1.shape == img2.shape 57 | h, w = img1.shape[:2] 58 | 59 | # The crop width cannot exceed the original image crop width 60 | if crop_W > w: 61 | crop_W = w 62 | 63 | # Crop height 64 | if crop_H > h: 65 | crop_H = h 66 | 67 | # Randomly generate the position of the upper left corner 68 | x0 = np.random.randint(0, w - crop_W + 1) 69 | y0 = np.random.randint(0, h - crop_H + 1) 70 | 71 | crop_1 = crop_image(img1, x0, y0, crop_W, crop_H) 72 | crop_2 = crop_image(img2, x0, y0, crop_W, crop_H) 73 | return crop_1,crop_2 74 | 75 | 76 | def show_all_variables(): 77 | model_vars = tf.trainable_variables() 78 | 79 | slim.model_analyzer.analyze_vars(model_vars, print_info=True) 80 | print('G:') 81 | slim.model_analyzer.analyze_vars([var for var in tf.trainable_variables() if var.name.startswith('generator')], print_info=True) 82 | # print('D:') 83 | # slim.model_analyzer.analyze_vars([var for var in tf.trainable_variables() if var.name.startswith('discriminator')], print_info=True) 84 | 85 | def check_folder(log_dir): 86 | if not os.path.exists(log_dir): 87 | os.makedirs(log_dir) 88 | return log_dir 89 | 90 | def str2bool(x): 91 | return x.lower() in ('true') 92 | 93 | 94 | -------------------------------------------------------------------------------- /tools/vgg19.py: -------------------------------------------------------------------------------- 1 | 2 | import tensorflow as tf 3 | 4 | import numpy as np 5 | import time 6 | import sys 7 | 8 | VGG_MEAN = [103.939, 116.779, 123.68] 9 | 10 | 11 | class Vgg19: 12 | def __init__(self, vgg19_npy_path='vgg19_weight/vgg19.npy'): 13 | 14 | if vgg19_npy_path is not None: 15 | self.data_dict = np.load(vgg19_npy_path, encoding='latin1', allow_pickle=True).item() 16 | print("npy file loaded ------- ",vgg19_npy_path) 17 | else: 18 | self.data_dict = None 19 | print("npy file load error!") 20 | sys.exit(1) 21 | 22 | def build(self, rgb, include_fc=False): 23 | """ 24 | load variable from npy to build the VGG 25 | input format: bgr image with shape [batch_size, h, w, 3] 26 | scale: (-1, 1) 27 | """ 28 | 29 | start_time = time.time() 30 | rgb_scaled = ((rgb + 1) / 2) * 255.0 # [-1, 1] ~ [0, 255] 31 | 32 | red, green, blue = tf.split(axis=3, num_or_size_splits=3, value=rgb_scaled) 33 | bgr = tf.concat(axis=3, values=[blue - VGG_MEAN[0], 34 | green - VGG_MEAN[1], 35 | red - VGG_MEAN[2]]) 36 | 37 | self.conv1_1 = self.conv_layer(bgr, "conv1_1") 38 | self.conv1_2 = self.conv_layer(self.conv1_1, "conv1_2") 39 | self.pool1 = self.max_pool(self.conv1_2, 'pool1') 40 | 41 | self.conv2_1 = self.conv_layer(self.pool1, "conv2_1") 42 | self.conv2_2 = self.conv_layer(self.conv2_1, "conv2_2") 43 | self.pool2 = self.max_pool(self.conv2_2, 'pool2') 44 | 45 | self.conv3_1 = self.conv_layer(self.pool2, "conv3_1") 46 | self.conv3_2 = self.conv_layer(self.conv3_1, "conv3_2") 47 | self.conv3_3 = self.conv_layer(self.conv3_2, "conv3_3") 48 | self.conv3_4 = self.conv_layer(self.conv3_3, "conv3_4") 49 | self.pool3 = self.max_pool(self.conv3_4, 'pool3') 50 | 51 | self.conv4_1 = self.conv_layer(self.pool3, "conv4_1") 52 | self.conv4_2 = self.conv_layer(self.conv4_1, "conv4_2") 53 | self.conv4_3 = self.conv_layer(self.conv4_2, "conv4_3") 54 | 55 | self.conv4_4_no_activation = self.no_activation_conv_layer(self.conv4_3, "conv4_4") 56 | 57 | self.conv4_4 = self.conv_layer(self.conv4_3, "conv4_4") 58 | self.pool4 = self.max_pool(self.conv4_4, 'pool4') 59 | 60 | self.conv5_1 = self.conv_layer(self.pool4, "conv5_1") 61 | self.conv5_2 = self.conv_layer(self.conv5_1, "conv5_2") 62 | self.conv5_3 = self.conv_layer(self.conv5_2, "conv5_3") 63 | self.conv5_4 = self.conv_layer(self.conv5_3, "conv5_4") 64 | self.pool5 = self.max_pool(self.conv5_4, 'pool5') 65 | 66 | if include_fc: 67 | self.fc6 = self.fc_layer(self.pool5, "fc6") 68 | assert self.fc6.get_shape().as_list()[1:] == [4096] 69 | self.relu6 = tf.nn.relu(self.fc6) 70 | 71 | self.fc7 = self.fc_layer(self.relu6, "fc7") 72 | self.relu7 = tf.nn.relu(self.fc7) 73 | 74 | self.fc8 = self.fc_layer(self.relu7, "fc8") 75 | 76 | self.prob = tf.nn.softmax(self.fc8, name="prob") 77 | 78 | self.data_dict = None 79 | print(("build model finished: %fs" % (time.time() - start_time))) 80 | 81 | def avg_pool(self, bottom, name): 82 | return tf.nn.avg_pool(bottom, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME', name=name) 83 | 84 | def max_pool(self, bottom, name): 85 | return tf.nn.max_pool(bottom, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME', name=name) 86 | 87 | def conv_layer(self, bottom, name): 88 | with tf.variable_scope(name): 89 | filt = self.get_conv_filter(name) 90 | 91 | conv = tf.nn.conv2d(bottom, filt, [1, 1, 1, 1], padding='SAME') 92 | 93 | conv_biases = self.get_bias(name) 94 | bias = tf.nn.bias_add(conv, conv_biases) 95 | 96 | relu = tf.nn.relu(bias) 97 | return relu 98 | 99 | def no_activation_conv_layer(self, bottom, name): 100 | with tf.variable_scope(name): 101 | filt = self.get_conv_filter(name) 102 | 103 | conv = tf.nn.conv2d(bottom, filt, [1, 1, 1, 1], padding='SAME') 104 | 105 | conv_biases = self.get_bias(name) 106 | x = tf.nn.bias_add(conv, conv_biases) 107 | 108 | return x 109 | 110 | def fc_layer(self, bottom, name): 111 | with tf.variable_scope(name): 112 | shape = bottom.get_shape().as_list() 113 | dim = 1 114 | for d in shape[1:]: 115 | dim *= d 116 | x = tf.reshape(bottom, [-1, dim]) 117 | 118 | weights = self.get_fc_weight(name) 119 | biases = self.get_bias(name) 120 | 121 | # Fully connected layer. Note that the '+' operation automatically 122 | # broadcasts the biases. 123 | fc = tf.nn.bias_add(tf.matmul(x, weights), biases) 124 | 125 | return fc 126 | 127 | def get_conv_filter(self, name): 128 | return tf.constant(self.data_dict[name][0], name="filter") 129 | 130 | def get_bias(self, name): 131 | return tf.constant(self.data_dict[name][1], name="biases") 132 | 133 | def get_fc_weight(self, name): 134 | return tf.constant(self.data_dict[name][0], name="weights") -------------------------------------------------------------------------------- /train.py: -------------------------------------------------------------------------------- 1 | from AnimeGAN import AnimeGAN 2 | import argparse 3 | from tools.utils import * 4 | import os 5 | os.environ["CUDA_VISIBLE_DEVICES"] = "1" 6 | 7 | """parsing and configuration""" 8 | 9 | def parse_args(): 10 | desc = "Tensorflow implementation of AnimeGAN" 11 | parser = argparse.ArgumentParser(description=desc) 12 | parser.add_argument('--dataset', type=str, default='Hayao', help='dataset_name') 13 | 14 | parser.add_argument('--epoch', type=int, default=101, help='The number of epochs to run') 15 | parser.add_argument('--init_epoch', type=int, default=5, help='The number of epochs for weight initialization') 16 | parser.add_argument('--batch_size', type=int, default=6, help='The size of batch size') 17 | parser.add_argument('--save_freq', type=int, default=1, help='The number of ckpt_save_freq') 18 | 19 | parser.add_argument('--init_lr', type=float, default=1e-4, help='The learning rate') 20 | parser.add_argument('--g_lr', type=float, default=8e-5, help='The learning rate') 21 | parser.add_argument('--d_lr', type=float, default=16e-5, help='The learning rate') 22 | parser.add_argument('--ld', type=float, default=10.0, help='The gradient penalty lambda') 23 | 24 | parser.add_argument('--g_adv_weight', type=float, default=300.0, help='Weight about GAN') 25 | parser.add_argument('--d_adv_weight', type=float, default=300.0, help='Weight about GAN') 26 | parser.add_argument('--con_weight', type=float, default=1.5, help='Weight about VGG19') # 1.1 for Shinkai 27 | # ------ the follow weight used in AnimeGAN 28 | parser.add_argument('--sty_weight', type=float, default=3.0, help='Weight about style') 29 | parser.add_argument('--color_weight', type=float, default=10.0, help='Weight about color') 30 | # --------------------------------------------- 31 | parser.add_argument('--training_rate', type=int, default=1, help='training rate about G & D') 32 | parser.add_argument('--gan_type', type=str, default='lsgan', help='[gan / lsgan / wgan-gp / wgan-lp / dragan / hinge') 33 | 34 | parser.add_argument('--img_size', type=list, default=[256,256], help='The size of image: H and W') 35 | parser.add_argument('--img_ch', type=int, default=3, help='The size of image channel') 36 | 37 | parser.add_argument('--ch', type=int, default=64, help='base channel number per layer') 38 | parser.add_argument('--n_dis', type=int, default=3, help='The number of discriminator layer') 39 | parser.add_argument('--sn', type=str2bool, default=True, help='using spectral norm') 40 | 41 | parser.add_argument('--checkpoint_dir', type=str, default='checkpoint', 42 | help='Directory name to save the checkpoints') 43 | parser.add_argument('--log_dir', type=str, default='logs', 44 | help='Directory name to save training logs') 45 | parser.add_argument('--sample_dir', type=str, default='samples', 46 | help='Directory name to save the samples on training') 47 | 48 | return check_args(parser.parse_args()) 49 | 50 | """checking arguments""" 51 | def check_args(args): 52 | # --checkpoint_dir 53 | check_folder(args.checkpoint_dir) 54 | 55 | # --log_dir 56 | check_folder(args.log_dir) 57 | 58 | # --sample_dir 59 | check_folder(args.sample_dir) 60 | 61 | # --epoch 62 | try: 63 | assert args.epoch >= 1 64 | except: 65 | print('number of epochs must be larger than or equal to one') 66 | 67 | # --batch_size 68 | try: 69 | assert args.batch_size >= 1 70 | except: 71 | print('batch size must be larger than or equal to one') 72 | return args 73 | 74 | 75 | """main""" 76 | def main(): 77 | # parse arguments 78 | args = parse_args() 79 | if args is None: 80 | exit() 81 | 82 | # open session 83 | gpu_options = tf.GPUOptions(allow_growth=True) 84 | with tf.Session(config=tf.ConfigProto(allow_soft_placement=True,inter_op_parallelism_threads=8, 85 | intra_op_parallelism_threads=8,gpu_options=gpu_options)) as sess: 86 | gan = AnimeGAN(sess, args) 87 | 88 | # build graph 89 | gan.build_model() 90 | 91 | # show network architecture 92 | show_all_variables() 93 | 94 | gan.train() 95 | print(" [*] Training finished!") 96 | 97 | 98 | 99 | if __name__ == '__main__': 100 | main() 101 | -------------------------------------------------------------------------------- /vgg19_weight/vgg19.npy file: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /video/input/お花見.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/video/input/お花見.mp4 -------------------------------------------------------------------------------- /video/output/お花見.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TachibanaYoshino/AnimeGAN/b7c16f7c58e6c609f4064b1228782419a7e7a45c/video/output/お花見.mp4 -------------------------------------------------------------------------------- /video2anime.py: -------------------------------------------------------------------------------- 1 | ''' 2 | made by @finnkso (github) 3 | 2020.04.09 4 | ''' 5 | import argparse 6 | import os 7 | import cv2 8 | from tqdm import tqdm 9 | import numpy as np 10 | import tensorflow as tf 11 | 12 | from net import generator 13 | from tools.utils import preprocessing, check_folder 14 | from tools.adjust_brightness import adjust_brightness_from_src_to_dst 15 | 16 | os.environ["CUDA_VISIBLE_DEVICES"] = "0" 17 | 18 | def parse_args(): 19 | desc = "Tensorflow implementation of AnimeGAN" 20 | parser = argparse.ArgumentParser(description=desc) 21 | parser.add_argument('--video', type=str, default='video/input/'+ 'お花見.mp4', 22 | help='video file or number for webcam') 23 | parser.add_argument('--checkpoint_dir', type=str, default='../checkpoint/generator_Hayao_weight', 24 | help='Directory name to save the checkpoints') 25 | parser.add_argument('--output', type=str, default='video/output', 26 | help='output path') 27 | parser.add_argument('--output_format', type=str, default='MP4V', 28 | help='codec used in VideoWriter when saving video to file') 29 | parser.add_argument('--if_adjust_brightness', type=bool, default=False, 30 | help='adjust brightness by the real photo') 31 | return parser.parse_args() 32 | 33 | 34 | def convert_image(img, img_size): 35 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 36 | img = preprocessing(img, img_size) 37 | img = np.expand_dims(img, axis=0) 38 | img = np.asarray(img) 39 | return img 40 | 41 | def inverse_image(img): 42 | img = (img.squeeze()+1.) / 2 * 255 43 | img = img.astype(np.uint8) 44 | return img 45 | 46 | def cvt2anime_video(video, output, checkpoint_dir, output_format='MP4V', if_adjust_brightness=False, img_size=(256,256)): 47 | ''' 48 | output_format: 4-letter code that specify codec to use for specific video type. e.g. for mp4 support use "H264", "MP4V", or "X264" 49 | ''' 50 | # tf.reset_default_graph() 51 | # check_folder(result_dir) 52 | gpu_stat = bool(len(tf.config.experimental.list_physical_devices('GPU'))) 53 | if gpu_stat: 54 | os.environ["CUDA_VISIBLE_DEVICES"] = "0" 55 | gpu_options = tf.GPUOptions(allow_growth=gpu_stat) 56 | 57 | test_real = tf.placeholder(tf.float32, [1, None, None, 3], name='test') 58 | 59 | with tf.variable_scope("generator", reuse=False): 60 | test_generated = generator.G_net(test_real).fake 61 | 62 | # load video 63 | vid = cv2.VideoCapture(video) 64 | vid_name = os.path.basename(video) 65 | total = int(vid.get(cv2.CAP_PROP_FRAME_COUNT)) 66 | fps = vid.get(cv2.CAP_PROP_FPS) 67 | # codec = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G') 68 | codec = cv2.VideoWriter_fourcc(*output_format) 69 | 70 | tfconfig = tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options) 71 | with tf.Session(config=tfconfig) as sess: 72 | # tf.global_variables_initializer().run() 73 | # load model 74 | ckpt = tf.train.get_checkpoint_state(checkpoint_dir) # checkpoint file information 75 | saver = tf.train.Saver() 76 | if ckpt and ckpt.model_checkpoint_path: 77 | ckpt_name = os.path.basename(ckpt.model_checkpoint_path) # first line 78 | saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name)) 79 | print(" [*] Success to read {}".format(ckpt_name)) 80 | else: 81 | print(" [*] Failed to find a checkpoint") 82 | return 83 | 84 | # determine output width and height 85 | ret, img = vid.read() 86 | if img is None: 87 | print('Error! Failed to determine frame size: frame empty.') 88 | return 89 | img = preprocessing(img, img_size) 90 | height, width = img.shape[:2] 91 | out = cv2.VideoWriter(os.path.join(output, vid_name), codec, fps, (width, height)) 92 | 93 | pbar = tqdm(total=total) 94 | vid.set(cv2.CAP_PROP_POS_FRAMES, 0) 95 | while ret: 96 | ret, frame = vid.read() 97 | if frame is None: 98 | print('Warning: got empty frame.') 99 | continue 100 | 101 | img = convert_image(frame, img_size) 102 | fake_img = sess.run(test_generated, feed_dict={test_real: img}) 103 | fake_img = inverse_image(fake_img) 104 | if if_adjust_brightness: 105 | fake_img = cv2.cvtColor(adjust_brightness_from_src_to_dst(fake_img, frame), cv2.COLOR_BGR2RGB) 106 | else: 107 | fake_img = cv2.cvtColor(fake_img, cv2.COLOR_BGR2RGB) 108 | fake_img = cv2.resize(fake_img, (width, height)) 109 | out.write(fake_img) 110 | pbar.update(1) 111 | 112 | pbar.close() 113 | vid.release() 114 | # cv2.destroyAllWindows() 115 | return os.path.join(output, vid_name) 116 | 117 | 118 | if __name__ == '__main__': 119 | arg = parse_args() 120 | check_folder(arg.output) 121 | info = cvt2anime_video(arg.video, arg.output, arg.checkpoint_dir, output_format=arg.output_format, if_adjust_brightness=arg.if_adjust_brightness) 122 | print(f'output video: {info}') 123 | --------------------------------------------------------------------------------