def test_long_string(self): asset = Asset(dataset="test", content_id=0, asset_id=0, ref_path='a'*128, dis_path='b'*128, asset_dict={'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'ref_pad_cmd': 'iw+6:ih+4:3:2'}) self.assertEqual(str(asset), "4a67755df3b8c599c9016a6d03171392ddfbf9c2") asset = Asset(dataset="test", content_id=0, asset_id=0, ref_path='a'*60, dis_path='b'*60, asset_dict={'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'ref_pad_cmd': 'iw+6:ih+4:3:2'}) self.assertEqual(str(asset), "test_0_0_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_720x480_yuv422p_padiw_6_ih_4_3_2_vs_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb_720x480_yuv422p_q_720x320") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path='a'*128, asset_dict={'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'ref_pad_cmd': 'iw+6:ih+4:3:2'}) self.assertEqual(str(asset), "c4e39ac05957dbb235b86397e3ae9e0a7551aa8f") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path='b'*60, asset_dict={'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'ref_pad_cmd': 'iw+6:ih+4:3:2'}) self.assertEqual(str(asset), "test_0_0_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb_720x480_yuv422p_padiw_6_ih_4_3_2_vs_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb_720x480_yuv422p_q_720x320")
def test_run_noref_niqe_fextractor(self): print 'test on running NIQE noref feature extractor...' ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv") dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width':576, 'height':324,}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=2, workdir_root=VmafConfig.workdir_path(), dis_path=ref_path, asset_dict={'width':576, 'height':324,}) self.fextractor = NiqeNorefFeatureExtractor( [asset, asset_original], None, fifo_mode=False, result_store=None ) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha23_score'], 0.8168807870370377, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha13_score'], 0.6949641203703707, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha_m1_score'], 2.0924143518518536, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_blbr1_score'], 0.72958634325785898, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha23_score'], 0.89566087962963026, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha13_score'], 0.85539583333333391, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha_m1_score'], 2.7192025462962985, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_blbr1_score'], 0.98723051960738684, places=4)
def test_run_noref_brisque_fextractor(self): print 'test on running BRISQUE noref feature extractor...' ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv") dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width':576, 'height':324,}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=2, workdir_root=VmafConfig.workdir_path(), dis_path=ref_path, asset_dict={'width':576, 'height':324,}) self.fextractor = BrisqueNorefFeatureExtractor( [asset, asset_original], None, fifo_mode=True, result_store=None ) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['BRISQUE_noref_feature_alpha23_score'], 0.78020833333333384, places=4) self.assertAlmostEqual(results[0]['BRISQUE_noref_feature_alpha13_score'], 0.6322500000000002, places=4) self.assertAlmostEqual(results[0]['BRISQUE_noref_feature_N34_score'], -0.0071207420215536723, places=4) self.assertAlmostEqual(results[1]['BRISQUE_noref_feature_alpha23_score'], 0.87156250000000046, places=4) self.assertAlmostEqual(results[1]['BRISQUE_noref_feature_alpha13_score'], 0.82906250000000103, places=4) self.assertAlmostEqual(results[1]['BRISQUE_noref_feature_N34_score'], -0.0092448158862212092, places=4)
def test_copy_noref(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, 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)
def test_noref_moment_fextractor_with_noref_asset(self): print 'test on running Moment noref feature extractor on NorefAssets...' ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv") dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width':576, 'height':324}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_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_run_noref_niqe_fextractor_with_patch_size(self): print 'test on running NIQE noref feature extractor with custom patch size...' ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv") dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width':576, 'height':324}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=2, workdir_root=VmafConfig.workdir_path(), dis_path=ref_path, asset_dict={'width':576, 'height':324}) self.fextractor = NiqeNorefFeatureExtractor( [asset, asset_original], None, fifo_mode=False, result_store=None, optional_dict={'patch_size': 48}, optional_dict2=None, ) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha23_score'], 0.8430156250000006, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha13_score'], 0.71714583333333359, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha_m1_score'], 2.2195590277777795, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_blbr1_score'], 0.74061215376929412, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha23_score'], 0.9144918981481488, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha13_score'], 0.87132291666666728, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha_m1_score'], 2.8193532986111136, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_blbr1_score'], 0.99354006450609134, places=4)
def test_run_noref_niqe_fextractor_train(self): print 'test on running NIQE noref feature extractor in train mode...' ref_path = VmafConfig.test_resource_path("yuv", "src01_hrc00_576x324.yuv") dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width':576, 'height':324,}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=2, workdir_root=VmafConfig.workdir_path(), dis_path=ref_path, asset_dict={'width':576, 'height':324,}) self.fextractor = NiqeNorefFeatureExtractor( [asset, asset_original], None, fifo_mode=False, result_store=None, optional_dict={'mode': 'train'}, optional_dict2=None, ) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha23_score'], 0.97259000000000073, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha13_score'], 0.80907000000000051, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_alpha_m1_score'], 2.6135250000000019, places=4) self.assertAlmostEqual(results[0]['NIQE_noref_feature_blbr1_score'], 0.9150526409258144, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha23_score'], 0.97447727272727347, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha13_score'], 0.89120909090909162, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_alpha_m1_score'], 3.0300909090909118, places=4) self.assertAlmostEqual(results[1]['NIQE_noref_feature_blbr1_score'], 1.0508255408831713, places=4)
def test_clear_up_width_height(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={'width':720, 'height':480, 'quality_width':720, 'quality_height':320, 'yuv_type':'yuv422p', 'crop_cmd':'570:320:3:2'}) self.assertEquals(asset.dis_width_height, (720, 480)) asset.clear_up_width_height() self.assertEquals(asset.dis_width_height, None)
def test_clear_up_width_height(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={'width':720, 'height':480, 'quality_width':720, 'quality_height':320, 'yuv_type':'yuv422p', 'crop_cmd':'570:320:3:2'}) self.assertEquals(asset.dis_width_height, (720, 480)) asset.clear_up_width_height() self.assertEquals(asset.dis_width_height, None)
def test_NorefAsset_copy_as_Asset(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", 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(ref_path='xyz') self.assertEquals(new_asset.ref_path, 'abc') new_asset2 = asset.copy_as_Asset(ref_path='xyz') self.assertEquals(new_asset2.ref_path, 'xyz')
def test_NorefAsset_copy_as_Asset(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", 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(ref_path='xyz') self.assertEquals(new_asset.ref_path, 'abc') new_asset2 = asset.copy_as_Asset(ref_path='xyz') self.assertEquals(new_asset2.ref_path, 'xyz')
def test_clear_up_start_end_frame(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={ 'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'start_frame': 23, 'end_frame': 25 }) self.assertEquals(asset.dis_start_end_frame, (23, 25)) asset.clear_up_start_end_frame() self.assertEquals(asset.dis_start_end_frame, None) asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={ 'width': 720, 'height': 480, 'quality_width': 720, 'quality_height': 320, 'yuv_type': 'yuv422p', 'fps': 5, 'duration_sec': 10 }) self.assertEquals(asset.dis_start_end_frame, (0, 49)) asset.clear_up_start_end_frame() self.assertEquals(asset.dis_start_end_frame, None)
def set_default_576_324_noref_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 = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width': 576, 'height': 324}) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=VmafConfig.workdir_path(), dis_path=ref_path, asset_dict={'width': 576, 'height': 324}) return ref_path, dis_path, asset, asset_original
def test_noref_moment_fextractor_with_noref_asset_notyuv(self): print 'test on running Moment noref feature extractor on NorefAssets ' \ '(non-YUV)...' dis_path = VmafConfig.test_resource_path("mp4", "Seeking_10_288_375.mp4") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={ 'yuv_type': 'notyuv', 'quality_width': 720, 'quality_height': 480, }) self.fextractor = MomentNorefFeatureExtractor([asset], None, fifo_mode=True, result_store=None) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'], 63.763580381944436, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'], 5158.9407083526221, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'], 1084.1635630076041, places=4)
def test_notyuv_noref(self): with self.assertRaises(AssertionError): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="", asset_dict={ 'yuv_type': 'notyuv', 'workfile_yuv_type': 'yuv4444p' }) asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="", asset_dict={ 'yuv_type': 'notyuv', 'workfile_yuv_type': 'yuv422p' }) self.assertEqual(asset.workfile_yuv_type, 'yuv422p')
def test_noref_moment_fextractor_with_noref_asset_notyuv_gaussianblur( self): dis_path = VmafConfig.test_resource_path("mp4", "Seeking_10_288_375.mp4") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={ 'yuv_type': 'notyuv', 'quality_width': 720, 'quality_height': 480, 'gblur_cmd': 'sigma=0.01:steps=1', }) self.fextractor = MomentNorefFeatureExtractor([asset], None, fifo_mode=True, result_store=None) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'], 63.273978452932084, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'], 5124.572291840278, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'], 1111.9962740092349, places=4)
def test_noref_moment_fextractor_frames(self): dis_path = VmafConfig.test_resource_path("yuv", "src01_hrc01_576x324.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={ 'width': 576, 'height': 324, 'start_frame': 2, 'end_frame': 2, }) self.fextractor = MomentNorefFeatureExtractor( [asset], None, fifo_mode=False, # TODO python3: fifo mode fails in py3, needs fix result_store=None) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'], 62.315495327503427, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'], 4888.7623296039092, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'], 1005.5413716918079, places=4)
def test_noref_moment_fextractor_with_noref_asset_notyuv(self): dis_path = VmafConfig.test_resource_path("mp4", "Seeking_10_288_375.mp4") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={ 'yuv_type': 'notyuv', 'quality_width': 720, 'quality_height': 480, }) self.fextractor = MomentNorefFeatureExtractor( [asset], None, fifo_mode=False, # TODO python3: fifo mode fails in py3, needs fix result_store=None) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'], 63.776442013888882, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'], 5194.9118422453694, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'], 1118.4952858425261, places=4)
def test_noref_moment_fextractor_with_noref_asset_notyuv_gaussianblur( self): dis_path = VmafConfig.test_resource_path("mp4", "Seeking_10_288_375.mp4") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={ 'yuv_type': 'notyuv', 'quality_width': 720, 'quality_height': 480, 'gblur_cmd': 'sigma=0.01:steps=1', }) self.fextractor = MomentNorefFeatureExtractor([asset], None, fifo_mode=False, result_store=None) self.fextractor.run() results = self.fextractor.results self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'], 63.25902145061728, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'], 5123.705637307099, places=4) self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'], 1113.0346638689637, places=4)
def set_default_cambi_video_for_testing(): dis_path = VmafConfig.test_resource_path("yuv", "blue_sky_360p_60f.yuv") asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=VmafConfig.workdir_path(), dis_path=dis_path, asset_dict={'width': 640, 'height': 360, 'yuv_type': 'yuv420p'}) return dis_path, asset
def test_run_parallel_moment_noref_fextractor(self): print 'test on running Moment noref feature extractor on NorefAssets in parallel...' ref_path = config.ROOT + "/resource/yuv/src01_hrc00_576x324.yuv" dis_path = config.ROOT + "/resource/yuv/src01_hrc01_576x324.yuv" asset = NorefAsset(dataset="test", content_id=0, asset_id=0, workdir_root=config.ROOT + "/workspace/workdir", dis_path=dis_path, asset_dict={ 'width': 576, 'height': 324 }) asset_original = NorefAsset(dataset="test", content_id=0, asset_id=1, workdir_root=config.ROOT + "/workspace/workdir", dis_path=ref_path, asset_dict={ 'width': 576, 'height': 324 }) self.fextractors, results = run_executors_in_parallel( MomentNorefFeatureExtractor, [asset, asset_original], fifo_mode=True, delete_workdir=True, parallelize=True, result_store=None, ) 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_copy_noref(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, 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)
def test_clear_up_start_end_frame(self): asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={'width':720, 'height':480, 'quality_width':720, 'quality_height':320, 'yuv_type':'yuv422p', 'start_frame': 23, 'end_frame': 25}) self.assertEquals(asset.dis_start_end_frame, (23, 25)) asset.clear_up_start_end_frame() self.assertEquals(asset.dis_start_end_frame, None) asset = NorefAsset(dataset="test", content_id=0, asset_id=0, dis_path="abc", asset_dict={'width':720, 'height':480, 'quality_width':720, 'quality_height':320, 'yuv_type':'yuv422p', 'fps': 5, 'duration_sec': 10}) self.assertEquals(asset.dis_start_end_frame, (0, 49)) asset.clear_up_start_end_frame() self.assertEquals(asset.dis_start_end_frame, None)