woshixuhao / semantic-explainable-AI

The codes and dataset for the semantic explainable AI (S-XAI)
14 stars 4 forks source link

No such file or directory: 'lime_save/lime_cat_500_324.npy' #3

Open AlphaGoooo opened 1 year ago

AlphaGoooo commented 1 year ago

您好,我是研一科研小白。在运行完CNN_training.py之后,运行GA.py时报错:FileNotFoundError: [Errno 2] No such file or directory: 'lime_save/lime_cat_500_324.npy' 请问这个是什么原因呢,要怎么解决呀?谢谢

woshixuhao commented 1 year ago

是不是没有先建个叫lime_save的文件夹? Do you first create a folder called lime_save

AlphaGoooo commented 1 year ago

是不是没有先建个叫lime_save的文件夹? Do you first create a folder called lime_save

您好,我试着您的方法在项目下创建了lime_save的文件夹,然后重新跑了一遍GA.py,跑完500张图之后还是说No such file or directory,有点迷茫了... 1 2

woshixuhao commented 1 year ago

Lime=lime_GA(config)

Lime.GA()

delete the # of these two rows to activate the code and generate the file

AlphaGoooo commented 1 year ago

Lime=lime_GA(config) #Lime.GA() delete the # of these two rows to activate the code and generate the file

谢谢您的回复,不过我已经把两个#都删了,不然那500张图片的best fiteness也跑不出来,就是说现在我是删了#也创建了文件夹,但还是报这个错,还有什么可能是我没注意的吗,然后我也再仔细看看,麻烦了

woshixuhao commented 1 year ago

看一下第234,235行,你运行完Lime.GA()应该会保存文件, np.save(f'limesave/lime{self.animal}_{self.picturenum}{config.torch_seed}.npy',image_best_save) np.save(f'limesave/lime{self.animal}_{self.picture_num}origin{config.torch_seed}.npy',image_origin_save) 你根据你在parse里面设置的animal,picture_num和torch_seed改一下第239行的那个文件名就行。 或者把239改成: image_best_save=torch.from_numpy(np.load(f'limesave/lime{self.animal}_{self.picturenum}{config.torch_seed}.npy').astype(np.float32)) image_origin_save=torch.from_numpy(np.load(f'limesave/lime{self.animal}_{self.picture_num}origin{config.torch_seed}.npy').astype(np.float32))

woshixuhao commented 1 year ago

注意我源程序的animial给的是dog,所以你应该所产生的是lime_dog_500_324,改一下parse_args里面的animal变成cat就行

AlphaGoooo commented 1 year ago

感谢感谢,这里已经搞定了