-
Notifications
You must be signed in to change notification settings - Fork 813
Refactor motion to motion2 #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c088b66
Rename float_motion to float_motion2.
li-zhi 7278c86
Rename integer_motion to integer_motion2.
li-zhi 9e79559
Rename vmaf_fex_integer_motion2.name from motion to motion2.
li-zhi f047580
Add vmafrc_feature_extractor and tests.
li-zhi 7ea0e21
Fix.
li-zhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import unittest | ||
|
|
||
| from test.testutil import set_default_576_324_videos_for_testing | ||
|
|
||
| from vmaf.core.vmafrc_feature_extractor import FloatMotion2FeatureExtractor, IntegerMotion2FeatureExtractor, FloatVifFeatureExtractor, FloatAdmFeatureExtractor, IntegerVifFeatureExtractor, IntegerPsnrFeatureExtractor | ||
|
|
||
|
|
||
| class FeatureExtractorTest(unittest.TestCase): | ||
|
|
||
| def tearDown(self): | ||
| if hasattr(self, 'fextractor'): | ||
| self.fextractor.remove_results() | ||
| pass | ||
|
|
||
| def test_run_float_motion2_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = FloatMotion2FeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['float_motion2_feature_motion2_score'], 3.8953518541666665, places=8) | ||
| self.assertAlmostEqual(results[1]['float_motion2_feature_motion2_score'], 3.8953518541666665, places=8) | ||
|
|
||
| def test_run_integer_motion2_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = IntegerMotion2FeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['integer_motion2_feature_motion2_score'], 3.895345229166667, places=8) | ||
| self.assertAlmostEqual(results[1]['integer_motion2_feature_motion2_score'], 3.895345229166667, places=8) | ||
|
|
||
| def test_run_float_vif_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = FloatVifFeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['float_VIF_feature_vif_scale0_score'], 0.3634208125, places=6) | ||
| self.assertAlmostEqual(results[0]['float_VIF_feature_vif_scale1_score'], 0.7666474166666667, places=6) | ||
| self.assertAlmostEqual(results[0]['float_VIF_feature_vif_scale2_score'], 0.8628533333333334, places=6) | ||
| self.assertAlmostEqual(results[0]['float_VIF_feature_vif_scale3_score'], 0.9159719583333334, places=6) | ||
| self.assertAlmostEqual(results[1]['float_VIF_feature_vif_scale0_score'], 1.0, places=6) | ||
| self.assertAlmostEqual(results[1]['float_VIF_feature_vif_scale1_score'], 1.0, places=6) | ||
| self.assertAlmostEqual(results[1]['float_VIF_feature_vif_scale2_score'], 1.0, places=6) | ||
| self.assertAlmostEqual(results[1]['float_VIF_feature_vif_scale3_score'], 1.0, places=5) | ||
|
|
||
| def test_run_integer_vif_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = IntegerVifFeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['integer_VIF_feature_vif_scale0_score'], 0.3634233125, places=6) | ||
| self.assertAlmostEqual(results[0]['integer_VIF_feature_vif_scale1_score'], 0.7666542916666667, places=6) | ||
| self.assertAlmostEqual(results[0]['integer_VIF_feature_vif_scale2_score'], 0.862872125, places=6) | ||
| self.assertAlmostEqual(results[0]['integer_VIF_feature_vif_scale3_score'], 0.9159956249999999, places=6) | ||
| self.assertAlmostEqual(results[1]['integer_VIF_feature_vif_scale0_score'], 1.000002, places=6) | ||
| self.assertAlmostEqual(results[1]['integer_VIF_feature_vif_scale1_score'], 1.0000023541666667, places=6) | ||
| self.assertAlmostEqual(results[1]['integer_VIF_feature_vif_scale2_score'], 1.0000022916666667, places=6) | ||
| self.assertAlmostEqual(results[1]['integer_VIF_feature_vif_scale3_score'], 1.0, places=5) | ||
|
|
||
| def test_run_float_adm_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = FloatAdmFeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['float_ADM_feature_adm2_score'], 0.9345877291666667, places=6) | ||
| self.assertAlmostEqual(results[1]['float_ADM_feature_adm2_score'], 1.0, places=6) | ||
|
|
||
| def test_run_integer_psnr_fextractor(self): | ||
| ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() | ||
| self.fextractor = IntegerPsnrFeatureExtractor( | ||
| [asset, asset_original], | ||
| None, fifo_mode=False, | ||
| result_store=None | ||
| ) | ||
| self.fextractor.run() | ||
| results = self.fextractor.results | ||
| self.assertAlmostEqual(results[0]['integer_PSNR_feature_psnr_y_score'], 30.755063979166664, places=4) | ||
| self.assertAlmostEqual(results[0]['integer_PSNR_feature_psnr_cb_score'], 38.4494410625, places=4) | ||
| self.assertAlmostEqual(results[0]['integer_PSNR_feature_psnr_cr_score'], 40.99191027083334, places=4) | ||
| self.assertAlmostEqual(results[1]['integer_PSNR_feature_psnr_y_score'], 60.0, places=4) | ||
| self.assertAlmostEqual(results[1]['integer_PSNR_feature_psnr_cb_score'], 60.0, places=4) | ||
| self.assertAlmostEqual(results[1]['integer_PSNR_feature_psnr_cr_score'], 60.0, places=4) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main(verbosity=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| from vmaf import ExternalProgramCaller | ||
| from vmaf.core.feature_extractor import VmafrcFeatureExtractorMixin, FeatureExtractor | ||
|
|
||
|
|
||
| class FloatMotion2FeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = "float_motion2_feature" | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['motion2'] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'motion2': 'motion2', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('float_motion2', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) | ||
|
|
||
|
|
||
| class IntegerMotion2FeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = "integer_motion2_feature" | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['motion2'] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'motion2': 'integer_motion2', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('motion2', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) | ||
|
|
||
|
|
||
| class FloatVifFeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = "float_VIF_feature" | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['vif_scale0', 'vif_scale1', 'vif_scale2', 'vif_scale3', | ||
| ] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'vif_scale0': 'vif_scale0', | ||
| 'vif_scale1': 'vif_scale1', | ||
| 'vif_scale2': 'vif_scale2', | ||
| 'vif_scale3': 'vif_scale3', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('float_vif', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) | ||
|
|
||
|
|
||
| class IntegerVifFeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = "integer_VIF_feature" | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['vif_scale0', 'vif_scale1', 'vif_scale2', 'vif_scale3', | ||
| ] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'vif_scale0': 'integer_vif_scale0', | ||
| 'vif_scale1': 'integer_vif_scale1', | ||
| 'vif_scale2': 'integer_vif_scale2', | ||
| 'vif_scale3': 'integer_vif_scale3', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('vif', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) | ||
|
|
||
|
|
||
| class FloatAdmFeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = "float_ADM_feature" | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['adm2', | ||
| ] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'adm2': 'adm2', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('float_adm', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) | ||
|
|
||
|
|
||
| class IntegerPsnrFeatureExtractor(VmafrcFeatureExtractorMixin, FeatureExtractor): | ||
|
|
||
| TYPE = 'integer_PSNR_feature' | ||
| VERSION = "1.0" | ||
|
|
||
| ATOM_FEATURES = ['psnr_y', 'psnr_cb', 'psnr_cr'] | ||
|
|
||
| ATOM_FEATURES_TO_VMAFRC_KEY_DICT = { | ||
| 'psnr_y': 'psnr_y', | ||
| 'psnr_cb': 'psnr_cb', | ||
| 'psnr_cr': 'psnr_cr', | ||
| } | ||
|
|
||
| def _generate_result(self, asset): | ||
| # routine to call the command-line executable and generate quality | ||
| # scores in the log file. | ||
|
|
||
| quality_width, quality_height = asset.quality_width_height | ||
| log_file_path = self._get_log_file_path(asset) | ||
|
|
||
| yuv_type=self._get_workfile_yuv_type(asset) | ||
| ref_path=asset.ref_procfile_path | ||
| dis_path=asset.dis_procfile_path | ||
| w=quality_width | ||
| h=quality_height | ||
| logger = self.logger | ||
|
|
||
| ExternalProgramCaller.call_vmafrc_single_feature('psnr', yuv_type, ref_path, dis_path, w, h, log_file_path, logger) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If #594 is merged, I don't think it makes sense to rename these
*_motion2, since they provide both. We could also use the same feature extractor formotion3in the future.