Giter VIP home page Giter VIP logo

paddlepaddle / interpretdl Goto Github PK

View Code? Open in Web Editor NEW
229.0 12.0 36.0 32.68 MB

InterpretDL: Interpretation of Deep Learning Models,基于『飞桨』的模型可解释性算法库。

Home Page: https://interpretdl.readthedocs.io

License: Apache License 2.0

Shell 0.09% Python 99.91%
interpretation-algorithms paddlepaddle vision-transformer model-interpretation explanations grad-cam lime convolutional-neural-networks nlp-models smoothgrad

interpretdl's People

Contributors

carlzhang94 avatar christophe-jia avatar holyseven avatar jiaminchen-1031 avatar miaomaomiaomaoda avatar raindrops2sea avatar trellixvulnteam avatar wgm-inspur avatar xianrenyty avatar xuanyuwu123 avatar zhwesky2010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interpretdl's Issues

关于分割模型的可视化

请问目前有关于分割模型可视化的热力图方法吗,
我使用gradcam的教程在自己网络尝试,
显示我的维度不对,不知道该怎么处理。

热力图

(optional) Briefly introduce yourself.

请问使用interpretDL绘制ppyoloe的热力图,如何加载模型?
如果在infer.py里这样写会报这样的错误
image
image

❓ Questions and Help

求指教这个问题怎么导致的呢

你好,同是厂内开发人员,尝试用这个工具,跑了代码库里的InterpretDL/tutorials/normlime_tutorial_nlp.ipynb
,模型数据都下好了,跑的时候报错,不知道具体是什么意思,求指教
total of 1200 sentences
0%| | 0/1200 [00:00<?, ?it/s]2020-12-18 11:44:57,011-WARNING: /Users/wanghao81/senta_model/bilstm_model/params/checkpoint.pdparams not found, try to load model file saved with [ save_params, save_persistables, save_vars ]
2020-12-18 11:44:57,211-WARNING: /Users/wanghao81/senta_model/bilstm_model/params.pdparams not found, try to load model file saved with [ save_params, save_persistables, save_vars ]
2020-12-18 11:44:57,211-WARNING: variable file [ /Users/wanghao81/senta_model/bilstm_model/params/learning_rate_0 /Users/wanghao81/senta_model/bilstm_model/params/lstm_0.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_2.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_0.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/embedding_0.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/lstm_1.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_0.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_3.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_1.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_1.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_3.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/lstm_1.b_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/fc_2.w_0_moment_0 /Users/wanghao81/senta_model/bilstm_model/params/lstm_0.w_0_moment_0 ] not used
Load model from /Users/wanghao81/senta_model/bilstm_model/params
4%|▍ | 52/1200 [00:03<01:09, 16.61it/s]
Traceback (most recent call last):
File "/Users/wanghao81/InterpretDL/tutorials/test.py", line 67, in
batch_size=10)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/_normlime_base.py", line 400, in interpret
auto_save=(i % 10) == 0)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/_normlime_base.py", line 271, in _get_lime_weights
batch_size=batch_size)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/lime.py", line 342, in interpret
probability = self.predict_fn(*self.model_inputs)[0]
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/lime.py", line 417, in predict_fn
for i, d in enumerate(params)})
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/executor.py", line 1071, in run
six.reraise(*sys.exc_info())
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/executor.py", line 1066, in run
return_merged=return_merged)
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/executor.py", line 1154, in _run_impl
use_program_cache=use_program_cache)
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/executor.py", line 1229, in _run_program
fetch_var_name)
paddle.fluid.core_avx.EnforceNotMet:


C++ Call Stacks (More useful to developers):

