sairajk / PyTorch-Pyramid-Feature-Attention-Network-for-Saliency-Detection

PyTorch implementation of the CVPR 2019 paper “Pyramid Feature Attention Network for Saliency Detection”
GNU General Public License v3.0
175 stars 47 forks source link

TypeError: unsupported operand type(s) for %: 'int' and 'NoneType' #23

Open cculin18 opened 2 years ago

cculin18 commented 2 years ago

Hi, I got the problem, I can begin trainging the code. But while run epoch=2, it show this problem and stop to train.

File "train.py", line 212, in trainer.train() File "train.py", line 122, in train if epoch % self.test_interval == 0 or epoch % self.save_interval == 0: TypeError: unsupported operand type(s) for %: 'int' and 'NoneType'

JingdiZhou commented 1 year ago

yes ,I have met that problem too .So do someone have fixed it?

JingdiZhou commented 1 year ago

Hi bro ,so have you fixed this problem ?

H-Blues commented 1 year ago

@cculin18 @JingdiZhou

Hi guys, I'm not sure whether you have solved this issue, but I encountered the same problem. Upon checking, I found that the default value of the save_interval parameter was set to None, and you can see this in the parse_arguments() method, specifically line 29 in the train.py file.

At the same time, I noticed that @ParthPatel-ES fixed this issue in the Pull Request#14. He changed save_interval from None to 2 and used math.fmod() instead of % in line 122. I saw an explanation of differences for these two methods in a Q&A on Kaggle: https://www.kaggle.com/questions-and-answers/102766. He also modified some paths for better execution on Google Colab, great job!

Additionally, I believe that adding a condition check before the code in line 122 or using a try-catch block to catch exceptions are both viable solutions.

Best regards.

JingdiZhou commented 1 year ago

@cculin18 @JingdiZhou

Hi guys, I'm not sure whether you have solved this issue, but I encountered the same problem. Upon checking, I found that the default value of the save_interval parameter was set to None, and you can see this in the parse_arguments() method, specifically line 29 in the train.py file.

At the same time, I noticed that @ParthPatel-ES fixed this issue in the Pull Request#14. He changed save_interval from None to 2 and used math.fmod() instead of % in line 122. I saw an explanation of differences for these two methods in a Q&A on Kaggle: https://www.kaggle.com/questions-and-answers/102766. He also modified some paths for better execution on Google Colab, great job!

Additionally, I believe that adding a condition check before the code in line 122 or using a try-catch block to catch exceptions are both viable solutions.

Best regards.

I'm very appreciate your answer to me, which help me a lot in understanding the code