Exemple #1
0
def test_setup():
    global mandrill, mandrill_t, rowdfilt, tf
    tf = import_module('tensorflow')
    lowlevel = import_module('dtcwt.tf.lowlevel')
    rowdfilt = getattr(lowlevel, 'rowdfilt')
    mandrill = datasets.mandrill()
    mandrill_t = tf.expand_dims(tf.constant(mandrill, dtype=tf.float32),axis=0)
Exemple #2
0
def test_setup():
    global mandrill, mandrill_t, tf, colfilter
    tf = import_module('tensorflow')
    lowlevel = import_module('dtcwt.tf.lowlevel')
    colfilter = getattr(lowlevel, 'colfilter')

    mandrill = datasets.mandrill()
    mandrill_t = tf.expand_dims(tf.constant(mandrill, dtype=tf.float32),axis=0)
Exemple #3
0
def setup():
    global mandrill
    mandrill = datasets.mandrill()

    global qbgn
    qbgn = np.load(os.path.join(os.path.dirname(__file__), 'qbgn.npz'))['qbgn']

    global verif
    verif = np.load(os.path.join(os.path.dirname(__file__), 'verification.npz'))
Exemple #4
0
def setup():
    global mandrill
    mandrill = datasets.mandrill()

    global qbgn
    qbgn = np.load(os.path.join(os.path.dirname(__file__), 'qbgn.npz'))['qbgn']

    global verif
    verif = np.load(os.path.join(os.path.dirname(__file__),
                                 'verification.npz'))
Exemple #5
0
def setup():
    global mandrill, in_p, pyramid_ops
    global tf, Transform1d, dtwavexfm2, dtwaveifm2, Pyramid_tf
    global np_dtypes, tf_dtypes, stats
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt_tf = import_module('dtcwt.tf')
    dtcwt_tf_xfm1 = import_module('dtcwt.tf.transform1d')
    Transform1d = getattr(dtcwt_tf, 'Transform1d')
    Pyramid_tf = getattr(dtcwt_tf, 'Pyramid')
    np_dtypes = getattr(dtcwt_tf_xfm1, 'np_dtypes')
    tf_dtypes = getattr(dtcwt_tf_xfm1, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
    dtcwt.push_backend('tf')
def setup():
    global mandrill, in_p, pyramid_ops
    global tf, Transform1d, dtwavexfm2, dtwaveifm2, Pyramid_tf
    global np_dtypes, tf_dtypes, stats
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt_tf = import_module('dtcwt.tf')
    dtcwt_tf_xfm1 = import_module('dtcwt.tf.transform1d')
    Transform1d = getattr(dtcwt_tf, 'Transform1d')
    Pyramid_tf = getattr(dtcwt_tf, 'Pyramid')
    np_dtypes = getattr(dtcwt_tf_xfm1, 'np_dtypes')
    tf_dtypes = getattr(dtcwt_tf_xfm1, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
    dtcwt.push_backend('tf')
def setup():
    # Import some tf only dependencies
    global mandrill, Transform2d, Pyramid
    global tf, np_dtypes, tf_dtypes, dtwavexfm2, dtwaveifm2
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt.push_backend('tf')
    Transform2d = getattr(dtcwt, 'Transform2d')
    Pyramid = getattr(dtcwt, 'Pyramid')
    compat = import_module('dtcwt.compat')
    dtwavexfm2 = getattr(compat, 'dtwavexfm2')
    dtwaveifm2 = getattr(compat, 'dtwaveifm2')
    import dtcwt.tf.transform2d as transform2d
    np_dtypes = getattr(transform2d, 'np_dtypes')
    tf_dtypes = getattr(transform2d, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
Exemple #8
0
def setup():
    global mandrill
    mandrill = datasets.mandrill()
Exemple #9
0
def setup():
    global mandrill, mandrill_crop
    mandrill = datasets.mandrill().astype(np.float64)
    mandrill_crop = mandrill[:233, :301]
Exemple #10
0
def setup():
    global mandrill
    mandrill = datasets.mandrill()
    assert x.dtype in tf_dtypes
    xfm = Transform2d()
    X = np.random.randn(5,100,100,4)
    p = xfm.forward_channels(X,data_format="nhwc")
    x = xfm.inverse_channels(p,data_format="nhwc")
    assert x.dtype in np_dtypes
    xfm = Transform2d()
    X = tf.placeholder(tf.float32, [None, 100,100,4])
    p = xfm.forward_channels(X,data_format="nhwc")
    x = xfm.inverse_channels(p,data_format="nhwc")
    assert x.dtype in tf_dtypes


@skip_if_no_tf
@pytest.mark.parametrize("test_input,biort,qshift", [
    (datasets.mandrill(),'antonini','qshift_a'),
    (datasets.mandrill()[100:400,40:450],'legall','qshift_a'),
    (datasets.mandrill(),'near_sym_a','qshift_c'),
    (datasets.mandrill()[100:375,30:322],'near_sym_b','qshift_d'),
    (datasets.mandrill(),'near_sym_b_bp', 'qshift_b_bp')
])
def test_results_match(test_input, biort, qshift):
    """
    Compare forward transform with numpy forward transform for mandrill image
    """
    im = test_input
    f_np = Transform2d_np(biort=biort,qshift=qshift)
    p_np = f_np.forward(im, include_scale=True)

    f_tf = Transform2d(biort=biort,qshift=qshift)
    p_tf = f_tf.forward(im, include_scale=True)
Exemple #12
0
    p = xfm.forward(X)
    x = xfm.inverse(p)
    assert x.dtype in tf_dtypes
    X = np.random.randn(5,100,100)
    p = xfm.forward_channels(X)
    x = xfm.inverse_channels(p)
    assert x.dtype in np_dtypes
    X = tf.placeholder(tf.float32, [None, 100,100])
    p = xfm.forward_channels(X)
    x = xfm.inverse_channels(p)
    assert x.dtype in tf_dtypes


@skip_if_no_tf
@pytest.mark.parametrize("test_input,biort,qshift", [
    (datasets.mandrill(),'antonini','qshift_a'),
    (datasets.mandrill()[100:400,40:450],'legall','qshift_a'),
    (datasets.mandrill(),'near_sym_a','qshift_c'),
    (datasets.mandrill()[100:374,30:322],'near_sym_b','qshift_d'),
])
def test_results_match(test_input, biort, qshift):
    """
    Compare forward transform with numpy forward transform for mandrill image
    """
    im = test_input
    f_np = Transform1d_np(biort=biort,qshift=qshift)
    p_np = f_np.forward(im, include_scale=True)

    f_tf = Transform1d(biort=biort,qshift=qshift)
    p_tf = f_tf.forward(im, include_scale=True)
Exemple #13
0
def setup():
    global mandrill, mandrill_crop
    mandrill = datasets.mandrill().astype(np.float64)
    mandrill_crop = mandrill[:233, :301]