Example #1
0
 def test_copy_use_path_as_workpath(self):
     asset = Asset(dataset="test", content_id=0, asset_id=0,
                   ref_path="", dis_path="",
                   asset_dict={'width': 720, 'height': 480,
                               'quality_width': 720, 'quality_height': 320,
                               'yuv_type': 'yuv422p',
                               'crop_cmd': '570:320:3:2',
                               'use_path_as_workpath': True
                               })
     new_asset = asset.copy()
     self.assertNotEquals(asset, new_asset) # use_path_as_workpath gets reset
     self.assertTrue(asset.use_path_as_workpath)
     self.assertFalse(new_asset.use_path_as_workpath)
Example #2
0
    def test_run_vmafossexec_runner_with_phone_model(self):
        print 'test on running VMAFOSSEXEC runner with transform for phone...'
        ref_path = VmafConfig.test_resource_path("yuv", "checkerboard_1920_1080_10_3_0_0.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "checkerboard_1920_1080_10_3_10_0.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':1920, 'height':1080})

        self.runner = VmafossExecQualityRunner(
            [asset],
            None, fifo_mode=False,
            delete_workdir=True,
            optional_dict={
                'phone_model':True,
            },
            result_store=self.result_store,
        )
        self.runner.run()

        results = self.runner.results

        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale0_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale1_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale2_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale3_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_motion2_score'], 12.5548366667, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_adm2_score'], 0.053996566666666669, places=4)

        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 14.982840000000001, places=4)
Example #3
0
    def test_run_vmafossexec_runner_with_transform_score_disabled(self):
        print 'test on running VMAFOSSEXEC runner with score transforming disabled...'
        ref_path = VmafConfig.test_resource_path("yuv", "checkerboard_1920_1080_10_3_0_0.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "checkerboard_1920_1080_10_3_10_0.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':1920, 'height':1080})

        self.runner = VmafossExecQualityRunner(
            [asset],
            None, fifo_mode=True,
            delete_workdir=True,
            optional_dict={
                'model_filepath':VmafConfig.test_resource_path("test_model_transform_add40.pkl"),
                'enable_transform_score':False,
            },
            result_store=self.result_store,
        )
        self.runner.run()

        results = self.runner.results

        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale0_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale1_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale2_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_vif_scale3_score'], 0.0, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_motion_score'], 12.5548366667, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_adm_scale0_score'], 0.23738393128710478, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_adm_scale1_score'], 0.08524788663335138, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_adm_scale2_score'], 0.024058909404945077, places=4)
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_adm_scale3_score'], 0.018034879735107798, places=4)

        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 0.0, places=4)
Example #4
0
 def test_workfile_path(self):
     asset = Asset(dataset="test",
                   content_id=0,
                   asset_id=0,
                   ref_path="dir/refvideo.yuv",
                   dis_path="dir/disvideo.yuv",
                   asset_dict={
                       'width': 720,
                       'height': 480,
                       'start_frame': 2,
                       'end_frame': 2,
                       'quality_width': 1920,
                       'quality_height': 1080
                   },
                   workdir_root="workdir")
     expected_ref_workfile_path_re = \
         r"^workdir/[a-zA-Z0-9-]+/" \
         r"ref_test_0_0_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_1920x1080"
     expected_dis_workfile_path_re = \
         r"^workdir/[a-zA-Z0-9-]+/" \
         r"dis_test_0_0_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_1920x1080"
     self.assertTrue(
         re.match(expected_ref_workfile_path_re, asset.ref_workfile_path))
     self.assertTrue(
         re.match(expected_dis_workfile_path_re, asset.dis_workfile_path))
