Пример #1
0
    def test_run_ms_ssim_fextractor(self):
        print 'test on running MS-SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_score'], 0.9632498125, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 0.9923925625, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 0.9611274375, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 0.897844791667, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 0.9954706875, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 0.9857694375, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 0.941185875, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 0.997437458333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 0.997034020833, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 0.977992145833, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 0.998035583333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 0.999588104167, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 0.99387125, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 0.9995495, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 0.999907625, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 0.998222583333, places=4)

        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 1., places=4)
Пример #2
0
 def _run_on_asset(self, asset):
     # Override Executor._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[
         MsSsimFeatureExtractor.get_scores_key('ms_ssim')] # add ssim score
     del result_dict[MsSsimFeatureExtractor.get_scores_key('ms_ssim')] # delete redundant
     return Result(asset, self.executor_id, result_dict)
Пример #3
0
    def test_run_ssim_fextractor(self):
        print 'test on running SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_score'], 0.86325137500000004, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_l_score'], 0.99814749999999997, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_c_score'], 0.96132239583333323, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_s_score'], 0.89770760416666662, places=4)

        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_l_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_c_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_s_score'], 1.0, places=4)
Пример #4
0
    def test_run_ssim_fextractor(self):
        print 'test on running SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_score'], 0.857692208333, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_l_score'], 0.9923925625, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_c_score'], 0.9611274375, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_s_score'], 0.897844791667, places=4)

        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_l_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_c_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_s_score'], 1.0, places=4)
Пример #5
0
    def test_run_psnr_fextractor(self):
        print 'test on running PSNR feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['PSNR_feature_psnr_score'], 30.755063979166664, places=4)
        self.assertAlmostEqual(results[1]['PSNR_feature_psnr_score'], 60.0, places=4)
Пример #6
0
    def test_run_psnr_fextractor(self):
        print 'test on running PSNR feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['PSNR_feature_psnr_score'], 30.755063979166664, places=4)
        self.assertAlmostEqual(results[1]['PSNR_feature_psnr_score'], 60.0, places=4)
Пример #7
0
    def test_run_vmaf_fextractor_not_unique(self):
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=dis_path,
            asset_dict={"width": 576, "height": 324},
        )

        asset_original = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

        with self.assertRaises(AssertionError):
            self.fextractor = VmafFeatureExtractor([asset, asset_original], None, fifo_mode=True)
Пример #8
0
    def test_run_ms_ssim_fextractor(self):
        print 'test on running MS-SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_score'], 0.96324620833333319, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 0.9981474999999999, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 0.9613223958333336, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 0.8977076041666665, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 0.9989961250000002, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 0.9858215416666668, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 0.9411672708333335, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 0.9992356458333332, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 0.9970406458333333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 0.9779967291666667, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 0.9992921041666665, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 0.9995884375000003, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 0.9938731666666668, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 0.99940356249999995, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 0.99990762500000008, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 0.99822306250000004, places=4)

        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 1., places=4)
Пример #9
0
    def test_run_vamf_fextractor(self):
        print 'test on running VMAF feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'], 0.9254334398006141, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 644527.3311971038, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.815530270836, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.15266368750002, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.3655846219305399, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.7722301581694561, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.8681486658208089, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.9207121810522212, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1449635.3522745417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.65012097916668, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0000000132944864, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 0.9999998271651448, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 0.9999998649680067, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 0.9999998102499, places=4)
Пример #10
0
    def test_run_vmaf_fextractor_not_unique(self):
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

        asset_original = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        with self.assertRaises(AssertionError):
            self.fextractor = VmafFeatureExtractor(
                [asset, asset_original],
                None, fifo_mode=True)
