AnimeGAN icon indicating copy to clipboard operation
AnimeGAN copied to clipboard

Train Error

Open David9591 opened this issue 3 years ago • 6 comments

Hi I download and open project with pycharm. I configured the environment as README required(1080Ti), running edge-smooth.py and data_mean.py has no problem, however , when I ran main.py, something wrong: [*] Reading checkpoints... [*] Failed to find a checkpoint [!] Load failed... 2021-04-12 13:15:23.718658: W tensorflow/core/framework/op_kernel.cc:1306] Invalid argument: UFuncTypeError: Cannot cast ufunc 'add' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind' Traceback (most recent call last): File "****/anaconda3/envs/anime/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 157, in __call__ ret = func(*args) File "*****/AnimeGAN-master/tools/data_loader.py", line 70, in load_image image1, image2 = self.read_image(img1) File "*****/AnimeGAN-master/tools/data_loader.py", line 45, in read_image image1[:,:,0] += self.data_mean[2] numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'add' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind' Could you please help solve this problem or give some advice? Best wishes!

David9591 avatar Apr 12 '21 05:04 David9591

*****/AnimeGAN-master/tools/data_loader.py", line 45, in read_image image1[:,:,0] += self.data_mean[2]。 There is an error in this line, self.data_mean[2] should be a string, you cannot add a numpy array to a string.

TachibanaYoshino avatar Apr 12 '21 07:04 TachibanaYoshino

*****/AnimeGAN-master/tools/data_loader.py", line 45, in read_image image1[:,:,0] += self.data_mean[2]。 There is an error in this line, self.data_mean[2] should be a string, you cannot add a numpy array to a string.

Dear author, thank you for your timely answer。However, I'm not quite sure what you mean. Are you saying that we should convert self.data_mean[2] from str to numpy array when calculating it?Could you give a detailed example?Thank you very much!

David9591 avatar Apr 12 '21 08:04 David9591

Hi I download and open project with pycharm. I configured the environment as README required(1080Ti), running edge-smooth.py and data_mean.py has no problem, however , when I ran main.py, something wrong: [*] Reading checkpoints... [*] Failed to find a checkpoint [!] Load failed... 2021-04-12 13:15:23.718658: W tensorflow/core/framework/op_kernel.cc:1306] Invalid argument: UFuncTypeError: Cannot cast ufunc 'add' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind' Traceback (most recent call last): File "****/anaconda3/envs/anime/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 157, in __call__ ret = func(*args) File "*****/AnimeGAN-master/tools/data_loader.py", line 70, in load_image image1, image2 = self.read_image(img1) File "*****/AnimeGAN-master/tools/data_loader.py", line 45, in read_image image1[:,:,0] += self.data_mean[2] numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'add' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind' Could you please help solve this problem or give some advice? Best wishes!

Have you solved this problem? I have the same error.

6132sara avatar Apr 13 '21 01:04 6132sara

Same error here- I just hard coded the data mean values for my dataset into data_loader and it ran fine.

image1[:,:,0] += 13.136 #self.data_mean[2] image1[:,:,1] += -8.6698 #self.data_mean[1] image1[:,:,2] += -4.4661 #self.data_mean[0]

gmoneyphx avatar Apr 20 '21 21:04 gmoneyphx

The following worked for me.

Change the argparser for data_mean in main.py to something like this:

parser.add_argument('--data_mean', nargs="*", type=float, default=[13.1360, -8.6698, -4.4661], help='data_mean(bgr) from data_mean.py')

And then you can run training like this:

python main.py --phase train --dataset Hayao --data_mean 13.1360 -8.6698 -4.4661 --epoch 101 --init_epoch 10

luclement avatar Nov 18 '21 19:11 luclement

The following worked for me.

Change the argparser for data_mean in main.py to something like this:

parser.add_argument('--data_mean', nargs="*", type=float, default=[13.1360, -8.6698, -4.4661], help='data_mean(bgr) from data_mean.py')

And then you can run training like this:

python main.py --phase train --dataset Hayao --data_mean 13.1360 -8.6698 -4.4661 --epoch 101 --init_epoch 10

Yes, you are right. data_mean is used as an additional data preprocessing, it is not necessary. It was not mentioned in the original paper, because it was added later. Since its role is not obvious, I will delete this preprocessing later.

TachibanaYoshino avatar Nov 19 '21 08:11 TachibanaYoshino