Example #5
0
    def test_run_vmafrc_runner_akiyo_multiply_with_feature_enhn_gain_limit(self):
        ref_path = VmafConfig.test_resource_path("yuv", "refp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288")
        dis_path = VmafConfig.test_resource_path("yuv", "disp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width': 352, 'height': 288})

        self.runner = VmafrcQualityRunner(
            [asset],
            None, fifo_mode=False,
            delete_workdir=True,
            result_store=None,
            optional_dict={'disable_clip_score': True, 'adm_enhn_gain_limit': 1.0, 'vif_enhn_gain_limit': 1.0}
        )
        self.runner.run(parallelize=False)

        results = self.runner.results

        self.assertAlmostEqual(results[0]['VMAFRC_adm2_score'], 0.9574308606115118, places=4)  # 1.116691484215469
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale0_score'], 0.983699512450884, places=4)  # 1.0522544319369052
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale1_score'], 0.9974276726830457, places=4)  # 1.0705609423182443
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale2_score'], 0.9984692380091739, places=4)  # 1.0731529493098957
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale3_score'], 0.999146211879154, places=4)  # 1.0728060231246508

        self.assertAlmostEqual(results[0]['VMAFRC_score'], 88.032956, places=4)  # 132.78849246495625
Example #6
0
    def test_bitrate(self):
        ref_path = VmafConfig.test_resource_path('yuv/',
                                                 'src01_hrc00_576x324.yuv')
        dis_path = VmafConfig.test_resource_path('yuv',
                                                 'src01_hrc01_576x324.yuv')

        asset = Asset(
            dataset="test",
            content_id=0,
            asset_id=0,
            ref_path=ref_path,
            dis_path=dis_path,
            asset_dict={
                'ref_start_frame': 0,
                'ref_end_frame': 47,
                'dis_start_frame': 0,
                'dis_end_frame': 47,
                'fps': 23.976
            },
        )
        self.assertAlmostEquals(asset.ref_bitrate_kbps_for_entire_file,
                                53693.964287999996,
                                places=4)
        self.assertAlmostEquals(asset.dis_bitrate_kbps_for_entire_file,
                                53693.964287999996,
                                places=4)
Example #7
0
 def test_workdir(self):
     import re
     asset = Asset(dataset="test", content_id=0, asset_id=0,
                   ref_path="", dis_path="",
                   asset_dict={}, workdir_root="my_workdir_root")
     workdir = asset.workdir
     self.assertTrue(re.match(r"^my_workdir_root/[a-zA-Z0-9-]+$", workdir))
Example #8
0
 def test_run_float_adm_fextractor_akiyo_multiply_enhn_gain_limit_1d2(self):
     ref_path = VmafConfig.test_resource_path(
         "yuv",
         "refp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288"
     )
     dis_path = VmafConfig.test_resource_path(
         "yuv",
         "disp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288"
     )
     asset = Asset(dataset="test",
                   content_id=0,
                   asset_id=0,
                   workdir_root=VmafConfig.workdir_path(),
                   ref_path=ref_path,
                   dis_path=dis_path,
                   asset_dict={
                       'width': 352,
                       'height': 288
                   })
     self.fextractor = FloatAdmFeatureExtractor(
         [asset],
         None,
         fifo_mode=False,
         result_store=None,
         optional_dict={'adm_enhn_gain_limit': 1.2})
     self.fextractor.run()
     results = self.fextractor.results
     self.assertAlmostEqual(results[0]['float_ADM_feature_adm2_score'],
                            1.116595,
                            places=6)
Example #9
0
def set_default_flat_1920_1080_videos_for_testing():
    ref_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_0.yuv")
    dis_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_10.yuv")
    asset = Asset(dataset="test", content_id=0, asset_id=0,
                  workdir_root=VmafConfig.workdir_path(),
                  ref_path=ref_path,
                  dis_path=dis_path,
                  asset_dict={'width': 1920, 'height': 1080})

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

    return ref_path, dis_path, asset, asset_original
Example #10
0
def set_default_576_324_videos_for_testing():
    ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv")
    dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv")
    asset = Asset(dataset="test", content_id=0, asset_id=0,
                  workdir_root=VmafConfig.workdir_path(),
                  ref_path=ref_path,
                  dis_path=dis_path,
                  asset_dict={'width': 576, 'height': 324})

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

    return ref_path, dis_path, asset, asset_original
Example #11
0
    def test_run_vmafrc_runner_akiyo_multiply_with_feature_enhn_gain_limit_custom(self):
        ref_path = VmafConfig.test_resource_path("yuv", "refp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288")
        dis_path = VmafConfig.test_resource_path("yuv", "disp_vmaf_hacking_investigation_0_0_akiyo_cif_notyuv_0to0_identity_vs_akiyo_cif_notyuv_0to0_multiply_q_352x288")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width': 352, 'height': 288})

        self.runner = VmafrcQualityRunner(
            [asset],
            None, fifo_mode=False,
            delete_workdir=True,
            result_store=None,
            optional_dict={'disable_clip_score': True, 'adm_enhn_gain_limit': 1.2, 'vif_enhn_gain_limit': 1.1}
        )
        self.runner.run(parallelize=False)

        results = self.runner.results

        self.assertAlmostEqual(results[0]['VMAFRC_adm2_score'], 1.116595, places=4)  # 1.116691484215469
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale0_score'], 1.029765, places=4)  # 1.0522544319369052
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale1_score'], 1.046767, places=4)  # 1.0705609423182443
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale2_score'], 1.049025, places=4)  # 1.0731529493098957
        self.assertAlmostEqual(results[0]['VMAFRC_vif_scale3_score'], 1.0491232394147363, places=4)  # 1.0728060231246508

        self.assertAlmostEqual(results[0]['VMAFRC_score'], 129.516141, places=4)  # 132.78849246495625
Example #12
0
    def setUp(self):
        ref_path = VmafConfig.test_resource_path(
            "yuv", "checkerboard_1920_1080_10_3_0_0.yuv")
        dis_path = VmafConfig.test_resource_path(
            "yuv", "checkerboard_1920_1080_10_3_1_0.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 1920,
                          'height': 1080
                      })

        self.runner = VmafLegacyQualityRunner(
            [asset],
            None,
            fifo_mode=True,
            delete_workdir=True,
            result_store=None,
        )
        self.runner.run()
        self.result = self.runner.results[0]
