# dataset_test = dset.ImageFolder(root=os.path.join(opt.dataset, opt.test_set), transform=transform_fwd) # assert dataset_test # dataloader_test = torch.utils.data.DataLoader(dataset_test, batch_size=opt.batchSize, shuffle=False, num_workers=int(opt.workers)) # dataloaders = {} # for name in ['train', 'test']: # raw_data = pandas.read_csv(os.path.join(opt.dataset, '%s.csv' % name)) # dataloaders[name] = DataLoader(FrameDataset(raw_data.to_numpy()), **config.dataset_params) raw_data = pandas.read_csv(os.path.join(opt.dataset, 'test.csv')) dataloader_test = DataLoader(FrameDataset(raw_data.to_numpy()), batch_size=opt.batchSize, shuffle=True, num_workers=4, pin_memory=False) vgg_ext = model_big.VggExtractor() capnet = model_big.CapsuleNet(2, opt.gpu_id) capnet.load_state_dict(torch.load(os.path.join(opt.outf))) capnet.eval() if opt.gpu_id >= 0: vgg_ext.cuda(opt.gpu_id) capnet.cuda(opt.gpu_id) ################################################################################## tol_label = np.array([], dtype=np.float) tol_pred = np.array([], dtype=np.float) tol_pred_prob = np.array([], dtype=np.float) count = 0
print(path) print('Number of files: %d' % (length)) print('Number of videos: %d' % (count_vid)) print('Number of correct classifications: %d' % (correct)) return count_vid, correct if __name__ == '__main__': path_real = os.path.join(opt.dataset, opt.real) path_deepfakes = os.path.join(opt.dataset, opt.deepfakes) path_face2face = os.path.join(opt.dataset, opt.face2face) path_faceswap = os.path.join(opt.dataset, opt.faceswap) vgg_ext = model_big.VggExtractor() model = model_big.CapsuleNet(4, opt.gpu_id) model.load_state_dict( torch.load(os.path.join(opt.outf, 'capsule_' + str(opt.id) + '.pt'))) model.eval() if opt.gpu_id >= 0: vgg_ext.cuda(opt.gpu_id) model.cuda(opt.gpu_id) ################################################################### tol_count_vid_real = 0 tol_correct_real = 0 tol_count_vid_deepfakes = 0 tol_correct_deepfakes = 0