def main():
    dataset = ANI717Dataset(config.TEST_CSV, config.IMG_SOURCE, transforms=config.TEST_TRANSFORMS)
    loader = DataLoader(dataset, batch_size=1, shuffle=False)
    model = NvidiaNet(in_channels=config.IMG_SHAPE[0]).to(config.DEVICE)
    model.load_state_dict(torch.load(config.MODEL_FILE, map_location=config.DEVICE)['state_dict'])
    model.eval()
    num_correct = 0.0
    count = 0
    with torch.no_grad():
        loop = tqdm(loader, position=0, leave=True)
        for (batch_idx, (inputs, z, x)) in enumerate(loop):
            inputs = inputs.to(config.DEVICE)
            if (config.TRAIN_TYPE == 'z'):
                targets = z.unsqueeze(1).to(torch.float32).to(config.DEVICE)
            else:
                targets = x.unsqueeze(1).to(torch.float32).to(config.DEVICE)
            predictions = model(inputs)
            num_correct += sum((abs((torch.round((targets / config.ERROR_TOLERENCE)) - torch.round((predictions / config.ERROR_TOLERENCE)))) <= 1)).item()
            count += predictions.shape[0]
            loop.set_postfix(accuracy=((100 * num_correct) / count))
def main():
    dataset = ANI717Dataset(config.TEST_CSV, config.IMG_SOURCE, transforms=config.TEST_TRANSFORMS)
    loader = DataLoader(dataset, batch_size=1, shuffle=False)
    model = NvidiaNet(in_channels=config.IMG_SHAPE[0]).to(config.DEVICE)
    model.load_state_dict(torch.load(config.MODEL_FILE, map_location=config.DEVICE)['state_dict'])
    model.eval()
    num_correct = 0.0
    count = 0
    with torch.no_grad():
        loop = tqdm(loader, position=0, leave=True)
        for (batch_idx, (inputs, z, x)) in enumerate(loop):
            inputs = inputs.to(config.DEVICE)
            if (config.TRAIN_TYPE == 'z'):
                targets = z.unsqueeze(1).to(torch.float32).to(config.DEVICE)
            else:
                targets = x.unsqueeze(1).to(torch.float32).to(config.DEVICE)
            predictions = model(inputs)
            num_correct += sum((abs((torch.round((targets / config.ERROR_TOLERENCE)) - torch.round((predictions / config.ERROR_TOLERENCE)))) <= 1)).item()
            count += predictions.shape[0]
            loop.set_postfix(accuracy=((100 * num_correct) / count))