@@ -121,19 +121,21 @@ def compute(self, data):
121121 sigma_scale = 1.0 ,
122122 )
123123
124- expected = np .array ([
124+ expected = np .array (
125125 [
126126 [
127- [3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 ],
128- [3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 ],
129- [3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 ],
130- [3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 ],
131- [4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 ],
132- [4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 ],
133- [5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 ],
127+ [
128+ [3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 ],
129+ [3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 , 3.0000 ],
130+ [3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 , 3.3333 ],
131+ [3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 , 3.6667 ],
132+ [4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 , 4.3333 ],
133+ [4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 , 4.5000 ],
134+ [5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 , 5.0000 ],
135+ ]
134136 ]
135137 ]
136- ] )
138+ )
137139 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
138140 result = sliding_window_inference (
139141 inputs ,
@@ -147,29 +149,31 @@ def compute(self, data):
147149 sigma_scale = 1.0 ,
148150 progress = has_tqdm ,
149151 )
150- expected = np .array ([
152+ expected = np .array (
151153 [
152154 [
153- [3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 ],
154- [3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 ],
155- [3.3271625 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271625 ],
156- [3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 ],
157- [4.3271623 , 4.3271623 , 4.3271627 , 4.3271627 , 4.3271627 , 4.3271623 , 4.3271623 ],
158- [4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 ],
159- [4.9999995 , 5.0 , 5.0 , 5.0 , 5.0 , 5.0 , 4.9999995 ],
155+ [
156+ [3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 ],
157+ [3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 , 3.0 ],
158+ [3.3271625 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271623 , 3.3271625 ],
159+ [3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 , 3.6728377 ],
160+ [4.3271623 , 4.3271623 , 4.3271627 , 4.3271627 , 4.3271627 , 4.3271623 , 4.3271623 ],
161+ [4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 , 4.513757 ],
162+ [4.9999995 , 5.0 , 5.0 , 5.0 , 5.0 , 5.0 , 4.9999995 ],
163+ ]
160164 ]
161165 ]
162- ] )
166+ )
163167 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
164168
165169 result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "gaussian" , sigma_scale = 1.0 )(
166170 inputs , _Pred ().compute
167171 )
168172 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
169173
170- result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "gaussian" , sigma_scale = [ 1.0 , 1.0 ])(
171- inputs , _Pred (). compute
172- )
174+ result = SlidingWindowHoVerNetInferer (
175+ roi_shape , sw_batch_size , overlap = 0.5 , mode = "gaussian" , sigma_scale = [ 1.0 , 1.0 ]
176+ )( inputs , _Pred (). compute )
173177 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
174178
175179 result = SlidingWindowHoVerNetInferer (
@@ -200,7 +204,9 @@ def compute(data):
200204 expected = np .ones ((1 , 1 , 3 , 3 )) * - 6.0
201205 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
202206
203- result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 )(inputs , compute )
207+ result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 )(
208+ inputs , compute
209+ )
204210 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
205211
206212 def test_args_kwargs (self ):
@@ -238,9 +244,9 @@ def compute(data, test1, test2):
238244 expected = np .ones ((1 , 1 , 3 , 3 )) + 2.0
239245 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
240246
241- result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 , progress = has_tqdm )(
242- inputs , compute , t1 , test2 = t2
243- )
247+ result = SlidingWindowHoVerNetInferer (
248+ roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 , progress = has_tqdm
249+ )( inputs , compute , t1 , test2 = t2 )
244250 np .testing .assert_allclose (result .cpu ().numpy (), expected , rtol = 1e-4 )
245251
246252 @parameterized .expand (TEST_CASES_MULTIOUTPUT )
@@ -280,9 +286,9 @@ def compute_dict(data):
280286 for rr , _ in zip (result_dict , expected_dict ):
281287 np .testing .assert_allclose (result_dict [rr ].cpu ().numpy (), expected_dict [rr ], rtol = 1e-4 )
282288
283- result = SlidingWindowHoVerNetInferer (roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 , progress = has_tqdm )(
284- inputs , compute
285- )
289+ result = SlidingWindowHoVerNetInferer (
290+ roi_shape , sw_batch_size , overlap = 0.5 , mode = "constant" , cval = - 1 , progress = has_tqdm
291+ )( inputs , compute )
286292 for rr , ee in zip (result , expected ):
287293 np .testing .assert_allclose (rr .cpu ().numpy (), ee , rtol = 1e-4 )
288294
0 commit comments