speedinghzl / pytorch-segmentation-toolbox

PyTorch Implementations for DeeplabV3 and PSPNet
MIT License
768 stars 167 forks source link

关于多尺度预测 #59

Open swjtulinxi opened 4 years ago

swjtulinxi commented 4 years ago

这里多尺度预测说对于大于原图的采用裁剪的方式,请问是否也采用的滑动窗口预测呢?但是代码里没有采用滑动窗口的代码啊 def predict_multiscale(net, image, tile_size, scales, classes, flip_evaluation, recurrence): """ Predict an image by looking at it with different scales. We choose the "predict_wholeimg" for the image with less than the original input size, for the input of larger size, we would choose the cropping method to ensure that GPU memory is enough. """ image = image.data N, C, H, W_ = image.shape fullprobs = np.zeros((H, W_, classes))
for scale in scales: scale = float(scale) print("Predicting image scaled by %f" % scale) scale_image = ndimage.zoom(image, (1.0, 1.0, scale, scale), order=1, prefilter=False) scaled_probs = predict_whole(net, scale_image, tile_size, recurrence) if flip_evaluation == True: flip_scaled_probs = predict_whole(net, scale_image[:,:,:,::-1].copy(), tile_size, recurrence) scaled_probs = 0.5 * (scaled_probs + flip_scaled_probs[:,::-1,:]) full_probs += scaled_probs full_probs /= len(scales) return full_probs