jakeret / tf_unet

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

IndexError: tuple index out of range #220

Closed adong3 closed 5 years ago

adong3 commented 5 years ago

I made a mask with the same size of the image, but I get error: offset1 = (data.shape[2] - shape[2])//2 IndexError: tuple index out of range

adong3 commented 5 years ago

from tf_unet import unet, util, image_util import numpy as np from PIL import Image

preparing data loading

data_provider = image_util.ImageDataProvider("segment/*.tif")

setup & training

output_path = 'jieguo' net = unet.Unet(layers=3, features_root=64, channels=3, n_class=2) trainer = unet.Trainer(net) path = trainer.train(data_provider, output_path, training_iters=3, epochs=1)

verification

dat = np.array(Image.open('test/c.tif')) data = np.zeros((1,len(dat),len(dat[0]),3)) for i in range(len(dat)): for j in range(len(dat[0])): data[0][i][j][0] = dat[i][j][0] data[0][i][j][1] = dat[i][j][1] data[0][i][j][2] = dat[i][j][2]

l = 'train/c_mask.tif' label = np.array(Image.open('train/c_mask.tif'))

prediction = net.predict(path, data)

unet.error_rate(prediction, util.crop_to_shape(label, prediction.shape))

img = util.combine_img_prediction(data, label, prediction) util.save_image(img, "prediction.jpg")

jakeret commented 5 years ago

Where does this error occur?