import sys import os import random import numpy as np import shutil sys.path.append("/home/shanwei-luo/userdata/mmdetection") from mmdet.apis import (async_inference_detector, inference_detector, init_detector, show_result_pyplot) import argparse import pandas as pd #python get_score_csv.py --config_file /home/shanwei-luo/teamdata/anomaly_detection_active_learning/model/work_dirs/AD_dsxw_test66_06_10/AD_dsxw_test66_06_10.py --checkpoint_file /home/shanwei-luo/teamdata/anomaly_detection_active_learning/model/work_dirs/AD_dsxw_test66_06_10/latest.pth --images_path /home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/unlabel_11_12/images/ --test_batch_size 128 --result_path test_unlabel_11_12.csv def parse_args(): parser = argparse.ArgumentParser(description='get best threshold') parser.add_argument('--config_file', help='config') parser.add_argument('--checkpoint_file', help='checkpoint') parser.add_argument('--images_path', help='images') parser.add_argument('--test_batch_size', help='images') parser.add_argument('--result_path', help='result_path') args = parser.parse_args() return args args = parse_args() config_file_1 = args.config_file checkpoint_file_1 = args.checkpoint_file img_path = args.images_path model_1 = init_detector(config_file_1, checkpoint_file_1, device='cuda:0') imgs = os.listdir(img_path) imgs_name = [] for img in imgs: imgs_name.append(img_path+img) print(len(imgs_name)) print("before infer") index = 0 num = len(imgs_name) results_1 = [] results_feat = [] step = int(args.test_batch_size) while index