Exemplo n.º 1
0
def test_import_images_are_ordered_and_unduplicated():
    # we know that import_images returns images in path order
    imgs = list(mio.import_images(mio.data_dir_path()))
    imgs_filenames = [i.path.stem for i in imgs]
    print(imgs_filenames)
    exp_imgs_filenames = ['breakingbad', 'einstein', 'lenna', 'menpo_thumbnail', 'takeo', 'tongue']
    assert exp_imgs_filenames == imgs_filenames
Exemplo n.º 2
0
def test_import_lazy_list():
    from menpo.base import LazyList
    data_path = mio.data_dir_path()
    ll = mio.import_images(data_path)
    assert isinstance(ll, LazyList)
    ll = mio.import_landmark_files(data_path)
    assert isinstance(ll, LazyList)
Exemplo n.º 3
0
def test_ioinfo():
    # choose a random asset (all should have it!)
    img = pio.import_builtin_asset('einstein.jpg')
    path = pio.data_path_to('einstein.jpg')
    assert(img.ioinfo.filepath == path)
    assert(img.ioinfo.filename == 'einstein')
    assert(img.ioinfo.extension == '.jpg')
    assert(img.ioinfo.dir == pio.data_dir_path())
Exemplo n.º 4
0
def test_path():
    # choose a random asset (all should have it!)
    img = mio.import_builtin_asset('einstein.jpg')
    path = mio.data_path_to('einstein.jpg')
    assert(img.path == path)
    assert(img.path.stem == 'einstein')
    assert(img.path.suffix == '.jpg')
    assert(img.path.parent == mio.data_dir_path())
    assert(img.path.name == 'einstein.jpg')
Exemplo n.º 5
0
def test_import_images():
    imgs_glob = os.path.join(pio.data_dir_path(), '*')
    imgs = list(pio.import_images(imgs_glob))
    imgs_filenames = set(i.ioinfo.filename for i in imgs)
    exp_imgs_filenames = {'einstein', 'takeo', 'breakingbad', 'lenna'}
    assert(len(exp_imgs_filenames - imgs_filenames) == 0)
Exemplo n.º 6
0
def test_import_image_no_norm():
    img_path = os.path.join(mio.data_dir_path(), 'einstein.jpg')
    im = mio.import_image(img_path, normalise=False)
    assert im.pixels.dtype == np.uint8
Exemplo n.º 7
0
def test_import_images_zero_max_images():
    # different since the conditional 'if max_assets' is skipped,
    # thus all images might be imported.
    list(mio.import_images(mio.data_dir_path(), max_images=0))
Exemplo n.º 8
0
def test_image_paths():
    ls = mio.image_paths(os.path.join(mio.data_dir_path(), '*'))
    assert(len(ls) == 5)
Exemplo n.º 9
0
def test_import_images():
    imgs = list(mio.import_images(mio.data_dir_path()))
    imgs_filenames = set(i.path.stem for i in imgs)
    exp_imgs_filenames = {'einstein', 'takeo', 'breakingbad', 'lenna'}
    assert(len(exp_imgs_filenames - imgs_filenames) == 0)
Exemplo n.º 10
0
def test_import_images_zero_max_images():
    # different since the conditional 'if max_assets' is skipped,
    # thus all images might be imported.
    list(mio.import_images(mio.data_dir_path(), max_images=0))
Exemplo n.º 11
0
def test_image_paths():
    ls = mio.image_paths(mio.data_dir_path())
    assert (len(list(ls)) == 6)
Exemplo n.º 12
0
def test_shuffle_kwarg_true_calls_shuffle(mock):
    list(mio.import_images(mio.data_dir_path(), shuffle=True))
    assert mock.called
Exemplo n.º 13
0
def test_import_image():
    img_path = mio.data_dir_path() / 'einstein.jpg'
    im = mio.import_image(img_path)
    assert im.pixels.dtype == np.float
    assert im.n_channels == 1