0 std::string paddle::platform::GetTraceBackString<std::string const&>(std::string const&&&, char const*, int)
1 void paddle::operators::math::CopyValidData(paddle::framework::Tensor*, paddle::framework::Tensor const*, paddle::framework::CPUVector const&, int, int, bool, paddle::operators::math::CopyType, paddle::operators::math::PadLayout)
2 paddle::operators::math::UnpaddingLoDTensorFunctor<paddle::platform::CPUDeviceContext, float>::operator()(paddle::platform::CPUDeviceContext const&, paddle::framework::LoDTensor const&, paddle::framework::LoDTensor*, int, int, bool, paddle::operators::math::PadLayout)
3 paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, float>::Compute(paddle::framework::ExecutionContext const&) const
4 std::__1::__function::__func<paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, float>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, double>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, int>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, long long> >::operator()(char const*, char const*, int) const::'lambda'(paddle::framework::ExecutionContext const&), std::__1::allocator<paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, float>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, double>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, int>, paddle::operators::SequenceUnpadOpKernel<paddle::platform::CPUDeviceContext, long long> >::operator()(char const*, char const*, int) const::'lambda'(paddle::framework::ExecutionContext const&)>, void (paddle::framework::ExecutionContext const&)>::operator()(paddle::framework::ExecutionContext const&)
5 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&, paddle::framework::RuntimeContext*) const
6 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&) const
7 paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, paddle::platform::Place const&)
8 paddle::framework::Executor::RunPartialPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, long long, long long, bool, bool, bool)
9 paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::__1::vector<std::string, std::__1::allocator<std::string > > const&, bool, bool)
10 void pybind11::cpp_function::initialize<paddle::pybind::pybind11_init_core_avx(pybind11::module&)::$_111, void, paddle::framework::Executor&, paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::__1::vector<std::string, std::__1::allocator<std::string > > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(paddle::pybind::pybind11_init_core_avx(pybind11::module&)::$_111&&, void ()(paddle::framework::Executor&, paddle::framework::ProgramDesc const&, paddle::framework::Scope, int, bool, bool, std::__1::vector<std::string, std::__1::allocator<std::string > > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&)
11 pybind11::cpp_function::dispatcher(_object*, _object*, _object*)


Python Call Stacks (More useful to users):

File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/framework.py", line 2610, in append_op
attrs=kwargs.get("attrs", None))
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/Users/wanghao81/opt/anaconda3/envs/paddle_env/lib/python3.6/site-packages/paddle/fluid/layers/sequence_lod.py", line 1057, in sequence_unpad
outputs={'Out': out})
File "/Users/wanghao81/InterpretDL/tutorials/assets/bilstm.py", line 106, in bilstm
emb = fluid.layers.sequence_unpad(emb, length=seq_len)
File "/Users/wanghao81/InterpretDL/tutorials/test.py", line 36, in paddle_model
probs = bilstm(word_ids, seq_len, None, DICT_DIM, is_prediction=True)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/lime.py", line 392, in _paddle_prepare
probs = self.paddle_model(*data_ops)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/lime.py", line 340, in interpret
self._paddle_prepare()
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/_normlime_base.py", line 271, in _get_lime_weights
batch_size=batch_size)
File "/Users/wanghao81/InterpretDL/interpretdl/interpreter/_normlime_base.py", line 400, in interpret
auto_save=(i % 10) == 0)
File "/Users/wanghao81/InterpretDL/tutorials/test.py", line 67, in
batch_size=10)


Error Message Summary:

Error: The padded sequence length can not be less than its original length.
[Hint: Expected pad_seq_len >= valid_seq_len, but received pad_seq_len:256 < valid_seq_len:278.] at (/home/teamcity/work/ef54dc8a5b211854/paddle/fluid/operators/math/sequence_padding.cc:38)
[operator < sequence_unpad > error]

Process finished with exit code 1

Interface

🚀 Feature

An interface for using the explanation algorithms in InterpretDL.

Motivation

Much easier to use.

Alternatives

Mindinsight, EISeg.

分割可视化

我用给的示例代码运行分割模型
尝试了ppliteseg官方代码和权重,以及自己训练的权重,可视化的图形如下,是什么原因呢?
image

Error upon installation

Hi, my name is Matt Cremeens and am interested in using your work for a research project.


🐛 Bug

Error upon installation

To Reproduce

Steps to reproduce the behavior:

  1. Installed PaddlePaddle following these instructions: https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/macos-pip.html
  2. pip install interpretdl
  3. Received error below

If you have a code sample, error messages, stack traces, please provide it here as well.

Failed to build numpy
      ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.

(optional) Enviroment

If you know well the environment of your machine, please put the information below:

macOS
python3.9

Grad-CAM可视化分割模型

(optional) Briefly introduce yourself.

---请问有Grad-CAM可视化分割模型的时间安排吗?

❓ Questions and Help

Tutorial error

location: https://github.com/PaddlePaddle/InterpretDL/blob/master/tutorials/GradCAM_Segmentation.ipynb

🐛 Bug

in funciton GradCAMSegInterpreter._build_predict_fn( ).predict_fn( ) :

# paddle gradient computation changes since 2.4
paddle_version=tuple(map(int, paddle.__version__.split(".")))
if paddle_version>=(2,4,0):
       loss.backward(retain_graph=True) #since paddle 2.4
       gradients = paddle.grad(
             outputs=[target], inputs=[self._feature_maps[self._target_layer_name]])[0]
