Skip to content

Commit

Permalink
* avoid failure for tagging OPs
Browse files Browse the repository at this point in the history
  • Loading branch information
HYLcool committed Apr 16, 2024
1 parent c0cb640 commit fb8137b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
17 changes: 12 additions & 5 deletions tests/ops/filter/test_video_tagging_from_frames_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import unittest

from data_juicer.core.data import NestedDataset
from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
from data_juicer.utils.mm_utils import SpecialTokens
from data_juicer.utils.unittest_utils import DataJuicerTestCaseBase, SKIPPED_TESTS

Expand Down Expand Up @@ -45,6 +43,8 @@ def test(self):
'text': f'{SpecialTokens.video} 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。',
'videos': [self.vid1_path]
}]
from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['cartoon'])
self._run_video_tagging_from_frames_filter(op, ds_list, tgt_list)

Expand All @@ -69,6 +69,8 @@ def test_uniform(self):
f'{SpecialTokens.video} 两个长头发的女子正坐在一张圆桌前讲话互动。 {SpecialTokens.eoc}',
'videos': [self.vid3_path]
}]
from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['person'],
frame_sampling_method='uniform',
frame_num=10)
Expand Down Expand Up @@ -98,7 +100,8 @@ def test_contain_any(self):
f'{SpecialTokens.video} 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。{SpecialTokens.eoc}{SpecialTokens.video} 两个长头发的女子正坐在一张圆桌前讲话互动。 {SpecialTokens.eoc}',
'videos': [self.vid1_path, self.vid3_path]
}]

from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['cartoon', 'fish'],
contain='any',
any_or_all='any')
Expand Down Expand Up @@ -127,7 +130,8 @@ def test_contain_all(self):
f'{SpecialTokens.video} 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。{SpecialTokens.eoc}{SpecialTokens.video} 两个长头发的女子正坐在一张圆桌前讲话互动。 {SpecialTokens.eoc}',
'videos': [self.vid1_path, self.vid3_path]
}]

from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['girl', 'person'],
contain='all',
any_or_all='any')
Expand All @@ -153,7 +157,8 @@ def test_all(self):
f'{SpecialTokens.video} 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。{SpecialTokens.eoc}{SpecialTokens.video} 两个长头发的女子正坐在一张圆桌前讲话互动。 {SpecialTokens.eoc}',
'videos': [self.vid1_path, self.vid3_path]
}]

from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['cartoon', 'girl'],
contain='any',
any_or_all='all')
Expand Down Expand Up @@ -182,6 +187,8 @@ def test_multi_process(self):
'text': f'{SpecialTokens.video} 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。',
'videos': [self.vid1_path]
}]
from data_juicer.ops.filter.video_tagging_from_frames_filter import \
VideoTaggingFromFramesFilter
op = VideoTaggingFromFramesFilter(tags=['cartoon'])
self._run_video_tagging_from_frames_filter(op,
ds_list,
Expand Down
10 changes: 8 additions & 2 deletions tests/ops/mapper/test_video_tagging_from_frames_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import unittest

from data_juicer.core.data import NestedDataset
from data_juicer.ops.mapper.video_tagging_from_frames_mapper import \
VideoTaggingFromFramesMapper
from data_juicer.utils.constant import Fields
from data_juicer.utils.mm_utils import SpecialTokens
from data_juicer.utils.unittest_utils import DataJuicerTestCaseBase, SKIPPED_TESTS
Expand Down Expand Up @@ -68,6 +66,8 @@ def test(self):
'hand', 'selfie', 'stand'
]]
}]
from data_juicer.ops.mapper.video_tagging_from_frames_mapper import \
VideoTaggingFromFramesMapper
op = VideoTaggingFromFramesMapper()
self._run_video_tagging_from_frames_mapper(op, ds_list, tgt_list)

Expand Down Expand Up @@ -115,6 +115,8 @@ def test_uniform(self):
'point'
]]
}]
from data_juicer.ops.mapper.video_tagging_from_frames_mapper import \
VideoTaggingFromFramesMapper
op = VideoTaggingFromFramesMapper(frame_sampling_method='uniform',
frame_num=10)
self._run_video_tagging_from_frames_mapper(op, ds_list, tgt_list)
Expand Down Expand Up @@ -165,6 +167,8 @@ def test_multi_process(self):
'hand', 'selfie', 'stand'
]]
}]
from data_juicer.ops.mapper.video_tagging_from_frames_mapper import \
VideoTaggingFromFramesMapper
op = VideoTaggingFromFramesMapper()
self._run_video_tagging_from_frames_mapper(op,
ds_list,
Expand Down Expand Up @@ -236,6 +240,8 @@ def test_multi_chunk(self):
'cabinet', 'hand', 'selfie', 'stand'
]]
}]
from data_juicer.ops.mapper.video_tagging_from_frames_mapper import \
VideoTaggingFromFramesMapper
op = VideoTaggingFromFramesMapper()
self._run_video_tagging_from_frames_mapper(op, ds_list, tgt_list)

Expand Down

0 comments on commit fb8137b

Please sign in to comment.