-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from metal3d/v1.0.12
v1.0.12
- Loading branch information
Showing
12 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
nose | ||
coverage | ||
tensorflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
""" | ||
|
||
__version__ = "1.0.11" | ||
__version__ = "1.0.12" | ||
|
||
from . import flow | ||
from . import generator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
import keras_video | ||
import unittest | ||
import os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import keras_video | ||
import keras | ||
import unittest | ||
import os | ||
import sys | ||
import shutil | ||
sys.path.insert(0, './src') | ||
|
||
|
||
class TestOpticalFlow(unittest.TestCase): | ||
|
||
testdir = 'test_vids' | ||
|
||
def setUp(self): | ||
dirname = self.testdir | ||
os.makedirs(dirname) | ||
|
||
def _write_zero(cl, i): | ||
shutil.copy( | ||
'tests/vidtest.ogv', | ||
os.path.join(self.testdir, '%s_%d.ogv' % (cl, i)) | ||
) | ||
|
||
for i in range(10): | ||
for cl in ['A', 'B', 'C']: | ||
_write_zero(cl, i) | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.testdir) | ||
|
||
def test_init(self): | ||
""" Check opticalflow init """ | ||
gen = keras_video.OpticalFlowGenerator( | ||
glob_pattern=os.path.join(self.testdir, '{classname}_*.ogv') | ||
) | ||
assert len(gen.classes) == 3 | ||
assert gen.files_count == 30 | ||
|
||
def __get_with_method(self, method=keras_video.METHOD_ABS_DIFF): | ||
tr = keras.preprocessing.image.ImageDataGenerator(rotation_range=10) | ||
|
||
gen = keras_video.OpticalFlowGenerator( | ||
method=method, | ||
glob_pattern=os.path.join(self.testdir, '{classname}_*.ogv'), | ||
transformation=tr | ||
) | ||
|
||
seq, labels = next(gen) | ||
assert seq.shape == (16, 5, 224, 224, 3) | ||
assert labels.shape == (16, 3) | ||
|
||
def test_absdiff(self): | ||
""" Check absdiff """ | ||
self.__get_with_method(keras_video.METHOD_ABS_DIFF) | ||
|
||
def test_absdiffmask(self): | ||
""" Check absdiff masked """ | ||
self.__get_with_method(keras_video.METHOD_DIFF_MASK) | ||
|
||
def test_opticalflow(self): | ||
""" Check opticalflow""" | ||
self.__get_with_method(keras_video.METHOD_OPTICAL_FLOW) | ||
|
||
def test_opticalflowmask(self): | ||
""" Check opticalflow masked """ | ||
self.__get_with_method(keras_video.METHOD_FLOW_MASK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import keras_video | ||
import keras | ||
import unittest | ||
import os | ||
import sys | ||
import shutil | ||
sys.path.insert(0, './src') | ||
|
||
|
||
class TestSlinding(unittest.TestCase): | ||
|
||
testdir = 'test_vids' | ||
|
||
def setUp(self): | ||
dirname = self.testdir | ||
os.makedirs(dirname) | ||
|
||
def _write_zero(cl, i): | ||
shutil.copy( | ||
'tests/vidtest.ogv', | ||
os.path.join(self.testdir, '%s_%d.ogv' % (cl, i)) | ||
) | ||
|
||
for i in range(10): | ||
for cl in ['A', 'B', 'C']: | ||
_write_zero(cl, i) | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.testdir) | ||
|
||
def test_init(self): | ||
""" Check if slinding generator init """ | ||
g = keras_video.SlidingFrameGenerator( | ||
glob_pattern=os.path.join(self.testdir, '{classname}_*.ogv')) | ||
assert 'A' in g.classes | ||
assert 'B' in g.classes | ||
assert 'C' in g.classes | ||
|
||
assert g.files_count == 30 | ||
|
||
# check get item | ||
seq, labels = next(g) | ||
assert seq.shape == (16, 5, 224, 224, 3) | ||
assert labels.shape == (16, 3) | ||
|
||
def test_with_transformation(self): | ||
""" Check if transformation works with slinding frame generator """ | ||
tr = keras.preprocessing.image.ImageDataGenerator(rotation_range=10) | ||
g = keras_video.SlidingFrameGenerator( | ||
transformation=tr, | ||
glob_pattern=os.path.join(self.testdir, '{classname}_*.ogv')) | ||
|
||
# check get item | ||
seq, labels = next(g) | ||
assert seq.shape == (16, 5, 224, 224, 3) | ||
assert labels.shape == (16, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import keras_video | ||
import unittest | ||
import os | ||
import sys | ||
import shutil | ||
sys.path.insert(0, './src') | ||
|
||
|
||
class TestSplit(unittest.TestCase): | ||
|
||
testdir = 'test_vids' | ||
|
||
def setUp(self): | ||
dirname = self.testdir | ||
os.makedirs(dirname) | ||
|
||
def _write_zero(cl, i): | ||
shutil.copy( | ||
'tests/vidtest.ogv', | ||
os.path.join(self.testdir, '%s_%d.ogv' % (cl, i)) | ||
) | ||
|
||
for i in range(10): | ||
for cl in ['A', 'B', 'C']: | ||
_write_zero(cl, i) | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.testdir) | ||
|
||
def __split(self, | ||
kind=keras_video.VideoFrameGenerator, | ||
vc=0, | ||
tc=0): | ||
pattern = os.path.join(self.testdir, '{classname}_*.ogv') | ||
gen = kind( | ||
glob_pattern=pattern, | ||
split_test=.2, | ||
split_val=.3) | ||
valid = gen.get_validation_generator() | ||
test = gen.get_test_generator() | ||
|
||
assert valid.files_count == vc | ||
assert test.files_count == tc | ||
|
||
def test_videoframegenerator_split(self): | ||
""" Check spliting VideoFrameGenerator """ | ||
self.__split(keras_video.VideoFrameGenerator, 9, 3) | ||
|
||
def test_slidinggenerator_split(self): | ||
""" Check splitint SlidingFrameGenerator """ | ||
self.__split(keras_video.SlidingFrameGenerator, 9, 3) | ||
|
||
def test_flowgenerator_split(self): | ||
""" Check splitint OpticalFlowGenerator """ | ||
self.__split(keras_video.OpticalFlowGenerator, 9, 3) |