Skip to content

Commit

Permalink
Merge pull request #355 from Netflix/feature/FixBadPush-christos
Browse files Browse the repository at this point in the history
Undo changes caused by bad commits.
  • Loading branch information
christosbampis authored Aug 26, 2019
2 parents b199f2a + 7ddaf2a commit dd3a7f9
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 445 deletions.
55 changes: 0 additions & 55 deletions .newt.yml

This file was deleted.

3 changes: 3 additions & 0 deletions feature/src/common/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ int read_frame(float *ref_data, float *dis_data, float *temp_data, int stride_by
goto fail_or_end;
}

fprintf(stderr, "Frame: %d/%d\r", completed_frames++, user_data->num_frames);


fail_or_end:
return ret;
}
Expand Down
4 changes: 1 addition & 3 deletions python/src/vmaf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def call_vifdiff_feature(yuv_type, ref_path, dis_path, w, h, log_file_path, logg
@staticmethod
def call_vmafossexec(fmt, w, h, ref_path, dis_path, model, log_file_path, disable_clip_score,
enable_transform_score, phone_model, disable_avx, n_thread, n_subsample,
psnr, ssim, ms_ssim, ci, exe=None, logger=None, additional_models=None):
psnr, ssim, ms_ssim, ci, exe=None, logger=None):

if exe is None:
exe = required(ExternalProgram.vmafossexec)
Expand Down Expand Up @@ -194,8 +194,6 @@ def call_vmafossexec(fmt, w, h, ref_path, dis_path, model, log_file_path, disabl
vmafossexec_cmd += ' --ms-ssim'
if ci:
vmafossexec_cmd += ' --ci'
if additional_models is not None:
vmafossexec_cmd += ' --additional-models ' + additional_models
if logger:
logger.info(vmafossexec_cmd)
run_process(vmafossexec_cmd, shell=True)
5 changes: 1 addition & 4 deletions python/src/vmaf/core/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class Executor(TypeVersionEnabled):

__metaclass__ = ABCMeta

# if optional dict is too long, executor_id needs to be trimmed
MAX_CHARS_EX_ID_OPT_DICT = 10

@abstractmethod
def _generate_result(self, asset):
raise NotImplementedError
Expand Down Expand Up @@ -83,7 +80,7 @@ def executor_id(self):
if self.optional_dict is not None and len(self.optional_dict) > 0:
# include optional_dict info in executor_id for result store,
# as parameters in optional_dict will impact result
executor_id_ += '_{}'.format(get_normalized_string_from_dict(self.optional_dict))[0:self.MAX_CHARS_EX_ID_OPT_DICT]
executor_id_ += '_{}'.format(get_normalized_string_from_dict(self.optional_dict))
return executor_id_

def run(self, **kwargs):
Expand Down
42 changes: 10 additions & 32 deletions python/src/vmaf/core/quality_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,44 +675,21 @@ def _generate_result(self, asset):
else:
ci = False

additional_models_dict = self.optional_dict['additional_models'] \
if self.optional_dict is not None and 'additional_models' in self.optional_dict else None

additional_models = None
# augment the feature set, if there are any additional models passed in
if additional_models_dict:
self.FEATURES += additional_models_dict.keys()
# augment also with transformed scores
self.FEATURES += map(lambda k: "{k}_transformed".format(k=k), additional_models_dict.keys())
# get json string for additional models
additional_models = self.get_json_additional_model_string(additional_models_dict)

quality_width, quality_height = asset.quality_width_height

fmt = self._get_workfile_yuv_type(asset)
w = quality_width
h = quality_height
ref_path = asset.ref_workfile_path
dis_path = asset.dis_workfile_path
model = model_filepath
exe = self._get_exec()
fmt=self._get_workfile_yuv_type(asset)
w=quality_width
h=quality_height
ref_path=asset.ref_workfile_path
dis_path=asset.dis_workfile_path
model=model_filepath
exe=self._get_exec()
logger = self.logger

ExternalProgramCaller.call_vmafossexec(fmt, w, h, ref_path, dis_path, model, log_file_path,
disable_clip_score, enable_transform_score,
phone_model, disable_avx, n_thread, n_subsample,
psnr, ssim, ms_ssim, ci, exe, logger, additional_models)

@staticmethod
def get_json_additional_model_string(d):
""" Returns json string representation with sorted keys for additional models.
get_json_additional_model_string({"model A": "/someA/pthA/forA/A.pkl", "model B": "/someB/pthB/forB/B.pkl"})
"""
if d:
return "{{{0}}}".format('\\,'.join(map(lambda k: '\\"{k}\\"\\:\\"{v}\\"'
.format(k=k, v=d[k]), sorted(d.keys()))))
else:
return ""
psnr, ssim, ms_ssim, ci, exe, logger)

