myc159 / Deep-Taylor-Decomposition

DTD implement on Imagenet pretrained model
39 stars 9 forks source link

How to run this project on my personal inputa image datasets #1

Open LIN-ALOHA opened 4 years ago

LIN-ALOHA commented 4 years ago

I have prepared the pytorch packages and everything, but when I run the main.py, the wrong infos come out like:

test setup failed file C:\Users\lin\Desktop\gradduate_design\Deep Taylor for interpretation\Deep-Taylor-Decomposition-master\main.py, line 41 def test(args): E fixture 'args' not found

  available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, record_xml_property, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
  use 'pytest --fixtures [testpath]' for help on them.

and then I look for the solutions on this and try to change the test function name from 'test' to 'tes' so as not to get confusion, and add '@pytest.fixture' before the 'def tes(args)', and run, but then I get the error like: 2020-09-15 09:13:16,838 [INFO] data loading (main.py:51) 2020-09-15 09:13:16,838 [ERROR] Testing is falied (main.py:176) Traceback (most recent call last): File "C:/Users/lin/Desktop/gradduate_design/Deep Taylor for interpretation/Deep-Taylor-Decomposition-master/main.py", line 174, in tes(args) File "C:\Users\lin\Anaconda3\lib\site-packages_pytest\fixtures.py", line 1009, in result return function(*args, **kwargs) File "C:/Users/lin/Desktop/gradduate_design/Deep Taylor for interpretation/Deep-Taylor-Decomposition-master/main.py", line 58, in tes transforms.ToTensor(), File "C:\Users\lin\Anaconda3\lib\site-packages\torchvision\datasets\folder.py", line 208, in init is_valid_file=is_valid_file) File "C:\Users\lin\Anaconda3\lib\site-packages\torchvision\datasets\folder.py", line 95, in init samples = make_dataset(self.root, class_to_idx, extensions, is_valid_file) File "C:\Users\lin\Anaconda3\lib\site-packages\torchvision\datasets\folder.py", line 36, in make_dataset directory = os.path.expanduser(directory) File "C:\Users\lin\Anaconda3\lib\ntpath.py", line 291, in expanduser path = os.fspath(path) TypeError: expected str, bytes or os.PathLike object, not NoneType

Anyway, I don't know how to right run your code, and I wanna use DTD to interpret my datasets! Expected to hear from the solutions as soon as possible!

DanielF29 commented 3 years ago

Note: I´m running windows 10, I used python 3.9.6 and used a virtual environment ( https://pypi.org/project/virtualenv/ ), which I don´t think is needed to run the repository but just in case I share that info. In my case: I downloaded the repository as a .zip, extracted it, created a folder in the main folder (in my case with the name "imgs") where I put a second folder containing the image to be analyzed. So, the location of the image was "imgs\images\myimage.png" within the main folder. Then, open a cmd window, located it in the main folder, and enter the command: python main.py --test_dir .\imgs

After a few seconds, that created as output the folder "saliency_map_sample" within which you could find the original image and the generated explanation.

Hope that could help. 👋

yuninn commented 1 year ago

Note: I´m running windows 10, I used python 3.9.6 and used a virtual environment ( https://pypi.org/project/virtualenv/ ), which I don´t think is needed to run the repository but just in case I share that info. In my case: I downloaded the repository as a .zip, extracted it, created a folder in the main folder (in my case with the name "imgs") where I put a second folder containing the image to be analyzed. So, the location of the image was "imgs\images\myimage.png" within the main folder. Then, open a cmd window, located it in the main folder, and enter the command: python main.py --test_dir .\imgs

After a few seconds, that created as output the folder "saliency_map_sample" within which you could find the original image and the generated explanation.

Hope that could help. 👋

There are many pictures in my folder, but I can only get one result at a time. How can I get the result of all pictures at once?