Part 2 Lesson 14 Wiki

How can I apply the learned segmentation model (lesson 14, unet) on a single new test image?

is this the correct way to do it?

trn_tfms,val_tfms = tfms_from_model(models, sz)
im = open_image('/home/data/train-512/test1.png')
im = val_tfms(im)
learn.precompute=False 
preds = learn.predict_array(im[None])
np.argmax(preds)

How to interpret the result of this in the context of segementation?

Figured the correct version (I guess, please comment if I am wrong with it):

trn_tfms,val_tfms = tfms_from_model(models, sz)
im = open_image('/home/data/train-512/test1.png')
im = val_tfms(im)
learn.precompute=False 
py = to_np(learn.model(V(im[None])))
show_img(py[0] >0)
1 Like