jacobgil / pytorch-grad-cam

Advanced AI Explainability for computer vision. Support for CNNs, Vision Transformers, Classification, Object detection, Segmentation, Image similarity and more.
https://jacobgil.github.io/pytorch-gradcam-book
MIT License
9.79k stars 1.52k forks source link

Fix use_cuda of swin transformer example code #505

Open chilin0525 opened 1 month ago

chilin0525 commented 1 month ago

Based on https://github.com/jacobgil/pytorch-grad-cam/issues/504, use_cuda already removed in https://github.com/jacobgil/pytorch-grad-cam/commit/00711a20b7a8dfb6d6d1d892216997daeeee6288, so user will get error when executing swin transformer example code currently.

After fixing, the code will run successfully for CPU and GPU scenario, following is my test result:

$ python3 usage_examples/swinT_example.py --use-cuda
Using GPU for acceleration
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:07<00:00,  4.43it/s]

$ python3 usage_examples/swinT_example.py
Using CPU for computation
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 32/32 [02:01<00:00,  3.78s/it]