Example #13
0
    def test_dis_width_height(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'dis_width':1920, 'dis_height':1080,})
        self.assertEquals(asset.dis_width_height, (1920, 1080))

        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'dis_width':1920, 'dis_height':1080,
                                  'width':720, 'height':480})
        self.assertEquals(asset.dis_width_height, (1920, 1080))

        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'width':720, 'height':480})
        self.assertEquals(asset.dis_width_height, (720, 480))
Example #14
0
    def test_run_vmaf_runner_with_notyuv_gblur(self):

        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_30_480_1050.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 360,
                          'quality_height': 240,
                          'dis_gblur_cmd': 'sigma=0.01:steps=1',
                      })
        self.runner = VmafQualityRunner([asset],
                                        None,
                                        fifo_mode=True,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               77.28938600125885,
                               places=4)
Example #15
0
    def test_run_vmaf_runner_with_yuv_lutyuv(self):
        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 576,
                          'height': 324,
                          'quality_width': 360,
                          'quality_height': 240,
                          'lutyuv_cmd': 'y=2*val',
                      })
        self.runner = VmafQualityRunner([asset],
                                        None,
                                        fifo_mode=False,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               77.18873019841408,
                               places=4)
Example #16
0
    def test_run_vmafossexec_runner_with_notyuv(self):
        print 'test on running VMAF runner...'
        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_30_480_1050.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 360,
                          'quality_height': 240,
                      })
        self.runner = VmafossExecQualityRunner([asset],
                                               None,
                                               fifo_mode=True,
                                               delete_workdir=True,
                                               result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'],
                               79.052553444706504,
                               places=4)
Example #17
0
    def test_run_psnr_runner_with_notyuv_gblur(self):

        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 720,
                          'quality_height': 480,
                          'dis_gblur_cmd': 'sigma=0.01:steps=1',
                      })
        self.runner = PsnrQualityRunner([asset],
                                        None,
                                        fifo_mode=False,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['PSNR_score'],
                               50.99313338666667,
                               places=4)
