def basic_checks(input_images,
                 input_flows,
                 images_order='HWC',
                 flows_order='HWC',
                 fp16=False,
                 device='cpu',
                 tolerance=1e-8):
    tt = ToTensor(images_order, flows_order, fp16, device)
    images, flows = tt(input_images, input_flows)
    assert isinstance(images, torch.Tensor)
    assert isinstance(flows, torch.Tensor)
    assert images.shape == torch.Size(
        [NUM_IMAGES, 3, IMAGE_HEIGHT, IMAGE_WIDTH])
    assert flows.shape == torch.Size(
        [NUM_IMAGES - 1, 2, IMAGE_HEIGHT, IMAGE_WIDTH])

    input_images = np.stack(input_images, axis=0)
    input_flows = np.stack(input_flows, axis=0)
    if images_order == 'CHW':
        input_images = input_images.transpose(0, 2, 3, 1)
    if flows_order == 'CHW':
        input_flows = input_flows.transpose(0, 2, 3, 1)
    images = images.detach().cpu().numpy().transpose(0, 2, 3, 1)
    flows = flows.detach().cpu().numpy().transpose(0, 2, 3, 1)
    assert np.allclose(images, input_images, atol=tolerance)
    assert np.allclose(flows, input_flows, atol=tolerance)
Пример #2
0
def get_tensor_data(images_list, flows_list):
    tt = ToTensor()
    images, flows = tt(images_list, flows_list)
    return images, flows