예제 #1
0
def load_faceboxes():
    """
    Load FaceBoxes model and weight in pytorch
    """
    print('---------------------------------------------------')
    pretrained_path = 'weights/FaceBoxes.pth'
    net = FaceBoxes(phase='test', size=None,
                    num_classes=2)  # initialize detector
    net = load_model(net, pretrained_path)
    net.eval()
    print('Finished loading model')
    print('---------------------------------------------------')
    return net.cpu()
예제 #2
0
    model.load_state_dict(pretrained_dict, strict=False)
    return model


if __name__ == '__main__':
    # net and model
    net = FaceBoxes(phase='test', size=None, num_classes=2)    # initialize detector
    net = load_model(net, args.trained_model)
    net.eval()
    print('Finished loading model!')
    print(net)
    if args.cuda:
        net = net.cuda()
        cudnn.benchmark = True
    else:
        net = net.cpu()

    # save file
    if not os.path.exists(args.save_folder):
        os.makedirs(args.save_folder)
    fw = open(os.path.join(args.save_folder, args.dataset + '_dets.txt'), 'w')

    # testing dataset
    testset_folder = os.path.join('data', args.dataset, 'images/')
    testset_list = os.path.join('data', args.dataset, 'img_list.txt')
    with open(testset_list, 'r') as fr:
        test_dataset = fr.read().split()
    num_images = len(test_dataset)

    # testing scale
    if args.dataset == "FDDB":