From 6887ae5026e20fa8acad644f040fdab1a085e772 Mon Sep 17 00:00:00 2001 From: dkazanc Date: Thu, 11 Oct 2018 13:58:04 +0100 Subject: fixes tests/demos and closes #43 --- Wrappers/Python/conda-recipe/run_test.py | 20 ++++++++++---------- Wrappers/Python/demos/demo_cpu_regularisers.py | 2 +- .../Python/demos/demo_cpu_vs_gpu_regularisers.py | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/conda-recipe/run_test.py b/Wrappers/Python/conda-recipe/run_test.py index 398ef60..86013a3 100755 --- a/Wrappers/Python/conda-recipe/run_test.py +++ b/Wrappers/Python/conda-recipe/run_test.py @@ -65,8 +65,8 @@ class TestRegularisers(unittest.TestCase): pars = {'algorithm': ROF_TV, \ 'input' : u0,\ 'regularisation_parameter':0.04,\ - 'number_of_iterations': 1200,\ - 'time_marching_parameter': 0.0025 + 'number_of_iterations': 1000,\ + 'time_marching_parameter': 0.0001 } print ("#############ROF TV CPU####################") start_time = timeit.default_timer() @@ -94,7 +94,7 @@ class TestRegularisers(unittest.TestCase): txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time) print (txtstr) print ("--------Compare the results--------") - tolerance = 1e-05 + tolerance = 1e-04 diff_im = np.zeros(np.shape(rof_cpu)) diff_im = abs(rof_cpu - rof_gpu) diff_im[diff_im > tolerance] = 1 @@ -361,8 +361,8 @@ class TestRegularisers(unittest.TestCase): 'input' : u0,\ 'regularisation_parameterROF':0.04, \ 'regularisation_parameterLLT':0.01, \ - 'number_of_iterations' :500 ,\ - 'time_marching_parameter' :0.0025 ,\ + 'number_of_iterations' :1000 ,\ + 'time_marching_parameter' :0.0001 ,\ } print ("#############LLT- ROF CPU####################") @@ -394,7 +394,7 @@ class TestRegularisers(unittest.TestCase): txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time) print (txtstr) print ("--------Compare the results--------") - tolerance = 1e-05 + tolerance = 1e-04 diff_im = np.zeros(np.shape(lltrof_gpu)) diff_im = abs(lltrof_cpu - lltrof_gpu) diff_im[diff_im > tolerance] = 1 @@ -643,14 +643,14 @@ class TestRegularisers(unittest.TestCase): Im = np.asarray(Im, dtype='float32') """ tolerance = 1e-05 - rms_rof_exp = 0.006812507 #expected value for ROF model + rms_rof_exp = 8.313131464999238e-05 #expected value for ROF model # set parameters for ROF-TV pars_rof_tv = {'algorithm': ROF_TV, \ 'input' : Im,\ 'regularisation_parameter':0.04,\ 'number_of_iterations': 50,\ - 'time_marching_parameter': 0.0025 + 'time_marching_parameter': 0.00001 } print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("_________testing ROF-TV (2D, CPU)__________") @@ -715,14 +715,14 @@ class TestRegularisers(unittest.TestCase): Im = Im/255 tolerance = 1e-05 - rms_rof_exp = 0.006812507 #expected value for ROF model + rms_rof_exp = 8.313131464999238e-05 #expected value for ROF model # set parameters for ROF-TV pars_rof_tv = {'algorithm': ROF_TV, \ 'input' : Im,\ 'regularisation_parameter':0.04,\ 'number_of_iterations': 50,\ - 'time_marching_parameter': 0.0025 + 'time_marching_parameter': 0.00001 } print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("_________testing ROF-TV (2D, GPU)__________") diff --git a/Wrappers/Python/demos/demo_cpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_regularisers.py index b94f11c..e99b271 100644 --- a/Wrappers/Python/demos/demo_cpu_regularisers.py +++ b/Wrappers/Python/demos/demo_cpu_regularisers.py @@ -36,7 +36,7 @@ filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif") Im = plt.imread(filename) Im = np.asarray(Im, dtype='float32') -Im = Im/255 +Im = Im/255.0 perc = 0.05 u0 = Im + np.random.normal(loc = 0 , scale = perc * Im , diff --git a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py index e45dc40..3d6e92f 100644 --- a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py +++ b/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py @@ -66,8 +66,8 @@ imgplot = plt.imshow(u0,cmap="gray") pars = {'algorithm': ROF_TV, \ 'input' : u0,\ 'regularisation_parameter':0.04,\ - 'number_of_iterations': 1200,\ - 'time_marching_parameter': 0.0025 + 'number_of_iterations': 4500,\ + 'time_marching_parameter': 0.00002 } print ("#############ROF TV CPU####################") start_time = timeit.default_timer() @@ -406,8 +406,8 @@ pars = {'algorithm' : LLT_ROF, \ 'input' : u0,\ 'regularisation_parameterROF':0.04, \ 'regularisation_parameterLLT':0.01, \ - 'number_of_iterations' :500 ,\ - 'time_marching_parameter' :0.0025 ,\ + 'number_of_iterations' :4500 ,\ + 'time_marching_parameter' :0.00002 ,\ } print ("#############LLT- ROF CPU####################") -- cgit v1.2.3