Skip to content

Commit 5c21e8c

Browse files
author
yi.he
committed
clean code
1 parent 81f36a2 commit 5c21e8c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

alignshift/operators/alignshiftconv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def __init__(self, in_channels, out_channels, kernel_size, stride=1,
3333
self.ref_thickness = ref_thickness
3434
self.shift_padding_zero = shift_padding_zero
3535

36-
def alignshift(self, input, fold, thickness, padding_zero=True):
37-
alph = 1 - (self.ref_thickness / thickness).view(-1, 1 ,1, 1, 1).clamp_(0., 1.)
36+
def alignshift(self, input, fold, ref_thickness, thickness, padding_zero=True):
37+
alph = 1 - (ref_thickness / thickness).view(-1, 1 ,1, 1, 1).clamp_(0., 1.)
3838
out = torch.zeros_like(input)
3939
out[:, :fold, :-1] = input[:, :fold, :-1] * alph + input[:, :fold, 1:] * (1-alph)
4040
out[:, fold: 2 * fold, 1:] = input[:, fold: 2 * fold, 1:] * alph + \
@@ -49,7 +49,7 @@ def align_shift(self, x, fold, ref_thickness, thickness, padding_zero, inplace):
4949
if inplace:
5050
x = inplace_alignshift(x, fold, ref_thickness, thickness, padding_zero)
5151
else:
52-
x = self.alignshift(x, fold, thickness, padding_zero)
52+
x = self.alignshift(x, fold, ref_thickness, thickness, padding_zero)
5353
return x
5454

5555
def forward(self, input, thickness=None):
@@ -67,7 +67,7 @@ def extra_repr(self):
6767

6868
class InplaceAlignShift(torch.autograd.Function):
6969
@staticmethod
70-
def forward(ctx, input, fold, align_spacing, thickness, padding_zero=True):
70+
def forward(ctx, input, fold, ref_thickness, thickness, padding_zero=True):
7171
'''
7272
@params:
7373
input: BxCxDxHxW
@@ -79,7 +79,7 @@ def forward(ctx, input, fold, align_spacing, thickness, padding_zero=True):
7979
n, c, t, h, w = input.size()
8080
ctx.fold_ = fold
8181
ctx.padding_zero = padding_zero
82-
alph = 1 - (align_spacing / thickness).view(-1, 1 ,1, 1, 1).clamp_(0., 1.) ##把小于align_spacing的当作align_spacing,不做插值处理
82+
alph = 1 - (ref_thickness / thickness).view(-1, 1 ,1, 1, 1).clamp_(0., 1.) ##把小于ref_thickness的当作ref_thickness,不做插值处理
8383
ctx.alph_ = alph
8484
input.data[:, :fold, :-1] = input.data[:, :fold, :-1] * alph + input.data[:, :fold, 1:] * (1-alph)
8585
input.data[:, fold:2*fold, 1:] = input.data[:, fold:2*fold, 1:] * alph + \

deeplesion/eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def mask_matrics(output, iou_thresh=0.5):
173173
# _, cnts = cv2.findContours(l_seg, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
174174
pred_mask_index.append(indx)
175175
prop = regionprops(d_seg)[0]
176-
diameter = np.sqrt(hprop.major_axis_lengt**2 + prop.minor_axis_length**2)/2
176+
diameter = np.sqrt(prop.major_axis_lengt**2 + prop.minor_axis_length**2)/2
177177
recists = output['recists'][i].reshape((4, 2))
178178
l = np.linalg.norm(recists[0] - recists[1])
179179
s = np.linalg.norm(recists[2] - recists[3])

0 commit comments

Comments
 (0)