Git Product home page Git Product logo

u-net-brain-tumor's Introduction

U-Net Brain Tumor Segmentation

🚀:Feb 2019 the data processing implementation in this repo is not the fastest way (code need update, contribution is welcome), you can use TensorFlow dataset API instead.

This repo show you how to train a U-Net for brain tumor segmentation. By default, you need to download the training set of BRATS 2017 dataset, which have 210 HGG and 75 LGG volumes, and put the data folder along with all scripts.

data
  -- Brats17TrainingData
  -- train_dev_all
model.py
train.py
...

About the data

Note that according to the license, user have to apply the dataset from BRAST, please do NOT contact me for the dataset. Many thanks.


Fig 1: Brain Image
  • Each volume have 4 scanning images: FLAIR、T1、T1c and T2.
  • Each volume have 4 segmentation labels:
Label 0: background
Label 1: necrotic and non-enhancing tumor
Label 2: edema 
Label 4: enhancing tumor

The prepare_data_with_valid.py split the training set into 2 folds for training and validating. By default, it will use only half of the data for the sake of training speed, if you want to use all data, just change DATA_SIZE = 'half' to all.

About the method


Fig 2: Data augmentation

Start training

We train HGG and LGG together, as one network only have one task, set the task to all, necrotic, edema or enhance, "all" means learn to segment all tumors.

python train.py --task=all

Note that, if the loss stick on 1 at the beginning, it means the network doesn't converge to near-perfect accuracy, please try restart it.

Citation

If you find this project useful, we would be grateful if you cite the TensorLayer paper:

@article{tensorlayer2017,
author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
journal = {ACM Multimedia},
title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
url = {http://tensorlayer.org},
year = {2017}
}

u-net-brain-tumor's People

Contributors

zsdonghao 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

u-net-brain-tumor's Issues

survival data

there is a survival_csv_path, is that none, or have some data in it. ps: i train the model with 2015 data. is there any problem?

TypeError: __init__() got an unexpected keyword argument 'out_size'

  • After conv: Tensor("u_net/conv8/leaky_relu:0", shape=(5, 1, 1, 512), dtype=float32, device=/device:CPU:0)
    Traceback (most re
    screenshot from 2019-02-19 18-02-42
    cent call last):
    File "train.py", line 250, in
    main(args.task)
    File "train.py", line 121, in main
    net = model.u_net_bn(t_image, is_train=True, reuse=False, n_out=1)
    File "/home/achi/project/u-net-brain-tumor-master/model.py", line 179, in u_net_bn
    padding=pad, act=None, batch_size=batch_size, W_init=w_init, b_init=b_init, name='deconv7')
    File "/home/achi/anaconda3/lib/python3.6/site-packages/tensorlayer/decorators/deprecated_alias.py", line 24, in wrapper
    return f(*args, **kwargs)
    TypeError: init() got an unexpected keyword argument 'out_size'

Survival Data problem

I have registered and got the login details. I have downloaded the dataset using details but I didn't find .csv file in it. Could you tell me, where the file is present.

Error: Your CPU supports instructions that TensorFlow binary not compiled to use: AVX2

I am running run.py but gives error:

(base) G:>cd BraTS_2018_U-Net-master

(base) G:\BraTS_2018_U-Net-master>run.py
[] creates checkpoint ...
[
] creates samples/all ...
finished Brats18_2013_24_1
2019-06-15 22:05:45.959220: I tensorflow/core/platform/cpu_feature_guard.cc:141]
Your CPU supports instructions that this TensorFlow binary was not compiled to
use: AVX2
Traceback (most recent call last):
File "G:\BraTS_2018_U-Net-master\run.py", line 154, in

File "G:\BraTS_2018_U-Net-master\run.py", line 117, in main
t_seg = tf.placeholder('float32', [1, nw, nh, 1], name='target_segment')
NameError: name 'model' is not defined

u_net_all.npz doesn't exist.

Sorry to bother you,I tried to run the programme,I run 'train.py',but I got this error,but I don't know how to resolve it,thank you for your reply.

[TL] got 45: u_net/uconv1/bias:0 (1,)
INFO:tensorlayer: got 45: u_net/uconv1/bias:0 (1,)
[TL] ERROR: file checkpoint/u_net_all.npz doesn't exist.
ERROR:tensorlayer:ERROR: file checkpoint/u_net_all.npz doesn't exist.

Pre-proccessing

In 2015 dataset , survival_data .csv is not present can you please explain what is there ?

3D UNet

is there a way to convert this UNet implementation to 3D?