else:
       oss.backward()
       gradients = self._feature_maps[self._target_layer_name].grad

error: target is not defined,it should be loss

运行example_grad_cam_cv.ipynb时报错

(optional) Briefly introduce yourself.


🐛 Bug

运行example_grad_cam_cv.ipynb时会报错

To Reproduce

Steps to reproduce the behavior:

  1. 直接运行该notebook
  2. 报错信息如下
---------------------------------------------------------------------------
AxisError                                 Traceback (most recent call last)
/paddle/temp/ipykernel_14605/90004086.py in <module>
      9         label=None,
     10         visual=True,
---> 11         save_path=None)

/paddle/code/gry/InterpretDL/interpretdl/interpreter/gradient_cam.py in interpret(self, inputs, target_layer_name, label, resize_to, crop_to, visual, save_path)
     99 
    100         # the core algorithm
--> 101         cam_weights = np.mean(g, (2, 3), keepdims=True)
    102         heatmap = cam_weights * f
    103         heatmap = heatmap.mean(1)

<__array_function__ internals> in mean(*args, **kwargs)

/usr/local/python3.7.0/lib/python3.7/site-packages/numpy/core/fromnumeric.py in mean(a, axis, dtype, out, keepdims, where)
   3439 
   3440     return _methods._mean(a, axis=axis, dtype=dtype,
-> 3441                           out=out, **kwargs)
   3442 
   3443 

/usr/local/python3.7.0/lib/python3.7/site-packages/numpy/core/_methods.py in _mean(a, axis, dtype, out, keepdims, where)
    165     is_float16_result = False
    166 
--> 167     rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)
    168     if rcount == 0 if where is True else umr_any(rcount == 0, axis=None):
    169         warnings.warn("Mean of empty slice.", RuntimeWarning, stacklevel=2)

/usr/local/python3.7.0/lib/python3.7/site-packages/numpy/core/_methods.py in _count_reduce_items(arr, axis, keepdims, where)
     74         items = nt.intp(1)
     75         for ax in axis:
---> 76             items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]
     77     else:
     78         # TODO: Optimize case when `where` is broadcast along a non-reduction

报错的命令为

image

Failed to apply gradcam on mobileNetv3-large

🐛 Bug

I attempted to apply the Grad-CAM algorithm to mobilenetv3-large but failed. Here are the error messages and version information I have. I think it may have some connection with the issue mentioned in this topic.

To Reproduce

Steps to reproduce the behavior:

  1. The model is from paddle.vision.models, and the only modification is the output dimentsion of last fc layer since my number of classes doesnt match the pretrained paremeter.
  2. After training, the pdmodel is stored locally, and use the python code below to load the model arch and parameter, attempting to extract the feature map.
import interpretdl as it
from interpretdl.data_processor.readers import read_image
from paddle.vision.models import mobilenet_v3_large
from paddle.vision.models import resnet50

import os
import paddle
paddle.device.set_device('gpu:0')

# paddle_model = resnet50(pretrained=True)
paddle_model = mobilenet_v3_large(pretrained=True, num_classes=150) 
checkpoint_path = ""
if os.path.exists(checkpoint_path):
    param_state_dict = paddle.load(os.path.join(checkpoint_path, "mobileNetv3_5_16.pdparams"))
    paddle_model.set_state_dict(param_state_dict)

gradcam = it.GradCAMInterpreter(paddle_model, device='gpu:0')
layers_name = []
for n, v in paddle_model.named_sublayers():
    layers_name.append(n)
print(layers_name)
img_path = ''
print(paddle_model)
heatmap = gradcam.interpret(
        img_path,
        'lastconv.0',
        label=None,
        visual=True,
        save_path=None)

Stacktrace

