DeepCrack icon indicating copy to clipboard operation
DeepCrack copied to clipboard

ZeroDivisionError: division by zero

Open ycc66104116 opened this issue 3 years ago • 7 comments

hi, i recently tried to run DeepCrack to identify my target, but i faced some problem. The error message is shown below. i think it seems like it didn't read my mask data, however, i have manage my train.txt and val.txt as the README.md file. i really can't find which part was wrong. Does anyone know how to fix this problem?

-------------------------my error message----------------------------------- Setting up a new session... Without the incoming socket you cannot receive events from the server or register event handlers to your Visdom client. Epoch 1 --- Training --- :: 0% 0/520 [00:00<?, ?it/s]/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode) Epoch 1 --- Evaluation --- :: 0% 0/520 [01:06<?, ?it/s] Traceback (most recent call last): File "train.py", line 199, in main() File "train.py", line 127, in main trainer.acc_op(val_pred[0], val_target) File "/content/drive/MyDrive/Colab_Notebooks/DeepCrack/0411/DeepCrack_master/codes/trainer.py", line 102, in acc_op mask > 0].numel() ZeroDivisionError: division by zero

ycc66104116 avatar Apr 19 '22 01:04 ycc66104116

There are all background graphs in your verification set, so that the number of pixels greater than 1 is equal to 0.

plastictime avatar Apr 21 '22 12:04 plastictime

Thank you so much for your reply. i do have all background graphs in my train and val data! i will try to remove those images out of my val dataset and run again ASAP. if it works or there is any other news i will post down here. I really appreciate your help!!!

ycc66104116 avatar Apr 21 '22 13:04 ycc66104116

hi @plastictime , thank you for the help fixing the problem of zerodivisionerror. so far, i haven't make DeepCrack train successfully by my own dataset, because the error about checkpoint path No such file or directory. i post this as issue #22 . because it seems like you have ran the code successfully, i want to ask if you know how to fix this problem? if i can, i also want to discuss the problem you encountered. if you have time and reply, i will appreciate this a lot. thank in advance.

ycc66104116 avatar Apr 28 '22 06:04 ycc66104116

If you run the train on windows, you can check the file name you saved. Maybe there is '' or '/' in it. This will lead to the error.  

------------------ 原始邮件 ------------------ 发件人: "qinnzou/DeepCrack" @.>; 发送时间: 2022年4月28日(星期四) 下午2:30 @.>; @.@.>; 主题: Re: [qinnzou/DeepCrack] ZeroDivisionError: division by zero (Issue #20)

hi @plastictime , thank you for the help fixing the problem of zerodivisionerror. so far, i haven't make DeepCrack train successfully by my own dataset, because the error about checkpoint path No such file or directory. i post this as issue #22 . because it seems like you have ran the code successfully, i want to ask if you know how to fix this problem? if i can, i also want to discuss the problem you encountered. if you have time and reply, i will appreciate this a lot. thank in advance.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

plastictime avatar Apr 28 '22 06:04 plastictime

@plastictime thank you for you reply. i run the code on colab, so i just copy and paste the path. and "/" is right i think. in config.py, i modified the relevent path as below:

checkpoint_path = '/content/drive/MyDrive/Colab_Notebooks/DeepCrack/0411/DeepCrack_master/codes/' log_path = 'log' pretrained_model = '' save_format = ''

is this midification fit the request? or any thing you would suggest?

ycc66104116 avatar Apr 29 '22 02:04 ycc66104116

In your error:FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Colab_Notebooks/DeepCrack/0411/DeepCrack_master/codes/0428/checkpoints/0428_0428_epoch(1)_acc(0.00000/0.98645)_0000001_2022-04-28-02-27-52.pth',  is there any problem in this path before '0428_0428_epoch(1)_acc(0.00000/0.98645)_0000001_2022-04-28-02-27-52.pth'? If there's no problem here, i think the problem is still the file name. Maybe you can try to create a file named  '0428_0428_epoch(1)_acc(0.00000/0.98645)_0000001_2022-04-28-02-27-52.pth' so that you can check whether the name is legal. In my config.py,the relevent path is:

checkpoint_path = 'checkpoints' log_path = 'log' save_format = ''

------------------ 原始邮件 ------------------ 发件人: "qinnzou/DeepCrack" @.>; 发送时间: 2022年4月29日(星期五) 上午10:05 @.>; @.@.>; 主题: Re: [qinnzou/DeepCrack] ZeroDivisionError: division by zero (Issue #20)

@plastictime thank you for you reply. i run the code on colab, so i just copy and paste the path. and "/" is right i think. in config.py, i modified the relevent path as below:

checkpoint_path = '/content/drive/MyDrive/Colab_Notebooks/DeepCrack/0411/DeepCrack_master/codes/' log_path = 'log' pretrained_model = '' save_format = ''

is this midification fit the request? or any thing you would suggest?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

plastictime avatar Apr 29 '22 02:04 plastictime

@plastictime thank you for reply, i have found how to fix it. the error is caused by the name but not path of the file. i revised the symbol in saved file name, from "/" to "_". then the problem solved! thank you for the suggestion! now i'm keep trying understanding the visualization method it use and the accuracy calculation, just like the issue you mentioned #21 . if i have any new finding i will discuss with you ASAP! again, thank you so much for your help!!!

ycc66104116 avatar May 02 '22 07:05 ycc66104116

Thanks for your reply.

qinnzou avatar Dec 06 '22 09:12 qinnzou