Пример #11
0
    def test_run_moment_fextractor(self):
        print "test on running Moment feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["Moment_feature_ref1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_ref2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_refvar_score"], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_dis1st_score"], 61.332006624999984, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_dis2nd_score"], 4798.659574041666, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_disvar_score"], 1036.837184348847, places=4)

        self.assertAlmostEqual(results[1]["Moment_feature_ref1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_ref2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_refvar_score"], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_dis1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_dis2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_disvar_score"], 1121.519917231203, places=4)
Пример #12
0
    def test_run_moment_fextractor(self):
        print 'test on running Moment feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis1st_score'], 61.332006624999984, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis2nd_score'], 4798.659574041666, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_disvar_score'], 1036.837184348847, places=4)

        self.assertAlmostEqual(results[1]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_disvar_score'], 1121.519917231203, places=4)
Пример #13
0
    def test_run_ssim_fextractor(self):
        print "test on running SSIM feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_score"], 0.86322654166666657, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_l_score"], 0.9981474583333334, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_c_score"], 0.96126793750000006, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_s_score"], 0.89773633333333336, places=4)

        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_l_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_c_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_s_score"], 1.0, places=4)
Пример #14
0
class FeatureExtractorTest(unittest.TestCase):

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

    def test_executor_id(self):
        asset = Asset(dataset="test", content_id=0, asset_id=1,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={})
        fextractor = VmafFeatureExtractor([asset], None)
        self.assertEquals(fextractor.executor_id, "VMAF_feature_V0.2.2b")

    def test_get_log_file_path(self):
        import hashlib

        asset = Asset(dataset="test", content_id=0, asset_id=1,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'start_frame':2, 'end_frame':2},
                      workdir_root="my_workdir_root")

        fextractor = VmafFeatureExtractor([asset], None)
        log_file_path = fextractor._get_log_file_path(asset)
        h = hashlib.sha1("test_0_1_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_720x480").hexdigest()
        self.assertTrue(re.match(r"^my_workdir_root/[a-zA-Z0-9-]+/VMAF_feature_V0.2.2b_{}$".format(h), log_file_path))

    def test_run_vamf_fextractor(self):
        print 'test on running VMAF feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'],0.925421075027, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale0_score'], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale1_score'], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale2_score'], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale3_score'], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif2_score'], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm3_score'], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm3_score'], 1.0, places=4)

    def test_run_vamf_fextractor_with_result_store(self):
        print 'test on running VMAF feature extractor with result store...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        result_store = FileSystemResultStore(logger=None)

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

        print '    running for the first time with fresh calculation...'
        self.fextractor.run()
        result0, result1 = self.fextractor.results

        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()
        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'],0.925421075027, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale0_score'], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale1_score'], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale2_score'], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale3_score'], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif2_score'], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm3_score'], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm3_score'], 1.0, places=4)

    def test_run_vmaf_fextractor_not_unique(self):
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

        asset_original = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        with self.assertRaises(AssertionError):
            self.fextractor = VmafFeatureExtractor(
                [asset, asset_original],
                None, fifo_mode=True)

    def test_run_moment_fextractor(self):
        print 'test on running Moment feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis1st_score'], 61.332006624999984, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis2nd_score'], 4798.659574041666, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_disvar_score'], 1036.837184348847, places=4)

        self.assertAlmostEqual(results[1]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_disvar_score'], 1121.519917231203, places=4)

    def test_run_psnr_fextractor(self):
        print 'test on running PSNR feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['PSNR_feature_psnr_score'], 30.755063979166664, places=4)
        self.assertAlmostEqual(results[1]['PSNR_feature_psnr_score'], 60.0, places=4)

    def test_run_ssim_fextractor(self):
        print 'test on running SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_score'], 0.857692208333, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_l_score'], 0.9923925625, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_c_score'], 0.9611274375, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_s_score'], 0.897844791667, places=4)

        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_l_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_c_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_s_score'], 1.0, places=4)

    def test_run_ms_ssim_fextractor(self):
        print 'test on running MS-SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_score'], 0.9632498125, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 0.9923925625, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 0.9611274375, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 0.897844791667, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 0.9954706875, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 0.9857694375, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 0.941185875, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 0.997437458333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 0.997034020833, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 0.977992145833, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 0.998035583333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 0.999588104167, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 0.99387125, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 0.9995495, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 0.999907625, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 0.998222583333, places=4)

        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 1., places=4)
Пример #15
0
    def test_run_vamf_fextractor(self):
        print 'test on running VMAF feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'],0.925421075027, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale0_score'], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale1_score'], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale2_score'], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_scale3_score'], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif2_score'], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm3_score'], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale0_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale1_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_scale3_score'], 1.0, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm3_score'], 1.0, places=4)