Exemplo n.º 14
0
def test_import_landmark_file():
    lm_path = mio.data_dir_path() / 'einstein.pts'
    mio.import_landmark_file(lm_path)
Exemplo n.º 15
0
def test_import_landmark_file():
    lm_path = mio.data_dir_path() / 'einstein.pts'
    mio.import_landmark_file(lm_path)
Exemplo n.º 16
0
def test_import_image_no_norm():
    img_path = mio.data_dir_path() / 'einstein.jpg'
    im = mio.import_image(img_path, normalise=False)
    assert im.pixels.dtype == np.uint8
Exemplo n.º 17
0
def test_import_image():
    img_path = mio.data_dir_path() / 'einstein.jpg'
    im = mio.import_image(img_path)
    assert im.pixels.dtype == np.float
    assert im.n_channels == 1
Exemplo n.º 18
0
def test_import_as_generator():
    import types
    gen = mio.import_images(mio.data_dir_path(), as_generator=True)
    assert isinstance(gen, types.GeneratorType)
    gen = mio.import_landmark_files(mio.data_dir_path(), as_generator=True)
    assert isinstance(gen, types.GeneratorType)
Exemplo n.º 19
0
def test_shuffle_kwarg_true_calls_shuffle(mock):
    list(mio.import_images(mio.data_dir_path(), shuffle=True))
    assert mock.called
Exemplo n.º 20
0
def test_import_image_no_norm():
    img_path = mio.data_dir_path() / 'einstein.jpg'
    im = mio.import_image(img_path, normalize=False)
    assert im.pixels.dtype == np.uint8
Exemplo n.º 21
0
def test_import_landmark_file():
    lm_path = os.path.join(mio.data_dir_path(), 'einstein.pts')
    mio.import_landmark_file(lm_path)
Exemplo n.º 22
0
def test_import_images():
    imgs = list(mio.import_images(mio.data_dir_path()))
    imgs_filenames = set(i.path.stem for i in imgs)
    exp_imgs_filenames = {'einstein', 'takeo', 'tongue', 'breakingbad', 'lenna',
                          'menpo_thumbnail'}
    assert exp_imgs_filenames == imgs_filenames
Exemplo n.º 23
0
def test_import_image():
    img_path = os.path.join(mio.data_dir_path(), 'einstein.jpg')
    mio.import_images(img_path)
Exemplo n.º 24
0
def test_image_paths():
    ls = mio.image_paths(mio.data_dir_path())
    assert(len(list(ls)) == 6)
Exemplo n.º 25
0
def test_import_mesh():
    obj_path = os.path.join(mio.data_dir_path(), 'bunny.obj')
    mio.import_images(obj_path)
Exemplo n.º 26
0
def test_import_as_generator():
    import types
    gen = mio.import_images(mio.data_dir_path(), as_generator=True)
    assert isinstance(gen, types.GeneratorType)
    gen = mio.import_landmark_files(mio.data_dir_path(), as_generator=True)
    assert isinstance(gen, types.GeneratorType)
Exemplo n.º 27
0
def test_import_auto():
    assets_glob = os.path.join(mio.data_dir_path(), '*')
    assets = list(mio.import_auto(assets_glob))
    assert(len(assets) == 6)
Exemplo n.º 28
0
def test_import_images_negative_max_images():
    list(mio.import_images(mio.data_dir_path(), max_images=-2))
Exemplo n.º 29
0
def test_import_auto_max_meshes():
    assets_glob = os.path.join(mio.data_dir_path(), '*')
    assets = list(mio.import_auto(assets_glob, max_meshes=1))
    assert(sum([isinstance(x, TriMesh) for x in assets]) == 1)
Exemplo n.º 30
0
def test_mesh_paths():
    ls = mio.mesh_paths(os.path.join(mio.data_dir_path(), '*'))
    assert(len(ls) == 2)
Exemplo n.º 31
0
def test_import_images_negative_max_images():
    list(mio.import_images(mio.data_dir_path(), max_images=-2))