def _get_exec(self):
return None # signaling default
Expand All @@ -728,9 +705,10 @@ def _get_quality_scores(self, asset):
# check if vmafossexec returned additional info about the bootstrapped models
# bootstrap_model_list_str is a comma-separated string of model names
if 'bootstrap_model_list_str' in root.findall('params')[0].attrib:
bootstrap_model_list = []
vmaf_params = root.findall('params')[0].attrib
bootstrap_model_list_str = vmaf_params['bootstrap_model_list_str']
bootstrap_model_list = bootstrap_model_list_str.split(',') if len(bootstrap_model_list_str) > 0 else []
bootstrap_model_list = bootstrap_model_list_str.split(',')
# augment the feature set with bootstrap models
self.FEATURES += bootstrap_model_list

Expand Down
60 changes: 3 additions & 57 deletions python/test/lib/libvmaf_libtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
__license__ = "Apache, Version 2.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


class LibRunner(VmafossExecQualityRunner):

TYPE = "TESTLIB"
Expand Down Expand Up @@ -82,8 +64,8 @@ def test_run_testlib_runner(self):
self.assertAlmostEqual(results[0]['TESTLIB_ms_ssim_score'], 0.9632498125, places=4)

self.assertAlmostEqual(results[1]['TESTLIB_vif_scale0_score'], 1.0, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_vif_scale1_score'], 0.999999958333, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_vif_scale2_score'], 0.999999416667, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_vif_scale1_score'],0.999999958333, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_vif_scale2_score'],0.999999416667, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_vif_scale3_score'], 0.999999208333, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_motion2_score'], 3.8953518541666665, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_adm2_score'], 1.0, places=4)
Expand All @@ -92,40 +74,4 @@ def test_run_testlib_runner(self):
self.assertAlmostEqual(results[1]['TESTLIB_ms_ssim_score'], 1.0, places=4)

self.assertAlmostEqual(results[0]['TESTLIB_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[1]['TESTLIB_score'], 99.946416604585025, places=4)

def test_run_testlib_runner_with_thread(self):
print 'test on running TESTLIB runner with thread...'
ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

self.runner = LibRunner(
[asset, asset_original],
None, fifo_mode=True,
delete_workdir=True,
result_store=None,
optional_dict={'thread': 3}
)
self.runner.run()

results = self.runner.results

self.assertAlmostEqual(results[0]['TESTLIB_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[1]['TESTLIB_score'], 99.946416604585025, places=4)

def test_run_testlib_runner_phone_model(self):
print 'test on running TESTLIB runner with phone model...'
ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

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

results = self.runner.results

self.assertAlmostEqual(results[0]['TESTLIB_score'], 92.54239166666667, places=3)
self.assertAlmostEqual(results[1]['TESTLIB_score'], 100.0, places=4)
self.assertAlmostEqual(results[1]['TESTLIB_score'],99.946416604585025, places=4)
87 changes: 2 additions & 85 deletions python/test/vmafossexec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,90 +86,7 @@ def test_run_vmafossexec_runner_with_thread(self):
results = self.runner.results

self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_score'], 99.946416604585025, places=4)

def test_run_vmafossexec_runner_with_061_additional_model(self):
print('test on running VMAFOSSEXEC runner with 0.6.1 as additional model...')
ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

self.runner = VmafossExecQualityRunner(
[asset, asset_original],
None, fifo_mode=True,
delete_workdir=True,
result_store=None,
optional_dict={'additional_models': {"some_model": VmafConfig.model_path("vmaf_v0.6.1.pkl")}}
)
self.runner.run()

results = self.runner.results

self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[0]['VMAFOSSEXEC_some_model_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[0]['VMAFOSSEXEC_some_model_transformed_score'], 92.54239166666667, places=3)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_score'], 99.946416604585025, places=4)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_some_model_score'], 99.946416604585025, places=4)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_some_model_transformed_score'], 100.0, places=4)

def test_run_vmafossexec_runner_with_061_additional_models(self):
print('test on running VMAFOSSEXEC runner with 0.6.1 as additional models...')
ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

self.runner = VmafossExecQualityRunner(
[asset, asset_original],
None, fifo_mode=True,
delete_workdir=True,
result_store=None,
optional_dict={'additional_models': {"some_model": VmafConfig.model_path("vmaf_v0.6.1.pkl"),
"other_model": VmafConfig.model_path("vmaf_v0.6.1.pkl")}}
)
self.runner.run()

results = self.runner.results

self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[0]['VMAFOSSEXEC_some_model_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[0]['VMAFOSSEXEC_other_model_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_score'], 99.946416604585025, places=4)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_some_model_score'], 99.946416604585025, places=4)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_other_model_score'], 99.946416604585025, places=4)