Пример #16
0
class FeatureExtractorTest(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, "fextractor"):
            self.fextractor.remove_results()
        pass

    def test_executor_id(self):
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=1,
            ref_path="dir/refvideo.yuv",
            dis_path="dir/disvideo.yuv",
            asset_dict={},
        )
        fextractor = VmafFeatureExtractor([asset], None)
        self.assertEquals(fextractor.executor_id, "VMAF_feature_V0.2.2b")

    def test_get_log_file_path(self):
        import hashlib

        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=1,
            ref_path="dir/refvideo.yuv",
            dis_path="dir/disvideo.yuv",
            asset_dict={"width": 720, "height": 480, "start_frame": 2, "end_frame": 2},
            workdir_root="my_workdir_root",
        )

        fextractor = VmafFeatureExtractor([asset], None)
        log_file_path = fextractor._get_log_file_path(asset)
        h = hashlib.sha1("test_0_1_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_720x480").hexdigest()
        self.assertTrue(re.match(r"^my_workdir_root/[a-zA-Z0-9-]+/VMAF_feature_V0.2.2b_{}$".format(h), log_file_path))

    def test_run_vamf_fextractor(self):
        print "test on running VMAF feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_score"], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm2_score"], 0.925421075027, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_ansnr_score"], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_num_score"], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_num_score"], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_anpsnr_score"], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale0_score"], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale1_score"], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale2_score"], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale3_score"], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale0_score"], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale1_score"], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale2_score"], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale3_score"], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif2_score"], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm3_score"], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_ansnr_score"], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_num_score"], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_num_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_anpsnr_score"], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm3_score"], 1.0, places=4)

    def test_run_vamf_fextractor_with_result_store(self):
        print "test on running VMAF feature extractor with result store..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

        result_store = FileSystemResultStore(logger=None)

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

        print "    running for the first time with fresh calculation..."
        self.fextractor.run()
        result0, result1 = self.fextractor.results

        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()
        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_score"], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm2_score"], 0.925421075027, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_ansnr_score"], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_num_score"], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_num_score"], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_anpsnr_score"], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale0_score"], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale1_score"], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale2_score"], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale3_score"], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale0_score"], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale1_score"], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale2_score"], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale3_score"], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif2_score"], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm3_score"], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_ansnr_score"], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_num_score"], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_num_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_anpsnr_score"], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm3_score"], 1.0, places=4)

    def test_run_vmaf_fextractor_not_unique(self):
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=dis_path,
            asset_dict={"width": 576, "height": 324},
        )

        asset_original = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

        with self.assertRaises(AssertionError):
            self.fextractor = VmafFeatureExtractor([asset, asset_original], None, fifo_mode=True)

    def test_run_moment_fextractor(self):
        print "test on running Moment feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["Moment_feature_ref1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_ref2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_refvar_score"], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_dis1st_score"], 61.332006624999984, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_dis2nd_score"], 4798.659574041666, places=4)
        self.assertAlmostEqual(results[0]["Moment_feature_disvar_score"], 1036.837184348847, places=4)

        self.assertAlmostEqual(results[1]["Moment_feature_ref1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_ref2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_refvar_score"], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_dis1st_score"], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_dis2nd_score"], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]["Moment_feature_disvar_score"], 1121.519917231203, places=4)

    def test_run_psnr_fextractor(self):
        print "test on running PSNR feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["PSNR_feature_psnr_score"], 30.755063979166664, places=4)
        self.assertAlmostEqual(results[1]["PSNR_feature_psnr_score"], 60.0, places=4)

    def test_run_ssim_fextractor(self):
        print "test on running SSIM feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_score"], 0.86322654166666657, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_l_score"], 0.9981474583333334, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_c_score"], 0.96126793750000006, places=4)
        self.assertAlmostEqual(results[0]["SSIM_feature_ssim_s_score"], 0.89773633333333336, places=4)

        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_l_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_c_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["SSIM_feature_ssim_s_score"], 1.0, places=4)

    def test_run_ms_ssim_fextractor(self):
        print "test on running MS-SSIM feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_score"], 0.9632498125, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale0_score"], 0.9981474583333334, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale0_score"], 0.96126793750000006, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale0_score"], 0.89773633333333336, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale1_score"], 0.99899612500000001, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale1_score"], 0.9857694375, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale1_score"], 0.941185875, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale2_score"], 0.99923564583333324, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale2_score"], 0.997034020833, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale2_score"], 0.977992145833, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale3_score"], 0.99929210416666658, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale3_score"], 0.999588104167, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale3_score"], 0.99387125, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale4_score"], 0.99940356249999995, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale4_score"], 0.999907625, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale4_score"], 0.998222583333, places=4)

        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale4_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale4_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale4_score"], 1.0, places=4)
