Fix padding issue
@@ -660,20 +660,23 @@ def get_padding(layer):
in_W = layer.src_layers[0].output_size[0]
in_H = layer.src_layers[0].output_size[1]
if (in_H % S_h == 0):
- P_h = max(0, H - S_h) // 2
+ pad_h = max(0, H - S_h)
else:
- P_h = max(0, H - (in_H % S_h)) // 2
+ pad_h = max(0, H - (in_H % S_h))
if (in_W % S_w == 0):
- P_w = max(0, W - S_w) // 2
+ pad_w = max(0, W - S_w)
else:
- P_w = max(0, W - (in_W % S_w)) // 2
- P_h_ = P_h
- P_w_ = P_w
- if max(0, H - S_h) % 2 != 0:
- P_h_ += 1
- if max(0, W - S_w) % 2 != 0:
- P_w_ += 1
-
+ pad_w = max(0, W - (in_W % S_w))
+ if pad_h % 2 == 0:
+ P_h = P_h_ = pad_h // 2
+ else:
+ P_h = pad_h // 2
+ P_h_ = P_h + 1
+ if pad_w % 2 == 0:
+ P_w = P_w_ = pad_w // 2
+ else:
+ P_w = pad_w // 2
+ P_w_ = P_w + 1
return [P_h, P_w, P_h_, P_w_]
