def test_run_strred_fextractor(self):

        ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing(
        )

        self.fextractor = StrredFeatureExtractor([asset, asset_original],
                                                 None,
                                                 fifo_mode=True,
                                                 result_store=None)
        self.fextractor.run(parallelize=True)

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'],
                               3.0166328541666663,
                               places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'],
                               7.338665770833333,
                               places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'],
                               22.336452104611016,
                               places=4)
        self.assertAlmostEqual(
            results[0]['STRRED_feature_strred_all_same_score'],
            22.138060270044175,
            places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'],
                               0.0,
                               places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'],
                               0.0,
                               places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'],
                               0.0,
                               places=4)
Example #2
0
 def _run_on_asset(self, asset):
     vmaf_fassembler = self._get_feature_assembler_instance(asset)
     vmaf_fassembler.run()
     feature_result = vmaf_fassembler.results[0]
     result_dict = {}
     result_dict.update(feature_result.result_dict.copy()) # add feature result
     result_dict[self.get_scores_key()] = feature_result.result_dict[
         StrredFeatureExtractor.get_scores_key('strred')] # add strred score
     del result_dict[StrredFeatureExtractor.get_scores_key('strred')] # delete redundant
     return Result(asset, self.executor_id, result_dict)
    def test_run_strred_fextractor_blackframes(self):
        print 'test on running STRRED feature extractor on flat frames...'
        ref_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_0.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_10.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

        asset_original = Asset(dataset="test", content_id=0, asset_id=1,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        from vmaf.core.result_store import FileSystemResultStore
        result_store = FileSystemResultStore(logger=None)

        self.fextractor = StrredFeatureExtractor(
            [asset, asset_original],
            None, fifo_mode=True,
            result_store=result_store
        )

        print '    running for the first time with fresh calculation...'
        self.fextractor.run(parallelize=True)

        result0, result1 = self.fextractor.results
        import os
        self.assertTrue(os.path.exists(result_store._get_result_file_path(result0)))
        self.assertTrue(os.path.exists(result_store._get_result_file_path(result1)))

        print '    running for the second time with stored results...'
        self.fextractor.run(parallelize=True)
        results = self.fextractor.results

        # ignore NaN
        for result in results:
            result.set_score_aggregate_method(ListStats.nonemean)

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'], 1220.5679849999999, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'], 50983.3097155, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'], 62228595.6081, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'], 0.0, places=4)
    def test_run_strred_fextractor(self):
        print 'test on running STRRED feature extractor...'
        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 576,
                          'height': 324
                      })

        asset_original = Asset(dataset="test",
                               content_id=0,
                               asset_id=1,
                               workdir_root=VmafConfig.workdir_path(),
                               ref_path=ref_path,
                               dis_path=ref_path,
                               asset_dict={
                                   'width': 576,
                                   'height': 324
                               })

        self.fextractor = StrredFeatureExtractor([asset, asset_original],
                                                 None,
                                                 fifo_mode=True,
                                                 result_store=None)
        self.fextractor.run(parallelize=True)

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'],
                               3.0114681041666671,
                               places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'],
                               7.3039486249999994,
                               places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'],
                               21.995608318659482,
                               places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'],
                               0.0,
                               places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'],
                               0.0,
                               places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'],
                               0.0,
                               places=4)
class ParallelMatlabFeatureExtractorTestNew(unittest.TestCase):

    def tearDown(self):
        if hasattr(self, 'fextractor'):
            self.fextractor.remove_results()
        pass

    def test_run_strred_fextractor(self):
        print 'test on running STRRED feature extractor, with parallelization...'
        ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

        self.fextractor = StrredFeatureExtractor(
            [asset, asset_original],
            None, fifo_mode=True,
            result_store=None
        )
        self.fextractor.run(parallelize=True)

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'], 3.0166328541666663, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'], 7.338665770833333, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'], 22.336452104611016, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_all_same_score'], 22.138060270044175, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'], 0.0, places=4)

    def test_run_strred_fextractor_blackframes(self):
        print 'test on running STRRED feature extractor on flat frames...'
        ref_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_0.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_10.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

        asset_original = Asset(dataset="test", content_id=0, asset_id=1,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        from vmaf.core.result_store import FileSystemResultStore
        result_store = FileSystemResultStore(logger=None)

        self.fextractor = StrredFeatureExtractor(
            [asset, asset_original],
            None, fifo_mode=True,
            result_store=result_store
        )

        print '    running for the first time with fresh calculation...'
        self.fextractor.run(parallelize=True)

        result0, result1 = self.fextractor.results
        import os
        self.assertTrue(os.path.exists(result_store._get_result_file_path(result0)))
        self.assertTrue(os.path.exists(result_store._get_result_file_path(result1)))

        print '    running for the second time with stored results...'
        self.fextractor.run(parallelize=True)
        results = self.fextractor.results

        # ignore NaN
        for result in results:
            result.set_score_aggregate_method(ListStats.nonemean)

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'], 1220.5679849999999, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'], 50983.3097155, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'], 62228595.6081, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'], 0.0, places=4)