def test_run_vmafossexec_runner_with_4k_additional_model(self):
print('test on running VMAFOSSEXEC runner with 4k as additional model...')
ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing()

self.runner = VmafossExecQualityRunner(
[asset, asset_original],
None, fifo_mode=True,
delete_workdir=True,
result_store=None,
optional_dict={'additional_models': {"four_k": VmafConfig.model_path("vmaf_4k_v0.6.1.pkl")}}
)
self.runner.run()

results = self.runner.results

self.assertAlmostEqual(results[0]['VMAFOSSEXEC_score'], 76.699271272486044, places=3)
self.assertAlmostEqual(results[0]['VMAFOSSEXEC_four_k_score'], 84.98462083333332, places=3)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_score'], 99.946416604585025, places=4)
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_four_k_score'], 100.0, places=4)

def test_additional_model_json_string(self):
print('test additional model json string creation...')
self.assertEquals(VmafossExecQualityRunner
.get_json_additional_model_string({}), "")
self.assertEquals(VmafossExecQualityRunner
.get_json_additional_model_string({"model A": "/someA/pthA/forA/A.pkl"}),
"{\\\"model A\\\"\\:\\\"/someA/pthA/forA/A.pkl\\\"}")
self.assertEquals(VmafossExecQualityRunner
.get_json_additional_model_string({"model A": "/someA/pthA/forA/A.pkl",
"model B": "/someB/pthB/forB/B.pkl"}),
"{\\\"model A\\\"\\:\\\"/someA/pthA/forA/A.pkl\\\""
"\\,\\\"model B\\\"\\:\\\"/someB/pthB/forB/B.pkl\\\"}")
self.assertEquals(VmafossExecQualityRunner
.get_json_additional_model_string({"model B": "/someB/pthB/forB/B.pkl",
"model A": "/someA/pthA/forA/A.pkl"}),
"{\\\"model A\\\"\\:\\\"/someA/pthA/forA/A.pkl\\\""
"\\,\\\"model B\\\"\\:\\\"/someB/pthB/forB/B.pkl\\\"}")
self.assertAlmostEqual(results[1]['VMAFOSSEXEC_score'],99.946416604585025, places=4)

def test_run_vmafossexec_runner_with_subsample(self):
print('test on running VMAFOSSEXEC runner with subsample...')
Expand Down Expand Up @@ -460,7 +377,7 @@ def test_run_vmafossexec_runner_with_phone_model(self):
None, fifo_mode=False,
delete_workdir=True,
optional_dict={
'phone_model': True,
'phone_model':True,
},
result_store=self.result_store,
)
Expand Down
Loading

0 comments on commit dd3a7f9

Please sign in to comment.