microsoft / vision-explanation-methods

Methods for creating saliency maps for computer vision models.
https://vision-explanation-methods.readthedocs.io/en/latest/
MIT License
39 stars 12 forks source link

fix build gates failing with pytorch errors due to old torchvision install and pin matplotlib #22

Closed imatiach-msft closed 1 year ago

imatiach-msft commented 1 year ago

Description

The build gates started failing recently with the error:

/usr/share/miniconda/envs/test/lib/python3.7/site-packages/torchvision/models/inception.py:195: in Inception3
    @torch.jit.unused
E   AttributeError: module 'torch.jit' has no attribute 'unused'

This is due to an old version of torchvision getting installed and may be related to the recent pytorch 2.0.0 release. This PR fixes the issue by using the "strict-channel-priority" flag in conda install to ensure we are installing torchvision package from the pytorch channel.

Update: after the fix above, a new version of matplotlib was getting installed, but captum would fail as it still does not support latest matplotlib. Please see issue: https://github.com/pytorch/captum/issues/1114

Also, the typehint in the code started failing when I did upgrade to latest matplotlib, so I am also pre-emptively adding an import fix for the typehint when captum does start supporting the latest matplotlib in the future.

Another update: I've also rotated the carton image because sometimes the fasterrcnn model with pretrained weights would fail to find objects on some OSs (I think it might be a flaky/inconsistent issue?).

Checklist

codecov-commenter commented 1 year ago

Codecov Report

Merging #22 (bfa8664) into main (13d73f0) will increase coverage by 0.10%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   93.28%   93.38%   +0.10%     
==========================================
  Files           6        6              
  Lines         253      257       +4     
==========================================
+ Hits          236      240       +4     
  Misses         17       17              
Flag Coverage Δ
unittests 93.38% <100.00%> (+0.10%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/vision_explanation_methods/DRISE_runner.py 92.23% <100.00%> (+0.31%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

natalie-isak commented 1 year ago

Thanks for fixing this! I had noticed an error with matplotlib and the Axis attribute but I wasn't sure the best way to pin the dependencies. Looks great!!