cfg = cfg_plate net = BaseModel(cfg=cfg, phase='test') else: print("Don't support network!") exit(0) net = load_model(net, args.trained_model, args.cpu) net.eval() print('Finished loading model!') print(net) from torchscope import scope scope(net, input_size=(3, 480, 850)) cudnn.benchmark = True device = torch.device("cpu" if args.cpu else "cuda") net = net.to(device) image_paths = get_image_path(args.image_path) _t = {'pre': Timer(), 'forward_pass': Timer(), 'misc': Timer()} # testing begin for path in image_paths: _t['pre'].tic() # path = "/home/can/AI_Camera/License_Plate/LP_Detection/data/val/images/40000/61539302914508AF4442_B.jpg_out-full_1.jpg" img_raw = cv2.imread(path, cv2.IMREAD_COLOR) h, w, _ = img_raw.shape img_raw = cv2.resize(img_raw, (int(w / 3), int(h / 3))) # cv2.imshow("test111", img_raw) # cv2.waitKey() img = np.float32(img_raw) # testing scale target_size = args.long_side
"/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_blur", "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_tilt", "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_db", "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_fn", "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_rotate", # "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_np", "/home/can/AI_Camera/Dataset/License_Plate/CCPD2019/ccpd_challenge" ] print("loading model") # Initialize model model = BaseModel(cfg=cfg_plate) checkpoint = torch.load(checkpoint_path, map_location='cuda') model.load_state_dict(checkpoint['state_dict']) del checkpoint model.eval() model.to(device) for i in np.linspace(0.5, 0.9, 8): print("############################") print("threshold: " + str(i)) for index, path in enumerate(img_dir): print("**************************") print(path) val_dataset = ChaLocDataLoader([path], imgSize=320) valid_loader = torch.utils.data.DataLoader( val_dataset, batch_size=256, shuffle=False, num_workers=6, collate_fn=detection_collate, pin_memory=True)