CheXNet-with-localization
CheXNet-with-localization copied to clipboard
Invalid layer name: module.densenet121.features.denseblock4.denselayer16.conv.2
Hi,
I got the below error while running denseNet_localization.py file.
Traceback (most recent call last):
File "/media/administrator/D/XRay/CheXnet_Demo/denseNet_localization.py", line 227, in <module>
output = gcam.generate(target_layer="module.densenet121.features.denseblock4.denselayer16.conv.2")
File "/media/administrator/D/XRay/CheXnet_Demo/denseNet_localization.py", line 186, in generate
fmaps = self._find(self.all_fmaps, target_layer)
File "/media/administrator/D/XRay/CheXnet_Demo/denseNet_localization.py", line 174, in _find
raise ValueError('Invalid layer name: {}'.format(target_layer))
ValueError: Invalid layer name: module.densenet121.features.denseblock4.denselayer16.conv.2
any help would be really appriciated.. Thanks in advance..
Do you use Pytorch==0.2.0 and torchvision==0.2.0 ?
I am using the below version since I had some problem with torchvision 0.2.0.
torch==1.1.0 torchvision==0.2.2
Additional info: I ran my training by using the below requirements in Ubuntu 16.04.
python== 3.5.6
pip 19.1.1
pkg-resources 0.0.0
setuptools 41.0.1
wheel 0.33.4
cycler==0.10.0 decorator==4.4.0 imageio==2.5.0 joblib==0.13.2 matplotlib==2.1.1 networkx==2.3 numpy==1.13.3 opencv-python==3.4.0.12 pandas==0.24.2 Pillow==6.0.0 pyparsing==2.4.0 python-dateutil==2.8.0 pytz==2019.1 PyWavelets==1.0.3 scikit-image==0.13.1 scikit-learn==0.21.1 scipy==1.0.0 six==1.12.0 torch==1.1.0 torchvision==0.2.2
If I use torchvision 0.2.0 and torch==1.0.1 I get the following error.
warn("The default mode, 'constant', will be changed to 'reflect' in "
0
Traceback (most recent call last):
File "denseNet_localization.py", line 76, in <module>
model = DenseNet121(8).cuda()
File "denseNet_localization.py", line 65, in __init__
self.densenet121 = torchvision.models.densenet121(pretrained=True)
File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 26, in densenet121
**kwargs)
File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 142, in __init__
bn_size=bn_size, growth_rate=growth_rate, drop_rate=drop_rate)
File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/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 "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 77, in __init__
self.add_module('norm.1', nn.BatchNorm2d(num_input_features)),
File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torch/nn/modules/module.py", line 180, in add_module
raise KeyError("module name can't contain \".\"")
KeyError: 'module name can\'t contain "."'
So I have upgraded torchvision to 0.2.2. and torch==1.1.0. and my train went successful. When I try to run denseNet_localization.py file then I got the above error.
Ok, so it seems that the errors are just caused by the different version of packages.
It worked for me after I changed the name in denseNet_localization.py module.densenet121.features.denseblock4.denselayer16.conv.2 to module.densenet121.features.denseblock4.denselayer16.conv2
And I had some package version issues as well.
Hi Tang,
I am able to generate the bound_box.txt file after I execute the denseNet_localization.pyfile. how to visualize the bound box text file into the input image? as you mentioned in ground-truth label (red) and its prediction (blue). Thanks in advance..
Please assist me on this..
Sent from my iPhone
On 28-May-2019, at 17:57, T.H. Tang [email protected] wrote:
It seem that the errors are just caused by the different version of packages.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I changed module.densenet121.features.denseblock4.denselayer16.conv.2 to module.densenet121.features.denseblock4.denselayer16.conv2 but still have same problem. What should I do ... ??
I'm using torch (1.0.1.post2) torchvision (0.2.2.post3)
File "denseNet_localization.py", line 247, in <module>
output = gcam.generate(target_layer="module.densenet121.features.denseblock4.denselayer16.conv2")
File "denseNet_localization.py", line 211, in generate
fmaps = self._find(self.all_fmaps, target_layer)
File "denseNet_localization.py", line 199, in _find
raise ValueError('Invalid layer name: {}'.format(target_layer))
ValueError: Invalid layer name: module.densenet121.features.denseblock4.denselayer16.conv2```
I changed module.densenet121.features.denseblock4.denselayer16.conv.2 to module.densenet121.features.denseblock4.denselayer16.conv2 but still have same problem. What should I do ... ??
I'm using torch (1.0.1.post2) torchvision (0.2.2.post3)
File "denseNet_localization.py", line 247, in <module> output = gcam.generate(target_layer="module.densenet121.features.denseblock4.denselayer16.conv2") File "denseNet_localization.py", line 211, in generate fmaps = self._find(self.all_fmaps, target_layer) File "denseNet_localization.py", line 199, in _find raise ValueError('Invalid layer name: {}'.format(target_layer)) ValueError: Invalid layer name: module.densenet121.features.denseblock4.denselayer16.conv2```
have you solved this problem? I'm facing the same issue.
I changed module.densenet121.features.denseblock4.denselayer16.conv.2 to module.densenet121.features.denseblock4.denselayer16.conv2 but still have same problem. What should I do ... ?? I'm using torch (1.0.1.post2) torchvision (0.2.2.post3)
File "denseNet_localization.py", line 247, in <module> output = gcam.generate(target_layer="module.densenet121.features.denseblock4.denselayer16.conv2") File "denseNet_localization.py", line 211, in generate fmaps = self._find(self.all_fmaps, target_layer) File "denseNet_localization.py", line 199, in _find raise ValueError('Invalid layer name: {}'.format(target_layer)) ValueError: Invalid layer name: module.densenet121.features.denseblock4.denselayer16.conv2```
have you solved this problem? I'm facing the same issue.
If I use torchvision 0.2.0 and torch==1.0.1 I get the following error.
warn("The default mode, 'constant', will be changed to 'reflect' in " 0 Traceback (most recent call last): File "denseNet_localization.py", line 76, in <module> model = DenseNet121(8).cuda() File "denseNet_localization.py", line 65, in __init__ self.densenet121 = torchvision.models.densenet121(pretrained=True) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 26, in densenet121 **kwargs) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 142, in __init__ bn_size=bn_size, growth_rate=growth_rate, drop_rate=drop_rate) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/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 "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 77, in __init__ self.add_module('norm.1', nn.BatchNorm2d(num_input_features)), File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torch/nn/modules/module.py", line 180, in add_module raise KeyError("module name can't contain \".\"") KeyError: 'module name can\'t contain "."'
So I have upgraded torchvision to 0.2.2. and torch==1.1.0. and my train went successful. When I try to run denseNet_localization.py file then I got the above error.
Hello @rajdeinno how did u solve this error please healp me in this regard. Thanks @rajdeinno
If I use torchvision 0.2.0 and torch==1.0.1 I get the following error.
warn("The default mode, 'constant', will be changed to 'reflect' in " 0 Traceback (most recent call last): File "denseNet_localization.py", line 76, in <module> model = DenseNet121(8).cuda() File "denseNet_localization.py", line 65, in __init__ self.densenet121 = torchvision.models.densenet121(pretrained=True) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 26, in densenet121 **kwargs) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 142, in __init__ bn_size=bn_size, growth_rate=growth_rate, drop_rate=drop_rate) File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/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 "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torchvision/models/densenet.py", line 77, in __init__ self.add_module('norm.1', nn.BatchNorm2d(num_input_features)), File "/home/administrator/Desktop/Projects/xray/chexnet/setup3.5/lib/python3.5/site-packages/torch/nn/modules/module.py", line 180, in add_module raise KeyError("module name can't contain \".\"") KeyError: 'module name can\'t contain "."'
So I have upgraded torchvision to 0.2.2. and torch==1.1.0. and my train went successful. When I try to run denseNet_localization.py file then I got the above error.
Hello @rajdeinno how did u solve this error please healp me in this regard. Thanks @rajdeinno
check this. https://github.com/thtang/CheXNet-with-localization/issues/7#issuecomment-514562151
Hi Tang, I am able to generate the bound_box.txt file after I execute the denseNet_localization.pyfile. how to visualize the bound box text file into the input image? as you mentioned in ground-truth label (red) and its prediction (blue). Thanks in advance.. Please assist me on this.. … Sent from my iPhone On 28-May-2019, at 17:57, T.H. Tang @.***> wrote: It seem that the errors are just caused by the different version of packages. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
@rajdeinno hello sir after generating BB file how you print BB on that image with heatmap of that image? Pleae help