From 993888c0d47d3f28e8990cf2acb416c366c70019 Mon Sep 17 00:00:00 2001 From: Ahmet Can Solak Date: Tue, 25 Jan 2022 14:20:14 -0800 Subject: [PATCH] BUG: Fixing after breaking regressor name refactor (#88) * initial commit, implemented * fixed the follow up bug on gui init --- aydin/gui/tabs/qt/denoise.py | 19 +++++++++---------- aydin/it/demo/n2s/rf/2D_generic.py | 4 ++-- aydin/it/test/test_fgr.py | 8 ++++---- aydin/it/test/test_fgr_saveload.py | 8 ++++---- aydin/regression/{rf.py => random_forest.py} | 2 +- aydin/regression/{sv.py => support_vector.py} | 2 +- .../test/deprecated_test_saveload.py | 8 ++++---- aydin/regression/test/test_regressors.py | 8 ++++---- aydin/restoration/denoise/noise2selffgr.py | 4 ++-- 9 files changed, 31 insertions(+), 32 deletions(-) rename aydin/regression/{rf.py => random_forest.py} (97%) rename aydin/regression/{sv.py => support_vector.py} (97%) diff --git a/aydin/gui/tabs/qt/denoise.py b/aydin/gui/tabs/qt/denoise.py index 08897873..6511dc00 100644 --- a/aydin/gui/tabs/qt/denoise.py +++ b/aydin/gui/tabs/qt/denoise.py @@ -76,7 +76,7 @@ def __init__(self, parent): 'Noise2SelfCNN-jinet', 'Noise2SelfFGR-cb', 'Noise2SelfFGR-lgbm', - 'Noise2SelfFGR-rf', + 'Noise2SelfFGR-random_forest', ] self.basic_backend_options_descriptions = [] @@ -136,16 +136,15 @@ def set_advanced_enabled(self, enable: bool = False): while self.stacked_widget.count(): self.stacked_widget.removeWidget(self.stacked_widget.widget(0)) - for index, backend_option in enumerate( - self.backend_options if enable else self.basic_backend_options - ): - self.leftlist.insertItem(index, backend_option) + if enable: + options = self.backend_options + description_list = self.backend_options_descriptions + else: + options = self.basic_backend_options + description_list = self.basic_backend_options_descriptions - description_list = ( - self.backend_options_descriptions - if enable - else self.basic_backend_options_descriptions - ) + for index, backend_option in enumerate(options): + self.leftlist.insertItem(index, backend_option) self.stacked_widget.addWidget( DenoiseTabMethodWidget( diff --git a/aydin/it/demo/n2s/rf/2D_generic.py b/aydin/it/demo/n2s/rf/2D_generic.py index edc71adb..ac0d0b18 100644 --- a/aydin/it/demo/n2s/rf/2D_generic.py +++ b/aydin/it/demo/n2s/rf/2D_generic.py @@ -10,7 +10,7 @@ from aydin.features.standard_features import StandardFeatureGenerator from aydin.io.datasets import normalise, add_noise, pollen, newyork, lizard, characters from aydin.it.fgr import ImageTranslatorFGR -from aydin.regression.rf import RFRegressor +from aydin.regression.random_forest import RandomForestRegressor from aydin.util.log.log import Log @@ -26,7 +26,7 @@ def demo(image, name): generator = StandardFeatureGenerator() - regressor = RFRegressor(patience=32) + regressor = RandomForestRegressor(patience=32) it = ImageTranslatorFGR(feature_generator=generator, regressor=regressor) diff --git a/aydin/it/test/test_fgr.py b/aydin/it/test/test_fgr.py index 5421b6e3..0495b833 100644 --- a/aydin/it/test/test_fgr.py +++ b/aydin/it/test/test_fgr.py @@ -13,8 +13,8 @@ from aydin.regression.lgbm import LGBMRegressor from aydin.regression.linear import LinearRegressor from aydin.regression.nn import NNRegressor -from aydin.regression.rf import RFRegressor -from aydin.regression.sv import SVRegressor +from aydin.regression.random_forest import RandomForestRegressor +from aydin.regression.support_vector import SupportVectorRegressor @pytest.mark.heavy @@ -24,13 +24,13 @@ def test_it_fgr_linear(): def test_it_fgr_rf(): - regressor = RFRegressor(max_num_estimators=128) + regressor = RandomForestRegressor(max_num_estimators=128) do_it_fgr_with_self_supervised(regressor, min_ssim=0.75) @pytest.mark.heavy def test_it_fgr_svr(): - regressor = SVRegressor() + regressor = SupportVectorRegressor() do_it_fgr_with_self_supervised(regressor, min_psnr=22, min_ssim=0.71) diff --git a/aydin/it/test/test_fgr_saveload.py b/aydin/it/test/test_fgr_saveload.py index 2bd4c2a0..bed3935e 100644 --- a/aydin/it/test/test_fgr_saveload.py +++ b/aydin/it/test/test_fgr_saveload.py @@ -16,8 +16,8 @@ from aydin.regression.lgbm import LGBMRegressor from aydin.regression.linear import LinearRegressor from aydin.regression.nn import NNRegressor -from aydin.regression.rf import RFRegressor -from aydin.regression.sv import SVRegressor +from aydin.regression.random_forest import RandomForestRegressor +from aydin.regression.support_vector import SupportVectorRegressor @pytest.mark.heavy @@ -28,13 +28,13 @@ def test_saveload_Linear(): @pytest.mark.heavy def test_saveload_RF(): - regressor = RFRegressor() + regressor = RandomForestRegressor() saveload(StandardFeatureGenerator(), regressor, min_ssim=0.75) @pytest.mark.heavy def test_saveload_SVR(): - regressor = SVRegressor() + regressor = SupportVectorRegressor() saveload(StandardFeatureGenerator(), regressor, min_psnr=22, min_ssim=0.71) diff --git a/aydin/regression/rf.py b/aydin/regression/random_forest.py similarity index 97% rename from aydin/regression/rf.py rename to aydin/regression/random_forest.py index d016e628..faf3d392 100644 --- a/aydin/regression/rf.py +++ b/aydin/regression/random_forest.py @@ -4,7 +4,7 @@ from aydin.util.log.log import lsection, lprint -class RFRegressor(LGBMRegressor): +class RandomForestRegressor(LGBMRegressor): """Random Forrest Regressor (uses the LGBM library).""" def __init__( diff --git a/aydin/regression/sv.py b/aydin/regression/support_vector.py similarity index 97% rename from aydin/regression/sv.py rename to aydin/regression/support_vector.py index 1a888d27..de65e880 100644 --- a/aydin/regression/sv.py +++ b/aydin/regression/support_vector.py @@ -4,7 +4,7 @@ from aydin.util.log.log import lprint, lsection -class SVRegressor(RegressorBase): +class SupportVectorRegressor(RegressorBase): """Support Vector Regressor. \n\n Note: Way too slow when non-linear, nearly useless... diff --git a/aydin/regression/test/deprecated_test_saveload.py b/aydin/regression/test/deprecated_test_saveload.py index c8e81652..4a7461c6 100644 --- a/aydin/regression/test/deprecated_test_saveload.py +++ b/aydin/regression/test/deprecated_test_saveload.py @@ -14,8 +14,8 @@ from aydin.regression.lgbm import LGBMRegressor from aydin.regression.linear import LinearRegressor from aydin.regression.nn import NNRegressor -from aydin.regression.rf import RFRegressor -from aydin.regression.sv import SVRegressor +from aydin.regression.random_forest import RandomForestRegressor +from aydin.regression.support_vector import SupportVectorRegressor def test_linear_saveload(): @@ -23,11 +23,11 @@ def test_linear_saveload(): def test_rf_saveload(): - saveload(RFRegressor(), min_ssim=0.70) + saveload(RandomForestRegressor(), min_ssim=0.70) def test_svr_saveload(): - saveload(SVRegressor(), min_ssim=0.70) + saveload(SupportVectorRegressor(), min_ssim=0.70) def test_gbm_saveload(): diff --git a/aydin/regression/test/test_regressors.py b/aydin/regression/test/test_regressors.py index c5f415b2..0228fe24 100644 --- a/aydin/regression/test/test_regressors.py +++ b/aydin/regression/test/test_regressors.py @@ -13,8 +13,8 @@ from aydin.regression.lgbm import LGBMRegressor from aydin.regression.linear import LinearRegressor from aydin.regression.nn import NNRegressor -from aydin.regression.rf import RFRegressor -from aydin.regression.sv import SVRegressor +from aydin.regression.random_forest import RandomForestRegressor +from aydin.regression.support_vector import SupportVectorRegressor def test_linear_regressor(): @@ -23,12 +23,12 @@ def test_linear_regressor(): def test_rf_regressor(): - regressor = RFRegressor() + regressor = RandomForestRegressor() with_regressor(regressor, min_ssim=0.6) def test_svr_regressor(): - regressor = SVRegressor() + regressor = SupportVectorRegressor() with_regressor(regressor, min_ssim=0.65) diff --git a/aydin/restoration/denoise/noise2selffgr.py b/aydin/restoration/denoise/noise2selffgr.py index 6ef7363c..1e11849b 100644 --- a/aydin/restoration/denoise/noise2selffgr.py +++ b/aydin/restoration/denoise/noise2selffgr.py @@ -20,8 +20,8 @@ from aydin.regression.lgbm import LGBMRegressor # noqa: F401 from aydin.regression.linear import LinearRegressor # noqa: F401 from aydin.regression.nn import NNRegressor # noqa: F401 - from aydin.regression.rf import RFRegressor # noqa: F401 - from aydin.regression.sv import SVRegressor # noqa: F401 + from aydin.regression.random_forest import RandomForestRegressor # noqa: F401 + from aydin.regression.support_vector import SupportVectorRegressor # noqa: F401 class Noise2SelfFGR(DenoiseRestorationBase):