Example #18
0
    def test_run_vmaf_runner_with_notyuv_jpg(self):
        print 'test on running VMAF runner on jpg...'
        ref_path = VmafConfig.test_resource_path("test_images", "bikes.jpg")
        dis_path = VmafConfig.test_resource_path("test_images",
                                                 "bikes_dis.jpg")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 512,
                          'quality_height': 384,
                          'workfile_yuv_type': 'yuv444p',
                      })
        self.runner = VmafQualityRunner([asset],
                                        None,
                                        fifo_mode=True,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               63.27798081002585,
                               places=4)
Example #19
0
    def test_run_psnr_runner_with_notyuv(self):
        print 'test on running PSNR runner...'
        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 720,
                          'quality_height': 480,
                      })
        self.runner = PsnrQualityRunner([asset],
                                        None,
                                        fifo_mode=True,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['PSNR_score'], 60.0, places=4)
Example #20
0
    def setUp(self):

        ref_path = VmafConfig.test_resource_path(
            "yuv", "checkerboard_1920_1080_10_3_0_0.yuv")
        dis_path = VmafConfig.test_resource_path(
            "yuv", "checkerboard_1920_1080_10_3_1_0.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 1920,
                          'height': 1080
                      })

        self.runner = VmafQualityRunner(
            [asset],
            None,
            fifo_mode=True,
            delete_workdir=True,
            result_store=FileSystemResultStore(),
        )
        self.runner.run()

        self.result = self.runner.results[0]

        Nframes = len(self.result.result_dict['VMAF_scores'])
        self.result.result_dict['VMAF_array_scores'] = self.result.result_dict[
            'VMAF_scores'].reshape(Nframes, 1)
        self.result.result_dict['VMAF_two_models_array_scores'] = np.vstack(
            (self.result.result_dict['VMAF_scores'].reshape(1, Nframes),
             self.result.result_dict['VMAF_scores'].reshape(1, Nframes)))
        self.result.result_dict['VMAF_3D_array_scores'] = np.zeros((1, 1, 1))
Example #21
0
    def test_run_vmaf_runner_with_notyuv_jpg(self):

        ref_path = VmafConfig.test_resource_path("test_images", "bikes.jpg")
        dis_path = VmafConfig.test_resource_path("test_images", "bikes_dis.jpg")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'yuv_type': 'notyuv',
                                  'quality_width': 512, 'quality_height': 384,
                                  'workfile_yuv_type': 'yuv444p',
                                  })
        self.runner = VmafQualityRunner(
            [asset],
            None, fifo_mode=True,
            delete_workdir=True,
            result_store=None,
            optional_dict={
                'model_filepath': VmafConfig.model_path("vmaf_float_v0.6.1.json"),
            },
        )
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'], 63.255016130209064, places=4)
Example #22
0
    def setUp(self):

        ref_path = config.ROOT + "/resource/yuv/checkerboard_1920_1080_10_3_0_0.yuv"
        dis_path = config.ROOT + "/resource/yuv/checkerboard_1920_1080_10_3_1_0.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': 1920,
                          'height': 1080
                      })

        self.runner = VmafLegacyQualityRunner(
            [asset],
            None,
            fifo_mode=True,
            delete_workdir=True,
            result_store=FileSystemResultStore(),
        )
        self.runner.run()

        self.result = self.runner.results[0]
Example #23
0
    def test_run_vmaf_runner_with_notyuv(self):

        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_30_480_1050.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 360,
                          'quality_height': 240,
                      })
        self.runner = VmafQualityRunner(
            [asset],
            None,
            fifo_mode=True,
            delete_workdir=True,
            result_store=None,
            optional_dict={
                'model_filepath':
                VmafConfig.model_path("vmaf_float_v0.6.1.json"),
            },
        )
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               77.61273448644646,
                               places=4)
