Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train Error #48

Open
David9591 opened this issue Apr 12, 2021 · 6 comments
Open

Train Error #48

David9591 opened this issue Apr 12, 2021 · 6 comments

Comments

@David9591
Copy link

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!

@TachibanaYoshino
Copy link
Owner

*****/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.

@David9591
Copy link
Author

*****/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!

@6132sara
Copy link

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.

@gmoneyphx
Copy link

gmoneyphx commented Apr 20, 2021

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]

@luclement
Copy link

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

@TachibanaYoshino
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants