tf_unet icon indicating copy to clipboard operation
tf_unet copied to clipboard

output of prediction cannot use

Open sanersbug opened this issue 7 years ago • 3 comments

I trained the RGB image, and the result of the prediction not a RGB file , only a thumbnail, how to change it to a normal result,thanks a lot!

prediction

I use the code:

#!/usr/bin/env python

-- coding: utf-8 --

from tf_unet import image_util, unet, util from scripts.radio_util import DataProvider

model_path = '/home/geoic/tf_unet-master/unet_trained/model.ckpt' datapath = '//home/geoic/tf_unet-master/test/*.tif' files = glob.glob(datapath)

data_provider = image_util.ImageDataProvider(datapath,data_suffix='.tif',mask_suffix='_V1_poly.tif') data_provider.channerls = 3 data_provider.n_class = 2 net = unet.Unet(channels=3, n_class=2, layers=3, features_root=64)

data,label = data_provider(1) prediction = net.predict(model_path, data)

img = util.to_rgb(prediction[..., 1].reshape(-1, prediction.shape[2], 1)) util.save_image(img, "prediction.jpg")

sanersbug avatar Aug 13 '18 07:08 sanersbug

The original image is

image

sanersbug avatar Aug 13 '18 07:08 sanersbug

The deeper the network is the smaller the output image will be. This is expected behaviour as described in the original Ronneberger et al. paper. One thing people do to circumvent this is to mirror the edges of the input image to compensate for the reduction of resolution

jakeret avatar Aug 13 '18 18:08 jakeret

@jakeret I know it , another question, the padding = 'VALID' cannot change 'SAME' in the tf_unet/layers.py, if it changed ,the input size will same with output size

sanersbug avatar Aug 14 '18 00:08 sanersbug