TachibanaYoshino / AnimeGANv2

[Open Source]. The improved version of AnimeGAN. Landscape photos/videos to anime
5.06k stars 709 forks source link

Error when running train step #36

Open ngockimhoang opened 2 years ago

ngockimhoang commented 2 years ago

Hi, I want to ask if the master branch can run the train step? python main.py --phase train --dataset Hayao --data_mean [13.1360,-8.6698,-4.4661] --epoch 101 --init_epoch 10 I got a lot of errors running above command. Example: Traceback (most recent call last): File "main.py", line 114, in main() File "main.py", line 106, in main gan.train() File "/home/kimhoang/emvn/AnimeGANv2/AnimeGANv2.py", line 233, in train anime, anime_smooth, real = self.sess.run([anime_img_op, anime_smooth_op, real_img_op]) File "/home/kimhoang/.pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 956, in run run_metadata_ptr) File "/home/kimhoang/.pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1180, in _run feed_dict_tensor, options, run_metadata) File "/home/kimhoang/.pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1359, in _do_run run_metadata) File "/home/kimhoang/.pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1384, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __inference_Datasetmap_16913}} UFuncTypeError: Cannot cast ufunc 'add' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind'

TachibanaYoshino commented 2 years ago

You can refer to the issue. https://github.com/TachibanaYoshino/AnimeGAN/issues/48#issuecomment-973202247

ngockimhoang commented 2 years ago

@TachibanaYoshino the solution in that comment fixes the issue. I got below traces in output [] Reading checkpoints... [] Failed to find a checkpoint [!] Load failed... And the next step "Extract the weights of the generator" will fail with error [*] Failed to find a checkpoint, because this folder ../checkpoint/AnimeGAN_Hayao_lsgan_300_300_1_2_10_1 is missing So I suppose this checkpoint folder is generated by the train step. Am I still missing something in the train step?

TachibanaYoshino commented 2 years ago

Yes, when you run train.py to perform training, all the parameters of the network will be saved in the folder AnimeGAN_Hayao_lsgan_300_300_1_2_10_1. After the training is completed, execute get_generator_ckpt.py to obtain the weight of the generator network of your specified epoch. After getting the weight of the generator, you can use test.py to realize the function of converting pictures to animation or use video2anime.py to realize the function of converting videos to animation. Of course, I have trained the weights of the three animation style generators. You can directly perform the function of converting pictures or videos to animation without training the network yourself.