def test_run_parallel_ssim_fextractor(self): print 'test on running SSIM feature extractor in parallel...' 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.fextractors, results = run_executors_in_parallel( SsimFeatureExtractor, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None, ) 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_parallel_moment_fextractor(self): print 'test on running Moment feature extractor in parallel...' 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.fextractors, results = run_executors_in_parallel( MomentFeatureExtractor, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None, ) self.assertAlmostEqual(results[0]['Moment_feature_ref1st_score'], 59.788567297525134) self.assertAlmostEqual(results[0]['Moment_feature_ref2nd_score'], 4696.668388042269) self.assertAlmostEqual(results[0]['Moment_feature_refvar_score'], 1121.519917231203) self.assertAlmostEqual(results[0]['Moment_feature_dis1st_score'], 61.332006624999984) self.assertAlmostEqual(results[0]['Moment_feature_dis2nd_score'], 4798.659574041666) self.assertAlmostEqual(results[0]['Moment_feature_disvar_score'], 1036.837184348847) self.assertAlmostEqual(results[1]['Moment_feature_ref1st_score'], 59.788567297525134) self.assertAlmostEqual(results[1]['Moment_feature_ref2nd_score'], 4696.668388042269) self.assertAlmostEqual(results[1]['Moment_feature_refvar_score'], 1121.519917231203) self.assertAlmostEqual(results[1]['Moment_feature_dis1st_score'], 59.788567297525134) self.assertAlmostEqual(results[1]['Moment_feature_dis2nd_score'], 4696.668388042269) self.assertAlmostEqual(results[1]['Moment_feature_disvar_score'], 1121.519917231203)
def test_run_vmaf_legacy_runner_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.runner = VmafLegacyQualityRunner([asset, asset_original], None, fifo_mode=True)
def test_run_parallel_psnr_runner(self): print 'test on running PSNR quality runner in parallel...' 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.runners, results = run_executors_in_parallel( PsnrQualityRunner, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None) self.assertAlmostEqual(results[0]['PSNR_score'], 30.755063979166664) self.assertAlmostEqual(results[1]['PSNR_score'], 60.0)
def test_explain_vmaf_results(self): print 'test on running VMAF runner with local explainer...' 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.runner = VmafQualityRunnerWithLocalExplainer( [asset, asset_original], None, fifo_mode=True, delete_workdir=True, result_store=None, optional_dict2={'explainer': LocalExplainer(neighbor_samples=100)} ) np.random.seed(0) self.runner.run() results = self.runner.results self.assertAlmostEqual(results[0]['VMAF_score'], 65.4488588759, places=4) self.assertAlmostEqual(results[1]['VMAF_score'], 99.2259317881, places=4) expected_feature_names = ['VMAF_feature_adm2_score', 'VMAF_feature_motion_score', 'VMAF_feature_vif_scale0_score', 'VMAF_feature_vif_scale1_score', 'VMAF_feature_vif_scale2_score', 'VMAF_feature_vif_scale3_score'] weights = np.mean(results[0]['VMAF_scores_exps']['feature_weights'], axis=0) self.assertAlmostEqual(weights[0], 0.75441663, places=4) self.assertAlmostEqual(weights[1], 0.06816105, places=4) self.assertAlmostEqual(weights[2], -0.10934421, places=4) self.assertAlmostEqual(weights[3], 0.22051127, places=4) self.assertAlmostEqual(weights[4], 0.12517884, places=4) self.assertAlmostEqual(weights[5], 0.04639162, places=4) self.assertEqual(results[0]['VMAF_scores_exps']['feature_names'], expected_feature_names) weights = np.mean(results[1]['VMAF_scores_exps']['feature_weights'], axis=0) self.assertAlmostEqual(weights[0], 0.77096087, places=4) self.assertAlmostEqual(weights[1], 0.01491754, places=4) self.assertAlmostEqual(weights[2], -0.08025557, places=4) self.assertAlmostEqual(weights[3], 0.2511188, places=4) self.assertAlmostEqual(weights[4], 0.14953561, places=4) self.assertAlmostEqual(weights[5], 0.07960753, places=4) self.assertEqual(results[1]['VMAF_scores_exps']['feature_names'], expected_feature_names)
def test_duration_sec(self): asset = Asset( dataset="test", content_id=0, asset_id=0, ref_path="", dis_path="", asset_dict={ 'ref_start_frame': 2, 'ref_end_frame': 2, 'dis_start_frame': 3, 'dis_end_frame': 3 }, ) self.assertEquals(asset.ref_duration_sec, None) self.assertEquals(asset.dis_duration_sec, None) asset = Asset( dataset="test", content_id=0, asset_id=0, ref_path="", dis_path="", asset_dict={ 'ref_start_frame': 0, 'ref_end_frame': 23, 'dis_start_frame': 3, 'dis_end_frame': 26, 'fps': 24 }, ) self.assertEquals(asset.ref_duration_sec, 1.0) self.assertEquals(asset.dis_duration_sec, 1.0)
def test_run_vmaf_runner_flat(self): print 'test on running VMAF runner on flat pattern...' ref_path = config.ROOT + "/resource/yuv/flat_1920_1080_0.yuv" dis_path = config.ROOT + "/resource/yuv/flat_1920_1080_10.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 }) 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': 1920, 'height': 1080 }) self.runner = VmafQualityRunner( [asset, asset_original], None, fifo_mode=True, delete_workdir=True, result_store=self.result_store, ) self.runner.run() results = self.runner.results self.assertAlmostEqual(results[0]['VMAF_score'], 99.419836087060176) self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale0_score'], 1.0) self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale1_score'], 1.0) self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale2_score'], 1.0) self.assertAlmostEqual(results[0]['VMAF_feature_vif_scale3_score'], 1.0) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 0.0) self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_score'], 99.419836087060176) self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale0_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale1_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale2_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_vif_scale3_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 0.0) self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0)
def test_to_normalized_dict_10le(self): asset = Asset(dataset="test", content_id=0, asset_id=0, ref_path="dir/refvideo.yuv420p10le.yuv", dis_path="dir/disvideo.yuv420p10le.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.yuv420p10le.yuv', 'ref_path': 'refvideo.yuv420p10le.yuv', 'workdir': '' })
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')
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_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))
def test_run_asset_extractor(self): print 'test on running asset 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=1, workdir_root=config.ROOT + "/workspace/workdir", ref_path=ref_path, dis_path=dis_path, asset_dict={ 'width': 576, 'height': 324, 'quality_width': 160, 'quality_height': 90 }) asset_original = Asset(dataset="test", content_id=0, asset_id=2, workdir_root=config.ROOT + "/workspace/workdir", ref_path=ref_path, dis_path=ref_path, asset_dict={ 'width': 576, 'height': 324, 'quality_width': 160, 'quality_height': 90 }) self.fextractor = AssetExtractor([asset, asset_original], None, fifo_mode=True) self.fextractor.run() results = self.fextractor.results self.assertEqual( str(results[0]['asset']), 'test_0_1_src01_hrc00_576x324_576x324_vs_src01_hrc01_576x324_576x324_q_160x90' ) self.assertEqual( str(results[1]['asset']), 'test_0_2_src01_hrc00_576x324_576x324_vs_src01_hrc00_576x324_576x324_q_160x90' ) self.fextractor.run(parallelize=True) results = self.fextractor.results self.assertEqual( str(results[0]['asset']), 'test_0_1_src01_hrc00_576x324_576x324_vs_src01_hrc01_576x324_576x324_q_160x90' ) self.assertEqual( str(results[1]['asset']), 'test_0_2_src01_hrc00_576x324_576x324_vs_src01_hrc00_576x324_576x324_q_160x90' )
def test_feature_assembler_selected_atom_feature(self): print 'test on feature assembler with selected atom features...' 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.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, parallelize=True, ) self.fassembler.run() results = self.fassembler.results self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667) 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']
def test_run_parallel_ms_ssim_fextractor(self): print 'test on running MS-SSIM feature extractor in parallel...' 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.fextractors, results = run_executors_in_parallel( MsSsimFeatureExtractor, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None, ) 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)
def test_run_vmaf_runner_with_rf_model(self): print 'test on running VMAF runner with custom input model...' 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.runner = VmafQualityRunner( [asset, asset_original], None, fifo_mode=True, delete_workdir=True, result_store=self.result_store, optional_dict={ 'model_filepath': config.ROOT + "/resource/model/nflx_vmaff_rf_v1.pkl", }) self.runner.run() results = self.runner.results self.assertAlmostEqual(results[0]['VMAF_score'], 73.79861111111113) self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[0]['VMAF_feature_adm_score'], 0.9155242291666666) self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329) self.assertAlmostEqual(results[1]['VMAF_score'], 98.22048611111109) self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[1]['VMAF_feature_adm_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322)
def test_run_parallel_dis_y_fextractor(self): print 'test on running dis YUV raw video extractor in parallel (disabled)...' 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=1, 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=2, workdir_root=config.ROOT + "/workspace/workdir", ref_path=ref_path, dis_path=ref_path, asset_dict={ 'width': 576, 'height': 324 }) h5py_file = DisYUVRawVideoExtractor.open_h5py_file(self.h5py_filepath) optional_dict2 = {'h5py_file': h5py_file} self.fextractors, results = run_executors_in_parallel( DisYUVRawVideoExtractor, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=False, # Can't run parallel: can't pickle FileID objects result_store=None, optional_dict={'channels': 'yu'}, optional_dict2=optional_dict2) self.assertAlmostEqual(np.mean(results[0]['dis_y']), 61.332006579182384, places=4) self.assertAlmostEquals(np.mean(results[1]['dis_y']), 59.788567297525148, places=4) self.assertAlmostEqual(np.mean(results[0]['dis_u']), 115.23227407335962, places=4) self.assertAlmostEquals(np.mean(results[1]['dis_u']), 114.49701717535437, places=4) with self.assertRaises(KeyError): np.mean(results[0]['dis_v']) DisYUVRawVideoExtractor.close_h5py_file(h5py_file)
def test_feature_assembler_whole_feature(self): print 'test on feature assembler with whole feature...' 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.fassembler = FeatureAssembler( feature_dict={'VMAF_feature': 'all'}, feature_option_dict=None, assets=[asset, asset_original], logger=None, fifo_mode=True, delete_workdir=True, result_store=None, parallelize=True, ) self.fassembler.run() results = self.fassembler.results self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'], 0.9254334398006141) self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329) self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322)
def test_run_dis_yuv_raw_video_extractor(self): print 'test on running dis YUV raw video 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=1, 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=2, workdir_root=config.ROOT + "/workspace/workdir", ref_path=ref_path, dis_path=ref_path, asset_dict={ 'width': 576, 'height': 324 }) h5py_file = DisYUVRawVideoExtractor.open_h5py_file(self.h5py_filepath) self.fextractor = DisYUVRawVideoExtractor( [asset, asset_original], None, fifo_mode=False, optional_dict={'channels': 'yu'}, optional_dict2={'h5py_file': h5py_file}) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(np.mean(results[0]['dis_y']), 61.332006579182384, places=4) self.assertAlmostEquals(np.mean(results[1]['dis_y']), 59.788567297525148, places=4) self.assertAlmostEqual(np.mean(results[0]['dis_u']), 115.23227407335962, places=4) self.assertAlmostEquals(np.mean(results[1]['dis_u']), 114.49701717535437, places=4) with self.assertRaises(KeyError): np.mean(results[0]['dis_v']) DisYUVRawVideoExtractor.close_h5py_file(h5py_file)
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_legacy_runner_10le(self): print 'test on running VMAF (legacy) runner on 10 bit le...' ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv422p10le.yuv" dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv422p10le.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, 'yuv_type': 'yuv422p10le' }) 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, 'yuv_type': 'yuv422p10le' }) self.runner = VmafLegacyQualityRunner([asset, asset_original], None, fifo_mode=False, delete_workdir=True, result_store=None) self.runner.run() results = self.runner.results self.assertAlmostEqual(results[0]['VMAF_legacy_score'], 60.27316952679754) self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[0]['VMAF_feature_adm_score'], 0.9155242291666666) self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329) self.assertAlmostEqual(results[1]['VMAF_legacy_score'], 95.65756240092573) self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[1]['VMAF_feature_adm_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322)
def test_start_end_frame(self): asset = Asset( dataset="test", content_id=0, asset_id=0, ref_path="", dis_path="", asset_dict={ 'ref_start_frame': 2, 'ref_end_frame': 2, 'dis_start_frame': 3, 'dis_end_frame': 3 }, ) self.assertEquals(asset.ref_start_end_frame, (2, 2)) self.assertEquals(asset.dis_start_end_frame, (3, 3)) asset = Asset(dataset="test", content_id=0, asset_id=0, ref_path="", dis_path="", asset_dict={ 'start_frame': 2, 'end_frame': 2 }) self.assertEquals(asset.ref_start_end_frame, (2, 2)) self.assertEquals(asset.dis_start_end_frame, (2, 2)) asset = Asset(dataset="test", content_id=0, asset_id=0, ref_path="", dis_path="", asset_dict={ 'fps': 24, 'duration_sec': 2 }) self.assertEquals(asset.ref_start_end_frame, (0, 47)) self.assertEquals(asset.dis_start_end_frame, (0, 47)) 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.ref_start_end_frame, (48, 71)) self.assertEquals(asset.dis_start_end_frame, (48, 71))
def test_run_strred_fextractor(self): print 'test on running STRRED 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 = StrredFeatureExtractor([asset, asset_original], None, fifo_mode=True, result_store=None) self.fextractor.run(parallelize=True) results = self.fextractor.results self.assertAlmostEqual(results[0]['STRRED_feature_srred_score'], 4.8845008541666664, places=4) self.assertAlmostEqual(results[0]['STRRED_feature_trred_score'], 8.9429378333333336, places=4) self.assertAlmostEqual(results[0]['STRRED_feature_strred_score'], 44.002554138184131, places=4) self.assertAlmostEqual(results[1]['STRRED_feature_srred_score'], 0.0, places=4) self.assertAlmostEqual(results[1]['STRRED_feature_trred_score'], 0.0, places=4) self.assertAlmostEqual(results[1]['STRRED_feature_strred_score'], 0.0, places=4)
def test_run_parallel_vmaf_legacy_runner(self): print 'test on running VMAF (legacy) quality runner in parallel...' 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.runners, results = run_executors_in_parallel( VmafLegacyQualityRunner, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None) self.assertAlmostEqual(results[0]['VMAF_legacy_score'], 60.27316952679754) self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'], 0.44455808333333313) self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[0]['VMAF_feature_adm_score'], 0.9155242291666666) self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'], 22.533456770833329) self.assertAlmostEqual(results[1]['VMAF_legacy_score'], 95.65756240092573) self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'], 3.5916076041666667) self.assertAlmostEqual(results[1]['VMAF_feature_adm_score'], 1.0) self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'], 30.030914145833322)
def test_hash_equal(self): asset1 = 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 }) asset2 = 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 }) asset3 = Asset(dataset="test", content_id=0, asset_id=2, ref_path="my/dir/refvideo.yuv", dis_path="my/dir/disvideo.yuv", asset_dict={ 'width': 720, 'height': 480, 'quality_width': 1920, 'quality_height': 1080 }) asset4 = Asset(dataset="test", content_id=0, asset_id=2, ref_path="my/dir/refvideo.yuv", dis_path="my/dir/disvideo.avi", asset_dict={ 'width': 720, 'height': 480, 'quality_width': 1920, 'quality_height': 1080 }) self.assertTrue(asset1 == asset2) self.assertTrue(asset2 == asset3) self.assertFalse(asset3 == asset4) self.assertTrue(hash(asset2) == hash(asset3)) self.assertFalse(hash(asset1) == hash(asset4))
def test_run_vmafossexec_runner_with_notyuv(self): print 'test on running VMAF runner...' ref_path = config.ROOT + "/python/test/resource/icpf/frame%08d.icpf" dis_path = config.ROOT + "/python/test/resource/icpf/frame%08d.icpf" 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={ 'yuv_type': 'notyuv', 'quality_width': 720, 'quality_height': 480, }) 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'], 98.860796771266365, 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)
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': '' } )
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={}) runner = VmafLegacyQualityRunner([asset], None) self.assertEquals(runner.executor_id, 'VMAF_legacy_V1.0')
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): 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) self.assertTrue(re.match(r"^my_workdir_root/[a-zA-Z0-9-]+/VMAF_feature_V0.2.1_test_0_1_refvideo_720x480_2to2_vs_disvideo_720x480_2to2_q_720x480$", log_file_path))
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))
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')
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)
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": ""}' 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": ""}' 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": ""}' 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": ""}' self.assertEquals(repr(asset), expected_repr) recon_asset = Asset.from_repr(expected_repr) self.assertEquals(asset, recon_asset)