Пример #17
0
class FeatureExtractorTest(unittest.TestCase):

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

    def test_executor_id(self):
        asset = Asset(dataset="test", content_id=0, asset_id=1,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={})
        fextractor = VmafFeatureExtractor([asset], None)
        self.assertEquals(fextractor.executor_id, "VMAF_feature_V0.2.1")

    def test_get_log_file_path(self):
        import hashlib

        asset = Asset(dataset="test", content_id=0, asset_id=1,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'start_frame':2, 'end_frame':2},
                      workdir_root="my_workdir_root")

        fextractor = VmafFeatureExtractor([asset], None)
        log_file_path = fextractor._get_log_file_path(asset)
        h = hashlib.sha1("test_0_1_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_720x480").hexdigest()
        self.assertTrue(re.match(r"^my_workdir_root/[a-zA-Z0-9-]+/VMAF_feature_V0.2.1_{}$".format(h), log_file_path))

    def test_run_vamf_fextractor(self):
        print 'test on running VMAF feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'], 0.9254334398006141, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 644527.3311971038, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.815530270836, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.15266368750002, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.3655846219305399, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.7722301581694561, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.8681486658208089, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.9207121810522212, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1449635.3522745417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.65012097916668, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0000000132944864, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 0.9999998271651448, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 0.9999998649680067, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 0.9999998102499, places=4)

    def test_run_vamf_fextractor_with_result_store(self):
        print 'test on running VMAF feature extractor with result store...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        result_store = FileSystemResultStore(logger=None)

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

        print '    running for the first time with fresh calculation...'
        self.fextractor.run()
        result0, result1 = self.fextractor.results

        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()
        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'], 0.9254334398006141, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_num_score'], 644527.3311971038, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_num_score'], 6899.815530270836, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_anpsnr_score'], 34.15266368750002, places=4)

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 0.3655846219305399, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 0.7722301581694561, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 0.8681486658208089, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 0.9207121810522212, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_num_score'], 1449635.3522745417, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_den_score'], 1449635.3812459996, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_num_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm_den_score'], 7535.801140312499, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_anpsnr_score'], 41.65012097916668, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0000000132944864, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 0.9999998271651448, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 0.9999998649680067, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 0.9999998102499, places=4)

    def test_run_vmaf_fextractor_not_unique(self):
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

        asset_original = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

        with self.assertRaises(AssertionError):
            self.fextractor = VmafFeatureExtractor(
                [asset, asset_original],
                None, fifo_mode=True)

    def test_run_moment_fextractor(self):
        print 'test on running Moment feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis1st_score'], 61.332006624999984, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_dis2nd_score'], 4798.659574041666, places=4)
        self.assertAlmostEqual(results[0]['Moment_feature_disvar_score'], 1036.837184348847, places=4)

        self.assertAlmostEqual(results[1]['Moment_feature_ref1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_ref2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_refvar_score'], 1121.519917231203, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis1st_score'], 59.788567297525134, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_dis2nd_score'], 4696.668388042269, places=4)
        self.assertAlmostEqual(results[1]['Moment_feature_disvar_score'], 1121.519917231203, places=4)

    def test_run_psnr_fextractor(self):
        print 'test on running PSNR feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['PSNR_feature_psnr_score'], 30.755063979166664, places=4)
        self.assertAlmostEqual(results[1]['PSNR_feature_psnr_score'], 60.0, places=4)

    def test_run_ssim_fextractor(self):
        print 'test on running SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_score'], 0.86325137500000004, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_l_score'], 0.99814749999999997, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_c_score'], 0.96132239583333323, places=4)
        self.assertAlmostEqual(results[0]['SSIM_feature_ssim_s_score'], 0.89770760416666662, places=4)

        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_l_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_c_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['SSIM_feature_ssim_s_score'], 1.0, places=4)

    def test_run_ms_ssim_fextractor(self):
        print 'test on running MS-SSIM feature extractor...'
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=config.ROOT + "/workspace/workdir",
                      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=config.ROOT + "/workspace/workdir",
                      ref_path=ref_path,
                      dis_path=ref_path,
                      asset_dict={'width':576, 'height':324})

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_score'], 0.96324620833333319, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 0.9981474999999999, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 0.9613223958333336, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 0.8977076041666665, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 0.9989961250000002, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 0.9858215416666668, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 0.9411672708333335, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 0.9992356458333332, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 0.9970406458333333, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 0.9779967291666667, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 0.9992921041666665, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 0.9995884375000003, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 0.9938731666666668, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 0.99940356249999995, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 0.99990762500000008, places=4)
        self.assertAlmostEqual(results[0]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 0.99822306250000004, places=4)

        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale0_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale1_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale2_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale3_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_l_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_c_scale4_score'], 1., places=4)
        self.assertAlmostEqual(results[1]['MS_SSIM_feature_ms_ssim_s_scale4_score'], 1., places=4)