Traceback (most recent call last):
  File "interpretability.py", line 24, in <module>
    heatmap = gradcam.interpret(
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/interpretdl/interpreter/gradient_cam.py", line 90, in interpret
    feature_map, gradients, preds = self.predict_fn(data, label)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/interpretdl/interpreter/gradient_cam.py", line 140, in predict_fn
    out = self.model(data)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 1012, in __call__
    return self.forward(*inputs, **kwargs)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/vision/models/mobilenetv3.py", line 237, in forward
    x = self.conv(x)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 1012, in __call__
    return self.forward(*inputs, **kwargs)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/container.py", line 98, in forward
    input = layer(input)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 1012, in __call__
    return self.forward(*inputs, **kwargs)
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/conv.py", line 712, in forward
    out = F.conv._conv_nd(
  File "/home/xyt/.conda/envs/paddle/lib/python3.8/site-packages/paddle/nn/functional/conv.py", line 140, in _conv_nd
    pre_bias = _C_ops.conv2d(
OSError: (External) CUDNN error(4), CUDNN_STATUS_INTERNAL_ERROR. 
  [Hint: Please search for the error code(4) on website (https://docs.nvidia.com/deeplearning/cudnn/api/index.html#cudnnStatus_t) to get Nvidia's official solution and advice about CUDNN Error.] (at /paddle/paddle/phi/backends/gpu/gpu_resources.cc:227)

Enviroment

  • paddlepaddle-gpu 2.4.2.post116

  • NVIDIA A10 CUDA Version: 11.6

  • PaddlePaddle version (eg. 2.1): 2.4.2.post116

  • CPU: AMD EPYC 7713 64-Core Processor

  • GPU: 11.6/8.4.1

  • OS Platform (eg. Mac OS 10.14): ubuntu18.04

  • Graphics card storage: 23028MiB

NormLIMENLPInterpreter的interpret函数多次调用结果会有异常

NormLIMENLPInterpreter的interpret函数会调用lime方法,并将结果根据一个临时索引dict_key保存在一个字典中,下次调用如果索引存在则不调用lime方法,直接取字典中索引对应的结果。
但是dict_key每次都是从0开始计数的,所以如果连续多次调用interpret且输入的data不同,就会返回错误的结果。
abfcf46cad65db0b4a9fc4279993f42e
e9492608aa4b244747f2a2a82f426944

另外temp_data_file设置为None时可否不保存结果,现在每次调用都会生成一个结果文件感觉不太方便。

grad-CAM or score-CAM visualization with a Mask R-CNN model

Hi there. I am trying to implement CAM visualizations with a Mask R-CNN model. As you know, Mask R-CNN performs classifications per ROI, but the backbone network (for ex. a FPN with Resnet50 conv blocks) extracts features over the entire input image. Could you provide some guidance as to how to use InterpretDL to generate CAM with a Mask R-CNN model? Much appreciated!

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind'

This is my code:
`!pip install paddlepaddle-gpu
!git clone https://github.com/PaddlePaddle/InterpretDL.git
import os
import sys
os.chdir(/content/InterpretDL)
sys.path.insert(0, os.getcwd())
import interpretdl as it
!wget -c https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams -P /content/InterpretDL/tutorials/assets/
from tutorials.assets.vision_transformer import ViT_base_patch16_224
paddle_model = ViT_base_patch16_224()
MODEL_PATH = /content/InterpretDL/tutorials/assets/ViT_base_patch16_224_pretrained.pdparams
paddle_model.state_dict(paddle.load(MODEL_PATH))
img_path = /content/InterpretDL/imgs/catdog.jpg
tam = it.TAMInterpreter(paddle_model)
heatmap = tam.interpret(
img_path,
start_layer=4,
label=None, # cat
visual=True,
save_path=None)'
But i keep getting this error:
UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind'
why?

运行基于模型中间特征的算法时,有一个'feature_maps' is not defined的报错

我的代码如下:

import interpretdl as it
from interpretdl.data_processor.visualizer import visualize_grayscale

ResNet18_PATH = "ResNet18_chk_points/final.pdparams"
ResNet18 = paddle.vision.models.resnet18(pretrained=True, num_classes=6)
ResNet18_state_dict = paddle.load(ResNet18_PATH)
ResNet18.set_dict(ResNet18_state_dict)

ResNet18_gradcam = it.GradCAMInterpreter(ResNet18, use_cuda=True)

ResNet18_gradients = ResNet18_gradcam.interpret("face/Trump/1.jpg", target_layer_name='concat_0.tmp_0', visual=True, save_path=None)  #展示结果

visualize_grayscale(ResNet18_gradients[0])   #将结果转化为灰度图,展示效果更直观

输出结果:

---------------------------------------------------------------------------NameError                                 Traceback (most recent call last)<ipython-input-32-384a620fc707> in <module>
      1 ResNet18_gradcam = it.GradCAMInterpreter(ResNet18, use_cuda=True)
      2 
----> 3 ResNet18_gradients = ResNet18_gradcam.interpret("face/Trump/1.jpg", target_layer_name='concat_0.tmp_0', visual=True, save_path=None)  #展示结果
      4 
      5 visualize_grayscale(ResNet18_gradients[0])   #将结果转化为灰度图,展示效果更直观
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/interpretdl/interpreter/gradient_cam.py in interpret(self, inputs, target_layer_name, labels, visual, save_path)
     91         bsz = len(data)
     92         if labels is None:
---> 93             _, _, preds = self.predict_fn(data, labels)
     94             labels = preds
     95         labels = np.array(labels).reshape((bsz, ))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/interpretdl/interpreter/gradient_cam.py in predict_fn(data, labels)
    151                 target = paddle.sum(out * labels_onehot, axis=1)
    152                 gradients = paddle.grad(
--> 153                     outputs=[target], inputs=[feature_maps])[0]
    154                 return feature_maps.numpy(), gradients.numpy(), labels
    155 
NameError: name 'feature_maps' is not defined

Any interest for supporting LayerCAM

Our paper "LayerCAM: Exploring Hierarchical Class Activation Maps for Localization" is accepted by TIP recently, which can visualize the class activation maps from any cnn layer of an off-the-shelf network. Could you add our method to your popular repository for more people to try this method? Our method is a simple modification of Grad-CAM. It should easy to implement. Here is the paper and code. Hope for your reply.

Gradient computation changed since paddle2.4

Thanks @CarlZhang1020 for reporting the issue and the PR. See the modification in the PR for example of gradcam.

grad method changed in paddle2.4, need to check more code about grad process....grad-cam for example

Before solving this issue completely, we are suggesting using paddle2.3.2 currently.

gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
/usr/local/lib/python3.8/dist-packages/matplotlib/backends/backend_gtk3.py:40: DeprecationWarning: Gdk.Cursor.new is deprecated
cursors.MOVE: Gdk.Cursor.new(Gdk.CursorType.FLEUR),

(gmlp_view.py:513934): Gdk-CRITICAL **: 01:20:32.911: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Killed

Shapely Value

(optional) Briefly introduce yourself.


❓ Questions and Help

似乎InterpretDL没有提供shapely value的相关计算工具和可视化功能?我没有很了解,是否有大佬能提供帮助和讯息,paddle有没有提供类似的计算方法呀?
主要shap库:https://github.com/slundberg/shap
依赖pytroch,pytroch又跟paddle不兼并。搞的我用paddle训练的模型,无法用shapely value 去做解释说明诶...

安装问题

使用pip直接安装报错:
ERROR: Could not find a version that satisfies the requirement interpretDL (from versions: none) ERROR: No matching distribution found for interpretDL

customized input data

🚀 Feature

Input data processing needs to be flexible and can be customized.

Motivation and Additional context

Currently, images are normalized according to natural images, like ImageNet statistics. However, for medical, remote sensing, and other types of 2D inputs (or even more complex data), current pipelines cannot deal with.

Alternatives

Maybe paddle.vision.transforms or other transformations can be used.

softmax(): argument 'x' (position 0) must be Tensor, but got list

import paddle
from PIL import Image
import interpretdl as it
from interpretdl.data_processor.readers import read_image
from paddleseg.models import MixVisionTransformer_B5
from paddleseg.models.backbones import *

url = 'https://bj.bcebos.com/paddleseg/dygraph/pretrained_models/vit_small_patch16_384_augreg.tar.gz'
paddle_model = ViT_base_patch16_384(pretrained=url, num_classes=2)

result = [n for n, v in paddle_model.named_sublayers()]
print(result)

tam = it.TAMInterpreter(paddle_model)

Path = "imgs/catdog.jpg"

Layer = 'norm1'

heatmap = tam.interpret(
Path,
start_layer=4,
label=None, # cat
visual=True,
save_path=None)

❓ Questions and Help

代码如上,不管我换什么网络换什么层显示都报这个错
泪目了,求助
Traceback (most recent call last):
File "D:\project\InterpretDL-master\test.py", line 20, in
heatmap = tam.interpret(
File "D:\project\InterpretDL-master\interpretdl\interpreter\transition_attention_maps.py", line 78, in interpret
attns, _, preds = self.predict_fn(data)
File "D:\project\InterpretDL-master\interpretdl\interpreter\transition_attention_maps.py", line 149, in predict_fn
out = paddle.nn.functional.softmax(out, axis=1)
File "C:\soft\anaconda3\envs\paddle\lib\site-packages\paddle\nn\functional\activation.py", line 1142, in softmax
return _C_ops.softmax(outs_cast, axis)
ValueError: (InvalidArgument) softmax(): argument 'x' (position 0) must be Tensor, but got list (at ..\paddle\fluid\pybind\eager_utils.cc:894)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.