Example #24
0
    def test_run_psnr_runner_with_notyuv(self):
        ref_path = VmafConfig.test_resource_path(
            "tiff", "src01_hrc00_576x324%05d.tiff", bypass_download=True)
        dis_path = VmafConfig.test_resource_path(
            "tiff", "src01_hrc01_576x324%05d.tiff", bypass_download=True)
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 576,
                          'quality_height': 324,
                      })
        self.runner = PsnrQualityRunner([asset],
                                        None,
                                        fifo_mode=False,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        pprint.pprint(results[0]['PSNR_scores'])
        pprint.pprint(results[0]['PSNR_score'])
        self.assertAlmostEqual(results[0]['PSNR_score'], 32.12685675, places=4)
    def test_noref_moment_fextractor(self):
        print 'test on running Moment noref feature extractor on Assets...'
        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 = MomentNorefFeatureExtractor([asset, asset_original],
                                                      None,
                                                      fifo_mode=True,
                                                      result_store=None)
        self.fextractor.run()

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'],
                               61.332006624999984)
        self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'],
                               4798.659574041666)
        self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'],
                               1036.8371843488285)

        self.assertAlmostEqual(results[1]['Moment_noref_feature_1st_score'],
                               59.788567297525134)
        self.assertAlmostEqual(results[1]['Moment_noref_feature_2nd_score'],
                               4696.668388042271)
        self.assertAlmostEqual(results[1]['Moment_noref_feature_var_score'],
                               1121.519917231207)
Example #26
0
    def test_run_strred_fextractor_blackframes(self):
        print 'test on running STRRED feature extractor on flat frames...'
        ref_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_0.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "flat_1920_1080_10.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

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

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

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

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

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

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

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

        self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'], 1220.5679849999999, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'], 50983.3097155, places=4)
        self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'], 62228595.6081, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'], 0.0, places=4)
        self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'], 0.0, places=4)
Example #27
0
    def test_feature_assembler_selected_atom_feature(self):
        print 'test on feature assembler with selected atom features...'
        ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={'width':576, 'height':324})

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

        self.fassembler = FeatureAssembler(
            feature_dict={'VMAF_feature':['vif', 'motion']},
            feature_option_dict=None,
            assets=[asset, asset_original],
            logger=None,
            fifo_mode=True,
            delete_workdir=True,
            result_store=None,
            optional_dict=None,
            optional_dict2=None,
            parallelize=True,
        )

        self.fassembler.run()

        results = self.fassembler.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44609306249999997, places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 4.0498253541666669, places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0, places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 4.0498253541666669, places=4)

        with self.assertRaises(KeyError):
            results[0]['VMAF_feature_ansnr_scores']
        with self.assertRaises(KeyError):
            results[0]['VMAF_feature_ansnr_score']
        with self.assertRaises(KeyError):
            results[0]['VMAF_feature_adm_scores']
        with self.assertRaises(KeyError):
            results[0]['VMAF_feature_adm_score']
Example #28
0
    def test_pad_cmd(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':720, 'quality_height':320,
                                  'yuv_type':'yuv422p',
                                  'pad_cmd':'iw+6:ih+4:3:2'})
        self.assertEquals(asset.pad_cmd, 'iw+6:ih+4:3:2')
        self.assertEquals(str(asset), "test_0_0__720x480_yuv422p_vs__720x480_yuv422p_q_720x320_padiw+6:ih+4:3:2")

        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':720, 'quality_height':320,
                                  'yuv_type':'yuv422p',})
        self.assertTrue(asset.pad_cmd is None)
        self.assertEquals(str(asset), "test_0_0__720x480_yuv422p_vs__720x480_yuv422p_q_720x320")
Example #29
0
    def test_resampling_type(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'fps':24, 'start_sec':2, 'end_sec': 3})
        self.assertEquals(asset.resampling_type, 'bicubic')

        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'fps':24, 'start_sec':2, 'end_sec': 3,
                                  'resampling_type':'lanczos'})
        self.assertEquals(asset.resampling_type, 'lanczos')

        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'fps':24, 'start_sec':2, 'end_sec': 3,
                                  'resampling_type':'bicubic'})
        self.assertEquals(asset.resampling_type, 'bicubic')
