Closed caglayantuna closed 5 months ago
Dear @caglayantuna,
Thank you very much for your interest in our library. Regarding your questions and problems:
Rise
and Occlusion
methods can indeed be time-consuming as they make many inferences on many perturbed samples to estimate important pixels. Furthermore, the free GoogleColab can be slow when many inferences are needed. Nonetheless, I have several solutions:
batch_size
parameter.Rise
, you can try to reduce nb_samples
parameter, if the results are too noisy, then you can reduce grid_size
, but explanations may not stay precise enough, it is a trade-off. Regarding Occlusion
, you can try to increase batch_stride
, but batch_stride
should stay a multiple of batch_stride
.SobolAttributionMethod
or HsicAttributionMethod
; these methods use more optimized sampling and thus require fewer inferences.In your code, you called explainer.explain
in a torch.no_grad()
context. I tried adding this line in the tutorial, and I obtained the same error as the one you mentioned. Thus, I suggest that you remove it and hope it will solve your issue.
I would like to make a remark on the wrapper you used for the model: the NMF function should be removed from your model inference in an explainability setting. You can have it for inference to select the instances to explain, but it should be removed from the model you explain. More information and justifications can be found in the object detection documentation in practice section.
I hope this allows you to apply both perturbation-based and gradient-based methods on Ultralytics' models.
Best regards, Antonin
Hi Antonin,
Thanks for your answer it helped me a lot. I was waiting to try everything you suggested to me. To be honest, I couldn't managed to run gradient-based methods with my model. However, by coincidence, I met with Thomas Fel and he told me that pytorch could be the reason for this issue. He said that, the library will be improved soon to solve this issue
As you suggested to me, I tried Rise with reduced number of samples and it really worked very well for my OD task. Thank you very much :)
Best,
Module
Attributions Methods
Current Behavior
Dear Deel-ai team,
Thanks for this library, it is very well structured and very educative. However, I have 2 questions or problems when I use your library.
1- When I run OD notebook, it takes more than 40 minutes. Processing time is very long especially for Occlusion and Rise methods. Is it normal?
2- I am trying to apply your attribution methods with my Ultralytics Yolov5 model. Unfortunately, I get a "grad_fn" error when I apply gradient-based methods such as Saliency. With gradient-free methods such as Occlusion, it is very long as Colab notebook and I couldn't get any meaningful result for now. I checked on similar issue #157 but I couldn't find a solution. Do you have any experience with these models?
Expected Behavior
It would be nice to run attribution methods for ultralytics OD models without any problem.
Version
1.3.3
Environment
Relevant log output
To Reproduce