EVMET.Architecture( models.resnet50(pretrained=True).eval(), 'resnet50', 'layer4'), 'vgg16': EVMET.Architecture( models.vgg16(pretrained=True).eval(), 'vgg16', 'features_29') } arch = arch_dict[arch_name] #arch=EVMET.Architecture(models.resnet101(pretrained=True).eval(),'resnet101','layer4') #arch=EVMET.Architecture(models.resnet152(pretrained=True).eval(),'resnet152','layer4') #arch=EVMET.Architecture(models.vgg16(pretrained=True).eval(),'vgg16','features_29') metrics_dict = { 'average_drop': ADIC.AverageDrop('average_drop', arch), 'average_increase': ADIC.IncreaseInConfidence('average_increase', arch), 'increase_in_confidence': ADIC.IncreaseInConfidence('increase_in_confidence', arch), 'deletion': DAI.Deletion('deletion', arch), 'insertion': DAI.Insertion('insertion', arch), 'average_complexity': COMPLEXITY.Complexity('Average complexity', arch), 'average_coherency': COHERENCY.Coherency('Average coherency', arch), 'average_score_variance': ASV.AverageScoreVariance('Average score variance', arch) } metrics = {m: metrics_dict[m] for m in metric_names}
with open('filter.txt', 'r') as f: txt = f.read() img_list = [p.split()[0] for p in txt.strip().split('\n')[base:base + window]] img_list = {get_num_img(p.split()[0]): p.split()[0] for p in img_list} try: os.mkdir(f'{outpath_root}filter/') except: pass #arch=EVMET.Architecture(models.resnet18(pretrained=True).eval(),'resnet18','layer4') arch = EVMET.Architecture( models.vgg16(pretrained=True).eval(), 'vgg16', 'features_29') avg_drop = ADIC.AverageDrop('average_drop', arch) inc_conf = ADIC.IncreaseInConfidence('increase_in_confidence', arch) deletion = DAI.Deletion('deletion', arch) insertion = DAI.Insertion('insertion', arch) img_dict = IMUT.IMG_list(path=p, outpath_root='out/filter/', GT=GT, labs=labs).select_imgs(img_list) em = EVMET.MetricsEvaluator(img_dict, saliency_map_extractor=run, model=arch, metrics=[avg_drop, inc_conf, deletion, insertion]) start = time.time() now = start path0 = img_dict.get_outpath_root() conv_layer = arch.layer #MODEL_CONFIG[arch.name]['conv_layer']