DICE

I got dice equal to one every epoch?
How to handle that?

Checkpoint

Is anyone gone through the Evaluation ??

Data format issue

I have acquired the dataset which is BRATS 2015. It contains .mha files but the code deals with .nii.gz files. Need help in this since ita related to my thesis project.

Save all slices

How can I modify the code to save every slice of the segmented tumors?

MemoryError

@zsdonghao I am getting the memory error like this, What is the solution for this error?

Traceback (most recent call last):
File "train.py", line 279, in
main(args.task)
File "train.py", line 78, in main
y_test = (y_test > 0).astype(int)
MemoryError

'tuple' object has no attribute 'lower'

I am trying to train the model using this command:
python train.py --task=all

But after the prepare_data is done it shows an error like this:

image

My version of tensorflow is 1.13.1. How can I solve this problem without downgrading the version of tensorflow?

Feature Visualization

Hello Sir,

how can we visualize the feature in the network?
Can you give us some advices regarding that?

Thanks
Sami

Pretrained to make transferlearning

Hello, Ihave 3k images with T1 brain tumor, and i manage to obtain 50% mean IOU. Can you put the pretrained weights, to see if transfer learning is helping?

Code For Testing

Thank you for sharing your code.
I have trained the model and getting the .npz file which contains weights of the trained model.
Can you share the code for testing the images?
Thank you.

load checkpoit failed

It reported that load checkpoint process was failed.
[TL] [!] Load checkpoint/u_net_all.npz failed!
Do you know how to fix it? Thank you.

while trainig (python train.py --task=all) i got error

while trainig (python train.py --task=all) i got error

Traceback (most recent call last):
File "train.py", line 250, in
main(args.task)
File "train.py", line 65, in main
import prepare_data_with_valid as dataset
File "C:\delete\shared_f\braintumor\u-net-brain-tumor-master\prepare_data_with
_valid.py", line 351, in
X_train_input = np.asarray(X_train_input, dtype=np.float32)
File "C:\anaconda\lib\site-packages\numpy\core\numeric.py", line 492, in asarr
ay
return array(a, dtype, copy=False, order=order)
MemoryError

how can i solve this one ?
thanks in advance for helping :)

Gpu requirements

Would it be possible to run the training model on a Nvidia gtx 1060 6GB ram . Would the training time be longer than 18 hours in this case?

Index Error

When I removed parts of the code that deal with LGG, an index error comes up.

error

I'm only interested in the HGG half of the dataset. Do you have an idea on how to solve this issue?

survival_data.csv

I do understand what is the survival_data.csv file, could u provide me?

System Error throw while training

Traceback (most recent call last):
File "C:\Users\zlshu\AppData\Roaming\Python\Python36\site-packages\numpy\lib\stride_tricks.py", line 251, in
if all(array.shape == shape for array in args):
SystemError: error return without exception set

Performance with/without augmentation?

Could you show me the performance of your method without augmentation? I would like to know how many percents do we have if we apply augmentation. Thanks

I run the train.py several times, but DICE is always equal to one.

I used tensorflow-gpu1.8 and tensorlayer1.11, and I changed the original up3 = DeConv2d(conv4, 256, (3, 3), (nx/4, ny/4), (2, 2), name='deconv3') to up3 = DeConv2d(conv4, 256, (3, 3), strides=(2, 2), name='deconv3') in model.py and the lr=0.00001 .
According to readme, I restarted to train the model, but the 1-dice is always equal to one. Can you give me some advice to make it converge to near-perfect accuracy?

TensorFlow Implemetation

Do you have implementation of brain tumor segmentation code directly in tensorflow without using tensorlayer? If yes, can you share the same?
Thank you.

loss weight

In the U-net paper ,the loss is calculated with a weight in order to balance the class frequencies.But in your code file,I can not find this code . By the way ,I am a Chinese ,my English is poor and I am new to tensorlayer.

Pre-trained model

I was wondering if you would share a pre-trained model.
I would need to run inference-only, and training the model is taking longer than expected.

Thanks for sharing this project!

BRATS2017 data set

The registration time for Brat seems to have ended. Could you please provide an alternative for downloading the data?

Understanding of code

Is anyone understood the code???????
Please provide the sources how shall i understand the tensorlayer programming .

when using u_net_bn in model,i get the error

when using u_net_bn in model,i get the error "train_op = tf.train.AdamOptimizer(lr_v, beta1=beta1).minimize(loss, var_list=t_vars)",and "ValueError: No variables to optimize",what's the reason,how can i figure out ?

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.