Example #30
0
 def test_to_normalized_dict(self):
     asset = Asset(dataset="test", content_id=0, asset_id=0,
                   ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                   asset_dict={'width':720, 'height':480,
                               'start_frame':2, 'end_frame':2})
     self.assertEquals(
         asset.to_normalized_dict(),
         {
             'asset_dict': {'end_frame': 2, 'height': 480, 'start_frame': 2, 'width': 720},
             'asset_id': 0,
             'content_id': 0,
             'dataset': 'test',
             'dis_path': 'disvideo.yuv',
             'ref_path': 'refvideo.yuv',
             'workdir': ''
         }
     )
Example #31
0
 def test_to_normalized_dict(self):
     asset = Asset(dataset="test", content_id=0, asset_id=0,
                   ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                   asset_dict={'width':720, 'height':480,
                               'start_frame':2, 'end_frame':2})
     self.assertEquals(
         asset.to_normalized_dict(),
         {
             'asset_dict': {'end_frame': 2, 'height': 480, 'start_frame': 2, 'width': 720},
             'asset_id': 0,
             'content_id': 0,
             'dataset': 'test',
             'dis_path': 'disvideo.yuv',
             'ref_path': 'refvideo.yuv',
             'workdir': ''
         }
     )
Example #32
0
 def test_workdir_root(self):
     asset = Asset(dataset="test",
                   content_id=0,
                   asset_id=0,
                   ref_path="",
                   dis_path="",
                   asset_dict={},
                   workdir_root="my_workdir_root")
     self.assertEquals(asset.workdir_root, "my_workdir_root")
Example #33
0
    def test_copy(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="", dis_path="",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':720, 'quality_height':320,
                                  'yuv_type':'yuv422p',
                                  'crop_cmd':'570:320:3:2'})
        new_asset = asset.copy()
        self.assertEquals(asset, new_asset)
        self.assertTrue(asset == new_asset)
        self.assertNotEquals(id(asset), id(new_asset))

        new_asset.asset_dict['yuv_type'] = 'yuv444p'
        self.assertNotEquals(asset, new_asset)

        new_asset2 = asset.copy(content_id=2)
        self.assertFalse(asset == new_asset2)
        self.assertEquals(new_asset2.content_id, 2)
        self.assertEquals(new_asset2.asset_id, 0)
Example #34
0
    def test_use_path_as_workpath(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'start_frame':2, 'end_frame':2,
                                  'quality_width':1920, 'quality_height':1080},
                      workdir_root="workdir")
        expected_ref_workfile_path_re = \
            r"^workdir/[a-zA-Z0-9-]+/" \
            r"ref_test_0_0_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_1920x1080"
        expected_dis_workfile_path_re = \
            r"^workdir/[a-zA-Z0-9-]+/" \
            r"dis_test_0_0_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_1920x1080"
        self.assertTrue(re.match(expected_ref_workfile_path_re, asset.ref_workfile_path))
        self.assertTrue(re.match(expected_dis_workfile_path_re, asset.dis_workfile_path))
        self.assertFalse('use_path_as_workpath' in asset.asset_dict)

        asset.use_path_as_workpath = True
        self.assertTrue('use_path_as_workpath' in asset.asset_dict)
        self.assertTrue(asset.asset_dict['use_path_as_workpath'])
        self.assertEquals(asset.ref_workfile_path, 'dir/refvideo.yuv')
        self.assertEquals(asset.dis_workfile_path, 'dir/disvideo.yuv')
Example #35
0
    def from_dataframe(cls, df):

        # first, make sure the df conform to the format for a single asset
        cls._assert_asset_dataframe(df)

        asset_repr = df.iloc[0]['asset']
        asset = Asset.from_repr(asset_repr)

        executor_id = df.iloc[0]['executor_id']

        result_dict = {}
        for _, row in df.iterrows():
            result_dict[row['scores_key']] = row['scores']

        return Result(asset, executor_id, result_dict)
