Skip to content

Commit

Permalink
Update evaluate.py
Browse files Browse the repository at this point in the history
fix a bug
  • Loading branch information
speedinghzl committed Dec 2, 2018
1 parent 129d10b commit e374d77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions evaluate.py
Expand Up @@ -132,6 +132,7 @@ def predict_sliding(net, image, tile_size, classes, flip_evaluation, recurrence)
return full_probs

def predict_whole(net, image, tile_size, recurrence):
image = torch.from_numpy(image)
interp = nn.Upsample(size=tile_size, mode='bilinear', align_corners=True)
prediction = net(image.cuda())
if isinstance(prediction, list):
Expand All @@ -152,10 +153,9 @@ def predict_multiscale(net, image, tile_size, scales, classes, flip_evaluation,
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)
scale_image = torch.from_numpy(scale_image)
scaled_probs = predict_whole(net, scale_image, tile_size, recurrence)
if flip_evaluation == 'True':
flip_scaled_probs = predict_whole_img(net, scale_image[:,:,:,::-1].copy(), 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)
Expand Down

0 comments on commit e374d77

Please sign in to comment.