def _numpy_array_to_pil_image(x):
    """
    convert x of shape (1, 3, H, W) to PIL image
    """
    assert len(x.shape) == 4
    assert list(x.shape[:2]) == [1, 3]
    x = x[0, :, :, :]  # (3, H, W)
    x = _np.transpose(x, [1, 2, 0])  # (H, W, 3)
    x = x.astype(_np.uint8)
    return PIL.Image.fromarray(x)

    convert x of shape (1, 3, H, W) to PIL image
    
coremltools/converters/mil/test_inputs_outputs_shape.py