Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(unittest): fix unittest of video preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Larryjianfeng committed Aug 5, 2019
1 parent 0ba6c57 commit b8081c7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
34 changes: 34 additions & 0 deletions tests/test_video_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class TestFFmpeg(unittest.TestCase):
def setUp(self):
self.dirname = os.path.dirname(__file__)
self.yml_path = os.path.join(self.dirname, 'yaml', 'preprocessor-ffmpeg.yml')
self.yml_path_2 = os.path.join(self.dirname, 'yaml', 'preprocessor-ffmpeg2.yml')
self.yml_path_3 = os.path.join(self.dirname, 'yaml', 'preprocessor-ffmpeg3.yml')
self.video_path = os.path.join(self.dirname, 'videos')

def test_video_preprocessor_service_empty(self):
Expand All @@ -25,6 +27,15 @@ def test_video_preprocessor_service_realdata(self):
args = set_preprocessor_service_parser().parse_args([
'--yaml_path', self.yml_path
])

args_2 = set_preprocessor_service_parser().parse_args([
'--yaml_path', self.yml_path_2
])

args_3 = set_preprocessor_service_parser().parse_args([
'--yaml_path', self.yml_path_3
])

c_args = _set_client_parser().parse_args([
'--port_in', str(args.port_out),
'--port_out', str(args.port_in)
Expand All @@ -43,3 +54,26 @@ def test_video_preprocessor_service_realdata(self):
for _ in range(len(d.chunks)):
shape = blob2array(d.chunks[_].blob).shape
self.assertEqual(shape, (168, 192, 3))

with PreprocessorService(args_2), ZmqClient(c_args) as client:
for req in RequestGenerator.index(video_bytes):
msg = gnes_pb2.Message()
msg.request.index.CopyFrom(req.index)
client.send_message(msg)
r = client.recv_message()
for d in r.request.index.docs:
self.assertGreater(len(d.chunks), 0)
for _ in range(len(d.chunks)-1):
shape = blob2array(d.chunks[_].blob).shape
self.assertEqual(shape, (30, 168, 192, 3))
shape = blob2array(d.chunks[-1].blob).shape
self.assertLessEqual(shape[0], 30)

with PreprocessorService(args_2), ZmqClient(c_args) as client:
for req in RequestGenerator.index(video_bytes):
msg = gnes_pb2.Message()
msg.request.index.CopyFrom(req.index)
client.send_message(msg)
r = client.recv_message()
for d in r.request.index.docs:
self.assertEqual(len(d.chunks), 5)
2 changes: 1 addition & 1 deletion tests/yaml/preprocessor-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parameter:
duplicate_rm: true
use_phash_weight: true
phash_thresh: 5
frame_size: "192*168"
s: "192*168"
vsync: vfr
vf: select=eq(pict_type\,I)
gnes_config:
Expand Down
8 changes: 8 additions & 0 deletions tests/yaml/preprocessor-ffmpeg2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!FFmpegVideoSegmentor
parameter:
segment_method: cut_by_frame
segment_interval: 30
s: "192*168"
r: 1
gnes_config:
is_trained: true
8 changes: 8 additions & 0 deletions tests/yaml/preprocessor-ffmpeg3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!FFmpegVideoSegmentor
parameter:
segment_method: cut_by_num
segment_num: 5
s: "192*168"
r: 1
gnes_config:
is_trained: true

0 comments on commit b8081c7

Please sign in to comment.