Ejemplo n.º 1
0
def test_video_predict():
    model = ResNet50(weights='imagenet')
    x = video_io.VideoDataset(video_path).batch(1).map(
        lambda x: preprocess_input(image.resize(x, (224, 224))))
    y = model.predict(x)
    p = decode_predictions(y, top=1)
    assert len(p) == 166
Ejemplo n.º 2
0
def test_video_dataset():
    """test_video_dataset"""
    num_repeats = 2

    video_dataset = video_io.VideoDataset([video_path]).repeat(num_repeats)

    i = 0
    for v in video_dataset:
        assert v.shape == (320, 560, 3)
        i += 1
    assert i == 166 * num_repeats
Ejemplo n.º 3
0
def test_video_dataset():
    num_repeats = 2

    dataset = video_io.VideoDataset([video_path]).repeat(num_repeats)
    iterator = dataset.make_initializable_iterator()
    init_op = iterator.initializer
    get_next = iterator.get_next()

    with tensorflow.compat.v1.Session() as sess:
        sess.run(init_op)
        for _ in range(num_repeats):
            for _ in range(166):
                v = sess.run(get_next)
                assert v.shape == (320, 560, 3)
        with pytest.raises(errors.OutOfRangeError):
            sess.run(get_next)