cfg.AVD_ROOT_DIR, cfg.TEST_LIST, test_ids, max_difficulty=cfg.MAX_OBJ_DIFFICULTY, fraction_of_no_box=cfg.TEST_FRACTION_OF_NO_BOX_IMAGES) #create train/test loaders, with CUSTOM COLLATE function testloader = torch.utils.data.DataLoader(testset, batch_size=1, shuffle=True, num_workers=cfg.NUM_WORKERS, collate_fn=AVD.collate) # load net print('Loading ' + cfg.FULL_MODEL_LOAD_NAME + ' ...') net = TDID(cfg) load_net(cfg.FULL_MODEL_LOAD_DIR + cfg.FULL_MODEL_LOAD_NAME, net) net.features.eval() #freeze batchnorms layers? print('load model successfully!') net.cuda() net.eval() # evaluation test_net(cfg.MODEL_BASE_SAVE_NAME, net, testloader, target_images, test_ids, cfg, max_dets_per_target=cfg.MAX_DETS_PER_TARGET,
max_difficulty=cfg.MAX_OBJ_DIFFICULTY, fraction_of_no_box=cfg.FRACTION_OF_NO_BOX_IMAGES) valset = get_AVD_dataset(cfg.AVD_ROOT_DIR, cfg.VAL_LIST, val_ids, max_difficulty=cfg.MAX_OBJ_DIFFICULTY, fraction_of_no_box=cfg.VAL_FRACTION_OF_NO_BOX_IMAGES) trainloader = torch.utils.data.DataLoader(train_set, batch_size=cfg.BATCH_SIZE, shuffle=True, num_workers=cfg.NUM_WORKERS, collate_fn=AVD.collate) print('Loading network...') net = TDID(cfg) if cfg.LOAD_FULL_MODEL: load_net(cfg.FULL_MODEL_LOAD_DIR + cfg.FULL_MODEL_LOAD_NAME, net) else: weights_normal_init(net, dev=0.01) if cfg.USE_PRETRAINED_WEIGHTS: net.features = load_pretrained_weights(cfg.FEATURE_NET_NAME) net.features.eval() #freeze batchnorms layers? if not os.path.exists(cfg.SNAPSHOT_SAVE_DIR): os.makedirs(cfg.SNAPSHOT_SAVE_DIR) if not os.path.exists(cfg.META_SAVE_DIR): os.makedirs(cfg.META_SAVE_DIR) #put net on gpu net.cuda()
bbox = [int(data[1]), int(data[2]), int(data[3]), int(data[4]), 1] target1 = cv2.resize(pre_load_target_1, (80, 80), interpolation=cv2.INTER_AREA) target2 = cv2.resize(pre_load_target_2, (80, 80), interpolation=cv2.INTER_AREA) return image, bbox, target1, target2 # load config cfg_file = "configAVD1" cfg = importlib.import_module('configs.' + cfg_file) cfg = cfg.get_config() print('Loading network...') net = TDID(cfg) if cfg.LOAD_FULL_MODEL: load_net(cfg.FULL_MODEL_LOAD_DIR + cfg.FULL_MODEL_LOAD_NAME, net) else: weights_normal_init(net, dev=0.01) if cfg.USE_PRETRAINED_WEIGHTS: net.features = load_pretrained_weights(cfg.FEATURE_NET_NAME) net.features.eval() #freeze batchnorms layers? if not os.path.exists(cfg.SNAPSHOT_SAVE_DIR): os.makedirs(cfg.SNAPSHOT_SAVE_DIR) if not os.path.exists(cfg.META_SAVE_DIR): os.makedirs(cfg.META_SAVE_DIR) #put net on gpu net.cuda()