thtang / CheXNet-with-localization

Weakly Supervised Learning for Findings Detection in Medical Images
https://www.csie.ntu.edu.tw/~yvchen/f106-adl/doc/HTCMedical.pdf
GNU General Public License v3.0
314 stars 108 forks source link

Error in During testing the model need the number of output to perform testing? #18

Closed Aliktk closed 3 years ago

Aliktk commented 3 years ago

I am running test file to validate the results. The data loaded and preprocess sucessfully and when I load model with out_size as given in code to 8 its says the below erorr? What is the solution? Did the code need to update? or model in the Pytorch are missing something.

File "C:\ProgramData\Anaconda3\envs\chest-loc\lib\site-packages\torchvision\models\densenet.py", line 98, in init layer = _DenseLayer(num_input_features + i * growth_rate, growth_rate, bn_size, drop_rate) File "C:\ProgramData\Anaconda3\envs\chest-loc\lib\site-packages\torchvision\models\densenet.py", line 77, in init self.add_module('norm.1', nn.BatchNorm2d(num_input_features)), File "C:\ProgramData\Anaconda3\envs\chest-loc\lib\site-packages\torch\nn\modules\module.py", line 178, in add_module raise KeyError("module name can't contain \".\"") KeyError: 'module name can\'t contain "."' Help me in this regard. Thanks @thtang

Aliktk commented 3 years ago

by changing the

# model.load_state_dict(torch.load("model/DenseNet121_aug4_pretrain_WeightBelow1_1_0.829766922537.pkl"))
state_dict =torch.load("model/DenseNet121_aug4_pretrain_WeightBelow1_1_0.829766922537.pkl") 

as mentioned in #8