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

The error "divsion by zero" #7

Closed
sunnydai opened this issue Jun 11, 2018 · 19 comments
Closed

The error "divsion by zero" #7

sunnydai opened this issue Jun 11, 2018 · 19 comments

Comments

@sunnydai
Copy link

Excuse me! I'm new to the chainer framework and python. When i train with the command "python train.py", it always occur the error ''divsion by zero', i am confused! Hope your responce

@SeitaroShinagawa
Copy link
Owner

Hi @sunnydai,
Thanks for your report. Could you show me the actual error you have observed?

@sunnydai
Copy link
Author

Thank you for your responce, the error is as follow!
qq 20180611145835

@SeitaroShinagawa
Copy link
Owner

Oh, I see. The error occurs in division by "len(self.dataset)"
It means "len(self.dataset)==0." Namely, data loading has failed.

Firstly, could you check your dataset path in "common/paths.py"?
https://github.com/SeitaroShinagawa/chainer-partial_convolution_image_inpainting#set-dataset-path

#common/paths.py
train_place2 = "/yourpath/place2/data_256/"
val_place2 = "/yourpath/place2/val_256/"
test_place2 = "/yourpath/test_256/"

Note that the paths should be replaced by actual your dataset paths.

@sunnydai
Copy link
Author

I have set my own datasets path. But my datasets is not as large as the original one, I just select some of the pictures and i use 'python train.py' instead of 'python train.py -g 0'. I don't know if these two changes make the error?

qq 20180611153334

@SeitaroShinagawa
Copy link
Owner

Option -g means the gpu id you want to use as below,
https://github.com/SeitaroShinagawa/chainer-partial_convolution_image_inpainting/blob/master/train.py#L22
There is no relationship between -g and loading dataset.

Is your mask dataset which is generated by generate_windows.py also correct?
Default train.py uses image size of 256 as below,
https://github.com/SeitaroShinagawa/chainer-partial_convolution_image_inpainting/blob/master/train.py#L92

#actual command to generate mask dataset
python generate_windows.py 256 1000

@sunnydai
Copy link
Author

Yes, I have generate the mask.
qq 20180611160845

@sunnydai
Copy link
Author

It maybe the failure of the loading of VGG model because the 'completing model loaded' is missed. And i find that the VGG model has been download, I don't konw why the error occur?

@SeitaroShinagawa
Copy link
Owner

Actually, 'Completion model' represents the trained model with this completion (in-painting) network, not the VGG model. It has been successful because you got 'ok' in the line of 64.

@sunnydai
Copy link
Author

Oh~In ‘train.py’ line 92, mask_path=''mask/256", if it should be mask_path=''mask/256/"?

@SeitaroShinagawa
Copy link
Owner

Let me confirm your path is correct again. Could you run the following commands?

#to check train data path
>>> import glob
>>> from common import paths
>>> train_keys = glob.glob(paths.train_place2+"*/*/*.jpg")
>>> print(len(train_keys))
# if successful, you will get "1434892" as return
#to check mask path
>>> import glob
>>> from common import paths
>>> mask_keys = glob.glob("mask/256/*.bmp")
>>> print(len(mask_keys))
# if successful, you will get "1000" as return

@SeitaroShinagawa
Copy link
Owner

mask_path=''mask/256" is correct. See here,
https://github.com/SeitaroShinagawa/chainer-partial_convolution_image_inpainting/blob/master/datasets/place2.py#L20
(Sorry for confusing you, the comment in this line is my mistake.)

@sunnydai
Copy link
Author

Thanks for your patience! I have find the question. I make a mistake in "place2.py"~

@sunnydai
Copy link
Author

Another error occur when i am training, when the evaluation process is needed, there is an error 'numpy.ndarray' object has no attribute 'get'
qq 20180612214937

@SeitaroShinagawa
Copy link
Owner

Sorry for the inconvenience. It seems that you executed the code with CPU mode, right?
"get" changes a cuda.array to numpy.array.
You can solve it by removing .get() in this case.

@sunnydai
Copy link
Author

Thank you very much! It is ok now!

@sunnydai
Copy link
Author

I am sorry to trouble you again. After training the model, when i execute the "generate_result.py", I can not load the model that i have trained. The model are saved in "result".
qq 20180618145046
qq 20180618145055

@SeitaroShinagawa
Copy link
Owner

generate_result.py requires model path option, "--load_model" as below,
https://github.com/SeitaroShinagawa/chainer-partial_convolution_image_inpainting/blob/master/generate_result.py#L26

#example
python gnerate_result.py -g 0 --load_model your/model/path

@sunnydai
Copy link
Author

Thank you very much~

@greysou1
Copy link

greysou1 commented Aug 21, 2019

@sunnydai thank you for this thread. I followed the suggestions in this thread but still ran into the same issue. I changed my path and double-checked. I used a small dataset the "Small images (256 * 256) with easy directory structure" 21G one. It only has the train and val data set so I copied the val data and named it train_256.
Can you please help me with the dataset structure?
Screenshot 2019-08-21 at 11 15 09 PM
Screenshot 2019-08-21 at 11 25 47 PM
Screenshot 2019-08-21 at 11 26 19 PM

UPDATE: I changed my dataset paths to a different location and now running this

#to check train data path

import glob
from common import paths
train_keys = glob.glob(paths.train_place2+"//*.jpg")
print(len(train_keys))
#if successful, you will get "1434892" as return

returns 1803460, I assume thats because of the different dataset but that's better than 0 which I used to get before. But the ZeroDivisionError: division by zero error persists. Can you please help?

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

3 participants