Esempio n. 1
0
def test_style_predict():
    from photonix.classifiers.style.model import StyleModel

    model = StyleModel()
    snow = str(Path(__file__).parent / 'photos' / 'snow.jpg')
    result = model.predict(snow)

    assert len(result) == 1
    assert result[0][0] == 'serene'
    assert '{0:.3f}'.format(result[0][1]) == '0.962'
Esempio n. 2
0
def test_downloading(tmpdir):
    from photonix.classifiers.style.model import StyleModel

    model_dir = tmpdir
    start = time.mktime(datetime.now().timetuple())
    model = StyleModel(lock_name=None, model_dir=model_dir)

    graph_path = str(Path(model_dir) / 'style' / 'graph.pb')
    assert os.stat(graph_path).st_size > 1024 * 10 * 10
    assert os.stat(graph_path).st_mtime > start
    with open(str(Path(model_dir) / 'style' / 'version.txt')) as f:
        content = f.read()
        assert content.strip() == str(model.version)
Esempio n. 3
0
def test_style_predict():
    from photonix.classifiers.style.model import StyleModel

    model = StyleModel()
    snow = str(Path(__file__).parent / 'photos' / 'snow.jpg')
    result = model.predict(snow)

    assert len(result) == 1
    assert result[0][0] == 'serene'
    assert '{0:.3f}'.format(result[0][1]) == '0.962'

    # Check that there is no error when running with non-RGB image
    cmyk = str(Path(__file__).parent / 'photos' / 'cmyk.tif')
    result = model.predict(cmyk)
    assert result == None