Пример #18
0
    def test_run_vamf_fextractor(self):
        print "test on running VMAF feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_score"], 0.4460930625, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm2_score"], 0.925421075027, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_ansnr_score"], 23.5095715208, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_num_score"], 712650.023478, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_num_score"], 6899.24648475, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_anpsnr_score"], 34.164776875, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale0_score"], 0.363420489439, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale1_score"], 0.766647542135, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale2_score"], 0.862854666902, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_vif_scale3_score"], 0.915971778036, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale0_score"], 0.86711114907261122, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale1_score"], 0.87407085185224942, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale2_score"], 0.92448300466700284, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm_scale3_score"], 0.96367203202196239, places=4)

        self.assertAlmostEqual(results[0]["VMAF_feature_vif2_score"], 0.72722361912801026, places=4)
        self.assertAlmostEqual(results[0]["VMAF_feature_adm3_score"], 0.90733425940345658, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_motion_score"], 4.04982535417, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_ansnr_score"], 31.2714392708, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_num_score"], 1597314.86733, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_den_score"], 1597314.95249, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_num_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_den_score"], 7535.29963308, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_anpsnr_score"], 41.9266444375, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_vif_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm_scale3_score"], 1.0, places=4)

        self.assertAlmostEqual(results[1]["VMAF_feature_vif2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["VMAF_feature_adm3_score"], 1.0, places=4)
Пример #19
0
    def test_run_ms_ssim_fextractor(self):
        print "test on running MS-SSIM feature extractor..."
        ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv"
        dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv"
        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            workdir_root=config.ROOT + "/workspace/workdir",
            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=config.ROOT + "/workspace/workdir",
            ref_path=ref_path,
            dis_path=ref_path,
            asset_dict={"width": 576, "height": 324},
        )

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

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_score"], 0.9632498125, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale0_score"], 0.9981474583333334, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale0_score"], 0.96126793750000006, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale0_score"], 0.89773633333333336, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale1_score"], 0.99899612500000001, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale1_score"], 0.9857694375, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale1_score"], 0.941185875, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale2_score"], 0.99923564583333324, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale2_score"], 0.997034020833, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale2_score"], 0.977992145833, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale3_score"], 0.99929210416666658, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale3_score"], 0.999588104167, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale3_score"], 0.99387125, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_l_scale4_score"], 0.99940356249999995, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_c_scale4_score"], 0.999907625, places=4)
        self.assertAlmostEqual(results[0]["MS_SSIM_feature_ms_ssim_s_scale4_score"], 0.998222583333, places=4)

        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale0_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale1_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale2_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale3_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_l_scale4_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_c_scale4_score"], 1.0, places=4)
        self.assertAlmostEqual(results[1]["MS_SSIM_feature_ms_ssim_s_scale4_score"], 1.0, places=4)