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) config_file_1 = '/home/shanwei-luo/userdata/mmdetection/work_dirs/AD_dsxw_test70/AD_dsxw_test70.py' checkpoint_file_1 = '/home/shanwei-luo/userdata/mmdetection/work_dirs/AD_dsxw_test70/epoch_38.pth' img_path = '/home/shanwei-luo/userdata/datasets/PCBA_dataset_v15_MLOPS/ok/' dis_path1 = '/home/shanwei-luo/userdata/datasets/PCBA_dataset_v15_MLOPS/ok_score/' dis_path2 = '/home/shanwei-luo/userdata/datasets/PCBA_dataset_v15_MLOPS/v1/dsxw_train/images/' 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 = [] step = 128 while index=score_thr-score_thr*k_v and i[j, 4]<=score_thr+(1-score_thr)*k_v: hard = 1''' if i[j, 4]>=k_v: hard = 1 if hard==1: count+=1 #print(img_path+imgs[index], dis_path1+imgs[index]) #shutil.copy(img_path+imgs[index], dis_path1+imgs[index]) #shutil.copy(img_path+imgs[index], dis_path2+imgs[index]) index += 1 print(k_v, count) np_result = np.load('/home/shanwei-luo/userdata/datasets/PCBA_dataset_v15_MLOPS/result.npy') result_score = np_result.tolist() for k_v in np.arange(0.5, 1, 0.05): count = 0 index = 0 for result in result_score: if result>=k_v: count +=1 index += 1 print(k_v, count)