diff --git a/image_ref/config.py b/image_ref/config.py index bbb1353005340adf9f20c153e74eaa2b955a4d0b..aac9449d288fb1a668c82291ad996c39ec5665bc 100644 --- a/image_ref/config.py +++ b/image_ref/config.py @@ -17,7 +17,7 @@ def load_args_contrastive(): parser.add_argument('--dataset_ref_dir', type=str, default='image_ref/img_ref') parser.add_argument('--output', type=str, default='output/out_contrastive.csv') parser.add_argument('--save_path', type=str, default='output/best_model_constrastive.pt') - parser.add_argument('--pretrain_path', type=str, default='saved_model/baseline_resnet18_contrastive_prop_30_bis.pt') + parser.add_argument('--pretrain_path', type=str, default=None) args = parser.parse_args() return args \ No newline at end of file diff --git a/image_ref/grad_cam.py b/image_ref/grad_cam.py index f861358260c5b049ca2b94d25dd520bd50987a4f..091753e669109e76ef24628d48a0d7ab0f600ac6 100644 --- a/image_ref/grad_cam.py +++ b/image_ref/grad_cam.py @@ -22,12 +22,13 @@ def compute_class_activation_map(): [transforms.Resize((224, 224)), transforms.Normalize(0.5, 0.5)]) + model_path = '../saved_model/baseline_resnet18_contrastive_prop_30_bis.pt' path_aer ='../data/processed_data/npy_image/data_test_contrastive/Citrobacter freundii/CITFRE17_AER.npy' path_ana ='../data/processed_data/npy_image/data_test_contrastive/Citrobacter freundii/CITFRE17_ANA.npy' - path_ref ='../image_ref/img_ref/Citrobacter freundii.npy' #positive + # path_ref ='../image_ref/img_ref/Citrobacter freundii.npy' #positive # path_ref = '../image_ref/img_ref/Enterobacter hormaechei.npy' #negative - # path_ref = '../image_ref/img_ref/Proteus mirabilis.npy' # negative + path_ref = '../image_ref/img_ref/Proteus mirabilis.npy' # negative tensor_aer = npy_loader(path_aer) tensor_ana = npy_loader(path_ana) tensor_ref = npy_loader(path_ref) @@ -47,7 +48,7 @@ def compute_class_activation_map(): model.double() # load weight if args.pretrain_path is not None: - load_model(model, args.pretrain_path) + load_model(model, model_path) print('model loaded') # Identify the target layer diff --git a/image_ref/main.py b/image_ref/main.py index 017daeca73499f4ec29b7d2329b17c393f0ee41f..246df8861c5ad6abe6d27078ce83c30dd4ac9d29 100644 --- a/image_ref/main.py +++ b/image_ref/main.py @@ -85,7 +85,7 @@ def run_duo(args): load_model(model,args.pretrain_path) #move parameters to GPU if torch.cuda.is_available(): - print('model loaded on GPU') + print('Model loaded on GPU') model = model.cuda() #init accumulators