Esempio 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
Esempio 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)
Esempio 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())
Esempio 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')
Esempio 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)
Esempio 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
Esempio 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))
Esempio n. 8
0
def test_image_paths():
    ls = mio.image_paths(os.path.join(mio.data_dir_path(), '*'))
    assert(len(ls) == 5)
Esempio 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)
Esempio 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))
Esempio n. 11
0
def test_image_paths():
    ls = mio.image_paths(mio.data_dir_path())
    assert (len(list(ls)) == 6)
Esempio n. 12
0
def test_shuffle_kwarg_true_calls_shuffle(mock):
    list(mio.import_images(mio.data_dir_path(), shuffle=True))
    assert mock.called
Esempio 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
Esempio n. 14
0
def test_import_landmark_file():
    lm_path = mio.data_dir_path() / 'einstein.pts'
    mio.import_landmark_file(lm_path)
Esempio n. 15
0
def test_import_landmark_file():
    lm_path = mio.data_dir_path() / 'einstein.pts'
    mio.import_landmark_file(lm_path)
Esempio 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
Esempio 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
Esempio 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)
Esempio n. 19
0
def test_shuffle_kwarg_true_calls_shuffle(mock):
    list(mio.import_images(mio.data_dir_path(), shuffle=True))
    assert mock.called
Esempio 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
Esempio 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)
Esempio 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
Esempio n. 23
0
def test_import_image():
    img_path = os.path.join(mio.data_dir_path(), 'einstein.jpg')
    mio.import_images(img_path)
Esempio n. 24
0
def test_image_paths():
    ls = mio.image_paths(mio.data_dir_path())
    assert(len(list(ls)) == 6)
Esempio n. 25
0
def test_import_mesh():
    obj_path = os.path.join(mio.data_dir_path(), 'bunny.obj')
    mio.import_images(obj_path)
Esempio 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)
Esempio 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)
Esempio n. 28
0
def test_import_images_negative_max_images():
    list(mio.import_images(mio.data_dir_path(), max_images=-2))
Esempio 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)
Esempio n. 30
0
def test_mesh_paths():
    ls = mio.mesh_paths(os.path.join(mio.data_dir_path(), '*'))
    assert(len(ls) == 2)
Esempio n. 31
0
def test_import_images_negative_max_images():
    list(mio.import_images(mio.data_dir_path(), max_images=-2))