jakeret / tf_unet

Generic U-Net Tensorflow implementation for image segmentation
GNU General Public License v3.0
1.9k stars 748 forks source link

output of prediction cannot use #209

Open sanersbug opened 6 years ago

sanersbug commented 6 years ago

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 commented 6 years ago

The original image is

image

jakeret commented 6 years ago

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

sanersbug commented 6 years ago

@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