9
9
10
10
@unittest .skipUnless (gpu_modules_available , 'Skipping as GPU modules not available' )
11
11
class TestRegularisers (unittest .TestCase ):
12
+ def setUp (self ):
13
+ self .filename = os .path .join (os .path .dirname (__file__ ), "test_imageLena.bin" )
14
+
12
15
def test_ROF_TV_CPU_vs_GPU (self ):
13
16
#print ("tomas debug test function")
14
- print (__name__ )
15
17
#filename = os.path.join("test","lena_gray_512.tif")
16
18
#plt = TiffReader()
17
- filename = os .path .join ("test" , "test_imageLena.bin" )
19
+ filename = os .path .join (os . path . dirname ( __file__ ), "test_imageLena.bin" )
18
20
plt = BinReader ()
19
21
# read image
20
- Im = plt .imread (filename )
22
+ Im = plt .imread (self . filename )
21
23
Im = np .asarray (Im , dtype = 'float32' )
22
24
23
25
Im = Im / 255
@@ -83,10 +85,10 @@ def test_FGP_TV_CPU_vs_GPU(self):
83
85
print (__name__ )
84
86
#filename = os.path.join("test","lena_gray_512.tif")
85
87
#plt = TiffReader()
86
- filename = os .path .join ("test" ,"test_imageLena.bin" )
88
+ # self. filename = os.path.join("test","test_imageLena.bin")
87
89
plt = BinReader ()
88
90
# read image
89
- Im = plt .imread (filename )
91
+ Im = plt .imread (self . filename )
90
92
Im = np .asarray (Im , dtype = 'float32' )
91
93
92
94
Im = Im / 255
@@ -161,10 +163,10 @@ def test_PD_TV_CPU_vs_GPU(self):
161
163
print (__name__ )
162
164
#filename = os.path.join("test","lena_gray_512.tif")
163
165
#plt = TiffReader()
164
- filename = os .path .join ("test" ,"test_imageLena.bin" )
166
+ # self. filename = os.path.join("test","test_imageLena.bin")
165
167
plt = BinReader ()
166
168
# read image
167
- Im = plt .imread (filename )
169
+ Im = plt .imread (self . filename )
168
170
Im = np .asarray (Im , dtype = 'float32' )
169
171
170
172
Im = Im / 255
@@ -201,9 +203,10 @@ def test_PD_TV_CPU_vs_GPU(self):
201
203
pars ['regularisation_parameter' ],
202
204
pars ['number_of_iterations' ],
203
205
pars ['tolerance_constant' ],
206
+ pars ['lipschitz_const' ],
204
207
pars ['methodTV' ],
205
208
pars ['nonneg' ],
206
- pars [ 'lipschitz_const' ], device = 'cpu' )
209
+ device = 'cpu' )
207
210
208
211
rms = rmse (Im , pd_cpu )
209
212
pars ['rmse' ] = rms
@@ -218,9 +221,10 @@ def test_PD_TV_CPU_vs_GPU(self):
218
221
pars ['regularisation_parameter' ],
219
222
pars ['number_of_iterations' ],
220
223
pars ['tolerance_constant' ],
224
+ pars ['lipschitz_const' ],
221
225
pars ['methodTV' ],
222
226
pars ['nonneg' ],
223
- pars [ 'lipschitz_const' ], device = 'gpu' )
227
+ device = 'gpu' )
224
228
225
229
rms = rmse (Im , pd_gpu )
226
230
pars ['rmse' ] = rms
@@ -242,9 +246,9 @@ def test_SB_TV_CPU_vs_GPU(self):
242
246
#filename = os.path.join("test","lena_gray_512.tif")
243
247
#plt = TiffReader()
244
248
# read image
245
- filename = os .path .join ("test" ,"test_imageLena.bin" )
249
+ # filename = os.path.join("test","test_imageLena.bin")
246
250
plt = BinReader ()
247
- Im = plt .imread (filename )
251
+ Im = plt .imread (self . filename )
248
252
Im = np .asarray (Im , dtype = 'float32' )
249
253
250
254
Im = Im / 255
@@ -314,10 +318,10 @@ def test_TGV_CPU_vs_GPU(self):
314
318
print (__name__ )
315
319
#filename = os.path.join("test","lena_gray_512.tif")
316
320
#plt = TiffReader()
317
- filename = os .path .join ("test" ,"test_imageLena.bin" )
321
+ # filename = os.path.join("test","test_imageLena.bin")
318
322
plt = BinReader ()
319
323
# read image
320
- Im = plt .imread (filename )
324
+ Im = plt .imread (self . filename )
321
325
Im = np .asarray (Im , dtype = 'float32' )
322
326
323
327
Im = Im / 255
@@ -395,9 +399,9 @@ def test_LLT_ROF_CPU_vs_GPU(self):
395
399
#filename = os.path.join("test","lena_gray_512.tif")
396
400
#plt = TiffReader()
397
401
# read image
398
- filename = os .path .join ("test" ,"test_imageLena.bin" )
402
+ # filename = os.path.join("test","test_imageLena.bin")
399
403
plt = BinReader ()
400
- Im = plt .imread (filename )
404
+ Im = plt .imread (self . filename )
401
405
Im = np .asarray (Im , dtype = 'float32' )
402
406
403
407
Im = Im / 255
@@ -471,9 +475,9 @@ def test_NDF_CPU_vs_GPU(self):
471
475
#filename = os.path.join("test","lena_gray_512.tif")
472
476
#plt = TiffReader()
473
477
# read image
474
- filename = os .path .join ("test" ,"test_imageLena.bin" )
478
+ # filename = os.path.join("test","test_imageLena.bin")
475
479
plt = BinReader ()
476
- Im = plt .imread (filename )
480
+ Im = plt .imread (self . filename )
477
481
Im = np .asarray (Im , dtype = 'float32' )
478
482
479
483
Im = Im / 255
@@ -549,9 +553,9 @@ def test_Diff4th_CPU_vs_GPU(self):
549
553
#filename = os.path.join("test","lena_gray_512.tif")
550
554
#plt = TiffReader()
551
555
# read image
552
- filename = os .path .join ("test" , "test_imageLena.bin" )
556
+ # filename = os.path.join(os.path.dirname(__file__), "test_imageLena.bin")
553
557
plt = BinReader ()
554
- Im = plt .imread (filename )
558
+ Im = plt .imread (self . filename )
555
559
Im = np .asarray (Im , dtype = 'float32' )
556
560
557
561
Im = Im / 255
@@ -622,9 +626,9 @@ def test_FDGdTV_CPU_vs_GPU(self):
622
626
#filename = os.path.join("test","lena_gray_512.tif")
623
627
#plt = TiffReader()
624
628
# read image
625
- filename = os .path .join ("test" ,"test_imageLena.bin" )
629
+ # filename = os.path.join("test","test_imageLena.bin")
626
630
plt = BinReader ()
627
- Im = plt .imread (filename )
631
+ Im = plt .imread (self . filename )
628
632
Im = np .asarray (Im , dtype = 'float32' )
629
633
630
634
Im = Im / 255
0 commit comments