Skip to content

Commit

Permalink
fix negative rounds will appear in sliding window when mscale testing (
Browse files Browse the repository at this point in the history
…#975)

Co-authored-by: liliulei <liliulei@macintoshs-MacBook-Pro.local>
  • Loading branch information
lingorX and liliulei authored Apr 20, 2021
1 parent ec3c457 commit e75fa2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions paddleseg/core/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def slide_inference(model, im, crop_size, stride):
# calculate the crop nums
rows = np.int(np.ceil(1.0 * (h_im - h_crop) / h_stride)) + 1
cols = np.int(np.ceil(1.0 * (w_im - w_crop) / w_stride)) + 1
# prevent negative sliding rounds when imgs after scaling << crop_size
rows = 1 if h_im <= h_crop
cols = 1 if w_im <= w_crop
# TODO 'Tensor' object does not support item assignment. If support, use tensor to calculation.
final_logit = None
count = np.zeros([1, 1, h_im, w_im])
Expand Down

0 comments on commit e75fa2b

Please sign in to comment.