Code Monkey home page Code Monkey logo

unet-tensorflow-keras's People

Contributors

zizhaozhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unet-tensorflow-keras's Issues

data format

In train directory
train/
img/
0/
gt/
0/
in 0/ need I to put one image or batch?
In my case, I have 6 classes. How to look groundtruth mask image? 0,1,2,3,4,5 in the last channel, in all channels, certain colors like in palette_refer.png

Evaluation dataset - format/path ?

Hello,

Thanks for sharing your code !

I was able to use cityscapes dataset and train (just doing 2 classes for start).

However, during evaluation - on any jpg (either a jpg of training data, or new image)

python eval.py --data_path ./eval --load_from_checkpoint ./checkpoints/unet_example/model-146 --batch_size 1

I always get the exact same error:

ValueError: Input 0 of layer conv1_1 is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 256, 256]

(full trace here - https://pastebin.com/Rjzt5N7V )

it seems as if nothing I do can avoid that error.

I'll keep at it - but if anything comes to mind, appreciate any tips or ideas meanwhile.

Thanks again !

可以在.py文件里面写上路径吗?

你好:
最近在学习深度学习,大神的代码写的非常高深。
我按照你的readme的步骤来操作的时候,系统会出现错误,提示说:系统找不到指定的路径,我已经将你的说明中的your-data-path改成了我自己的文件夹了(使用的是绝对路径),然后就出现了这个问题。
所以我想请教一下,可以在.py文件中声明相关的路径吗?还有,总共需要自己设置几个路径呢?
还请大神不吝赐教。
谢谢!!

images question

python train.py
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
./datasets/
build UNet ...

please how are images and labels.
thank you very much
thank you very much...........

Question

Hi, thank you for sharing code.
Could you give me the dataset link?

license?

Hi, could you provide some license to your code? I suggest MIT ;)

Create Unet Error: `padding` should have two elements. Found: (6, 6, 6, 6)

When create the Unet,

with tf.name_scope('unet'):
   pred = UNet().create_model(img_shape, backend='tf', tf_input=img)

The following error occurred

Traceback (most recent call last):
  File "G:/Tensorflow/unet-tensorflow-keras-master/train.py", line 52, in <module>
    pred = UNet().create_model(img_shape, backend='tf', tf_input=img)
  File "G:\Tensorflow\unet-tensorflow-keras-master\model.py", line 84, in create_model
    conv9 = ZeroPadding2D(padding=(ch[0], ch[1], cw[0], cw[1]), dim_ordering=dim_ordering)(conv9)
  File "E:\Program Files\python35\lib\site-packages\keras\legacy\interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "E:\Program Files\python35\lib\site-packages\keras\layers\convolutional.py", line 1307, in __init__
    'Found: ' + str(padding))
ValueError: `padding` should have two elements. Found: (6, 6, 6, 6)

Besides, there are many warning

build UNet ...
G:\Tensorflow\unet-tensorflow-keras-master\model.py:37: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), name="conv1_1", activation="relu", data_format="channels_last", padding="same")`
  conv1 = Convolution2D(32, 3, 3, activation='relu', border_mode='same', dim_ordering=dim_ordering, name='conv1_1')(inputs)
G:\Tensorflow\unet-tensorflow-keras-master\model.py:38: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), activation="relu", padding="same", data_format="channels_last")`
  conv1 = Convolution2D(32, 3, 3, activation='relu', border_mode='same', dim_ordering=dim_ordering)(conv1)
G:\Tensorflow\unet-tensorflow-keras-master\model.py:39: UserWarning: Update your `MaxPooling2D` call to the Keras 2 API: `MaxPooling2D(data_format="channels_last", pool_size=(2, 2))`
  pool1 = MaxPooling2D(pool_size=(2, 2), dim_ordering=dim_ordering)(conv1)
G:\Tensorflow\unet-tensorflow-keras-master\model.py:40: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(64, (3, 3), activation="relu", padding="same", data_format="channels_last")`
  conv2 = Convolution2D(64, 3, 3, activation='relu', border_mode='same', dim_ordering=dim_ordering)(pool1)
...

Looking forward to your reply
Best wishes to you

Efficiency issue

 x_batch, y_batch = next(train_generator)
 feed_dict = {   img: x_batch,
                        label: y_batch
                    }

This way is very slowly.

Image shape mismatch

I am trying to input data into this U-Net and I keep getting the error:

Traceback (most recent call last):
File "train.py", line 119, in
loss, pred_logits = sess.run([cross_entropy_loss, pred], feed_dict=feed_dict)
File "/Users/ishapuri/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 789, in run
run_metadata_ptr)
File "/Users/ishapuri/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 975, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 288, 432, 4) for Tensor u'unet/input_1:0', which has shape '(?, 256, 256, 3)'

My images are png files and have shape (288, 432, 3).
How do I fix this? What is the exact shape you are looking for? And what is the 1st number in this shape dimension? (what is the significance of the spot that has a ? in it).
Thanks!

load data layer demo

I want to use nifit data to train a unet, here is a demo for datalayer.
Anyone who finds mistakes please make a suggestion.
Thanks

import numpy as np
import nibabel as nb

class DataLayer():
    def __init__(self, opt):
        # 'batch_size': 2,
        # 'learning_rate': 0.0001,
        # 'lr_decay': 0.5,
        # 'save_model_every': 100,
        # 'checkpoint_path': 'checkpoints/unet',
        # 'epoch': 5,
        # 'load_from_checkpoint': 'unet-654'
        self.batch_size = opt['batch_size']
        self.learning_rate = opt['learning_rate']
        self.lr_decay = opt['lr_decay']
        self.save_model_every = opt['save_model_every']
        self.checkpoint_path = opt['checkpoint_path']
        self.epoch = opt['epoch']
        self.load_from_checkpoint = opt['load_from_checkpoint']

    def get_iter_epoch(self):
        return self.epoch

    def load_batch(self):
        # read custome data
        TrainFilePath = "H:/e_PublicData/H_LiverTumor2017/Training Batch 2/" #data pyth
        Train_Case = 120
        data_name = TrainFilePath + 'volume-' + str(Train_Case) + '.nii'
        label_name = TrainFilePath + 'segmentation-' + str(Train_Case) + '.nii'
        Train_nii = nb.load(data_name) # load data
        Train_Label_nii = nb.load(label_name) #load label
        Train_data = Train_nii.get_data()
        Train_data = Train_data.astype(np.uint8)
        Train_Label_data = Train_Label_nii.get_data()
        Train_Label_data[Train_Label_data == 2] = 1 # laber number:2  background 0, ground truth 1
        [nx, ny, nz] = Train_data.shape
        X = np.zeros([nz, nx, ny, 1], dtype= float)
        Y = np.zeros([nz, nx, ny, 1], dtype= float)
        Train_data = Train_data.transpose(2, 0, 1)
        Train_Label_data = Train_Label_data.transpose(2, 0, 1)
        X[..., 0] = Train_data
        Y[..., 0] = Train_Label_data
        X_temp = X[0:2, ...]
        Y_temp = Y[0:2, ...]
        return X_temp, Y_temp

Changing --imSize seems to break eval.py functionality

With the default value of 256 for --imSize, the eval.py produces 768x256 images that comprises of the validation img image, the validation gt image, and the output from the uNet Model. The images look as expected. It's a really nice output as one can compare results.

But, when I change that value to 512 the image that it outputs is incorrect. It has the correct 1536x512 image size, but the validation img part is 256x512, and the validation gt part is also 256x512.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.