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

NotImplementedError: Relevance propagation not implemented for layer type <class 'models.common.BottleneckCSP'> #11

Open
HansYeoh opened this issue Oct 19, 2023 · 0 comments

Comments

@HansYeoh
Copy link

Hi @akarasman ,
I plan to reproduce your code, but when I run the sample command I get a first off error as below. Since I am not very familiar with the yolo model, I would like to ask you for advice.
Error:

$python3 explain.py --source=data/images/me.png --weights=yolov5s.pt --explain-class='person'
explain: weights=['yolov5s.pt'], source=data/images/me.png, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, visualize=False, update=False, project=runs/explain, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, power=1, contrastive=False, b1=1.0, b2=1.0, explain_class=person, conf=False, max_class_only=True, box_xywh=None, smooth_ks=1, box_xyxy=None, cmap=magma
YOLOv5 🚀 2022-8-1 torch 1.10.1+cu111 CUDA:0 (NVIDIA GeForce RTX 3070, 7971MiB)

Fusing layers... 
Model Summary: 232 layers, 7459581 parameters, 0 gradients
Traceback (most recent call last):
  File "/home/why/Desktop/LRP/inverter.py", line 199, in invert
    return self.inv_funcs[type(layer)](self, layer, relevance, **kwargs) 
KeyError: <class 'models.common.BottleneckCSP'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "explain.py", line 391, in <module>
    main(opt)
  File "explain.py", line 387, in main
    run(**vars(opt))
  File "/home/why/anaconda3/envs/lrp/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "explain.py", line 282, in run
    get_explanation(inn_model, init, contrastive, b1, b2, int(cls),
  File "explain.py", line 54, in get_explanation
    lrp_out = inn_model.innvestigate(in_tensor=None, initializer=init)
  File "/home/why/Desktop/LRP/innvestigator.py", line 351, in innvestigate
    relevance = self.inverter(layer, relevance)
  File "/home/why/Desktop/LRP/inverter.py", line 206, in __call__
    return self.invert(layer, relevance, **kwargs)
  File "/home/why/Desktop/LRP/inverter.py", line 201, in invert
    raise NotImplementedError(f'Relevance propagation not implemented for layer type {type(layer)}')
NotImplementedError: Relevance propagation not implemented for layer type <class 'models.common.BottleneckCSP'>

And here's the list of dependencies

$ conda list
# packages in environment at /home/why/anaconda3/envs/lrp:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
absl-py                   2.0.0                     <pip>
asttokens                 2.4.0                     <pip>
backcall                  0.2.0                     <pip>
Bottleneck                1.3.7                     <pip>
ca-certificates           2023.08.22           h06a4308_0    defaults
cachetools                5.3.1                     <pip>
certifi                   2023.7.22                 <pip>
charset-normalizer        3.3.0                     <pip>
contourpy                 1.1.1                     <pip>
cycler                    0.12.1                    <pip>
decorator                 5.1.1                     <pip>
executing                 2.0.0                     <pip>
fonttools                 4.43.1                    <pip>
google-auth               2.23.3                    <pip>
google-auth-oauthlib      1.0.0                     <pip>
grpcio                    1.59.0                    <pip>
idna                      3.4                       <pip>
importlib-metadata        6.8.0                     <pip>
importlib-resources       6.1.0                     <pip>
ipython                   8.12.3                    <pip>
jedi                      0.19.1                    <pip>
joblib                    1.3.2                     <pip>
kiwisolver                1.4.5                     <pip>
ld_impl_linux-64          2.38                 h1181459_1    defaults
libffi                    3.3                  he6710b0_2    defaults
libgcc-ng                 9.1.0                hdf63c60_0    defaults
libstdcxx-ng              9.1.0                hdf63c60_0    defaults
Markdown                  3.5                       <pip>
MarkupSafe                2.1.3                     <pip>
matplotlib                3.7.3                     <pip>
matplotlib-inline         0.1.6                     <pip>
ncurses                   6.3                  h7f8727e_2    defaults
numpy                     1.24.4                    <pip>
oauthlib                  3.2.2                     <pip>
opencv-python             4.8.1.78                  <pip>
openssl                   1.1.1w               h7f8727e_0    defaults
packaging                 23.2                      <pip>
pandas                    2.0.3                     <pip>
parso                     0.8.3                     <pip>
pexpect                   4.8.0                     <pip>
pickleshare               0.7.5                     <pip>
Pillow                    10.1.0                    <pip>
pip                       23.2.1           py38h06a4308_0    defaults
ply                       3.11                      <pip>
prompt-toolkit            3.0.39                    <pip>
protobuf                  4.24.4                    <pip>
psutil                    5.9.6                     <pip>
ptyprocess                0.7.0                     <pip>
pure-eval                 0.2.2                     <pip>
pyasn1                    0.5.0                     <pip>
pyasn1-modules            0.3.0                     <pip>
Pygments                  2.16.1                    <pip>
pyparsing                 3.1.1                     <pip>
python                    3.8.13               h12debd9_0    defaults
python-dateutil           2.8.2                     <pip>
pytz                      2023.3.post1              <pip>
PyYAML                    6.0.1                     <pip>
readline                  8.1.2                h7f8727e_1    defaults
requests                  2.31.0                    <pip>
requests-oauthlib         1.3.1                     <pip>
rsa                       4.9                       <pip>
scikit-learn              1.3.1                     <pip>
scipy                     1.10.1                    <pip>
seaborn                   0.13.0                    <pip>
setuptools                53.0.0                    <pip>
setuptools                68.0.0           py38h06a4308_0    defaults
sip                       6.7.12                    <pip>
six                       1.16.0                    <pip>
sqlite                    3.38.2               hc218d9a_0    defaults
stack-data                0.6.3                     <pip>
tensorboard               2.14.0                    <pip>
tensorboard-data-server   0.7.1                     <pip>
thop-0.1.1                2209072238                <pip>
threadpoolctl             3.2.0                     <pip>
tk                        8.6.11               h1ccaba5_0    defaults
tomli                     2.0.1                     <pip>
torch                     1.10.1+cu111              <pip>
torchaudio                0.10.1+rocm4.1            <pip>
torchvision               0.11.2+cu111              <pip>
tqdm                      4.66.1                    <pip>
traitlets                 5.11.2                    <pip>
typing_extensions         4.8.0                     <pip>
tzdata                    2023.3                    <pip>
urllib3                   2.0.7                     <pip>
wcwidth                   0.2.8                     <pip>
Werkzeug                  3.0.0                     <pip>
wheel                     0.41.2           py38h06a4308_0    defaults
xz                        5.2.5                h7f8727e_1    defaults
zipp                      3.17.0                    <pip>
zlib                      1.2.11                        0    https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free
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

1 participant