Example #36
0
    def test_str_repr(self):
        asset = Asset(dataset="test", content_id=0, asset_id=0,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'start_frame':2, 'end_frame':2})
        self.assertEquals(
            str(asset),
            "test_0_0_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_720x480"
        )
        expected_repr = '{"asset_dict": {"end_frame": 2, "height": 480, "start_frame": 2, "width": 720}, "asset_id": 0, "content_id": 0, "dataset": "test", "dis_path": "disvideo.yuv", "ref_path": "refvideo.yuv", "workdir": ""}' # noqa
        self.assertEquals(repr(asset), expected_repr)
        recon_asset = Asset.from_repr(expected_repr)
        self.assertEquals(asset, recon_asset)
        self.assertTrue(asset == recon_asset)
        self.assertFalse(asset != recon_asset)

        self.assertEquals(asset.to_normalized_repr(), expected_repr)

        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,})
        self.assertEquals(
            str(asset),
            "test_0_1_refvideo_720x480_vs_disvideo_720x480_q_720x480"
        )
        expected_repr = '{"asset_dict": {"height": 480, "width": 720}, "asset_id": 1, "content_id": 0, "dataset": "test", "dis_path": "disvideo.yuv", "ref_path": "refvideo.yuv", "workdir": ""}'
        self.assertEquals(repr(asset), expected_repr)
        recon_asset = Asset.from_repr(expected_repr)
        self.assertEquals(asset, recon_asset)

        asset = Asset(dataset="test", content_id=0, asset_id=2,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':1920, 'quality_height':1080})
        self.assertEquals(
            str(asset),
            "test_0_2_refvideo_720x480_vs_disvideo_720x480_q_1920x1080"
        )
        expected_repr = '{"asset_dict": {"height": 480, "quality_height": 1080, "quality_width": 1920, "width": 720}, "asset_id": 2, "content_id": 0, "dataset": "test", "dis_path": "disvideo.yuv", "ref_path": "refvideo.yuv", "workdir": ""}' # noqa
        self.assertEquals(repr(asset), expected_repr)
        recon_asset = Asset.from_repr(expected_repr)
        self.assertEquals(asset, recon_asset)

        asset = Asset(dataset="test", content_id=0, asset_id=2,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':1920, 'quality_height':1080,
                                  'yuv_type':'yuv422p'})
        self.assertEquals(
            str(asset),
            "test_0_2_refvideo_720x480_yuv422p_vs_disvideo_720x480_yuv422p_q_1920x1080"
        )
        expected_repr = '{"asset_dict": {"height": 480, "quality_height": 1080, "quality_width": 1920, "width": 720, "yuv_type": "yuv422p"}, "asset_id": 2, "content_id": 0, "dataset": "test", "dis_path": "disvideo.yuv", "ref_path": "refvideo.yuv", "workdir": ""}' # noqa
        self.assertEquals(repr(asset), expected_repr)
        recon_asset = Asset.from_repr(expected_repr)
        self.assertEquals(asset, recon_asset)

        asset = Asset(dataset="test", content_id=0, asset_id=2,
                      ref_path="dir/refvideo.yuv", dis_path="dir/disvideo.yuv",
                      asset_dict={'width':720, 'height':480,
                                  'quality_width':1920, 'quality_height':1080,
                                  'resampling_type':'lanczos'})
        self.assertEquals(
            str(asset),
            "test_0_2_refvideo_720x480_vs_disvideo_720x480_q_1920x1080_lanczos"
        )
        expected_repr = '{"asset_dict": {"height": 480, "quality_height": 1080, "quality_width": 1920, "resampling_type": "lanczos", "width": 720}, "asset_id": 2, "content_id": 0, "dataset": "test", "dis_path": "disvideo.yuv", "ref_path": "refvideo.yuv", "workdir": ""}' # noqa
        self.assertEquals(repr(asset), expected_repr)
        recon_asset = Asset.from_repr(expected_repr)
        self.assertEquals(asset, recon_asset)