U-Net Brain Tumor Segmentation

Overview

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}
}
Comments
  • TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    Lossy conversion from float64 to uint8. Range [-0.18539370596408844, 2.158207416534424]. Convert image to uint8 prior to saving to suppress this warning. Traceback (most recent call last): File "train.py", line 250, in main(args.task) File "train.py", line 106, in main X[:,:,2,np.newaxis], X[:,:,3,np.newaxis], y])#[:,:,np.newaxis]]) File "train.py", line 26, in distort_imgs fill_mode='constant') TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    opened by shenzeqi 8
  • MemoryError

    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

    opened by PoonamZ 4
  • Error: Your CPU supports instructions that TensorFlow binary not compiled to use: AVX2

    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

    opened by sapnii2 2
  • TypeError: __init__() got an unexpected keyword argument 'out_size'

    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'
    opened by achintacsgit 1
  • Pre-trained model

    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!

    opened by luisremis 1
  • TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    [TL] [!] checkpoint exists ... [TL] [!] samples/all exists ... Lossy conversion from float64 to uint8. Range [-0.19753389060497284, 2.826017379760742]. Convert image to uint8 prior to saving to suppress this warning.

    TypeError Traceback (most recent call last) in 239 tl.files.save_npz(net.all_params, name=save_dir+'/u_net_{}.npz'.format(task), sess=sess) 240 --> 241 main(task='all') 242 243 ##if name == "main":

    in main(task) 103 for i in range(10): 104 x_flair, x_t1, x_t1ce, x_t2, label = distort_imgs([X[:,:,0,np.newaxis], X[:,:,1,np.newaxis], --> 105 X[:,:,2,np.newaxis], X[:,:,3,np.newaxis], y])#[:,:,np.newaxis]]) 106 # print(x_flair.shape, x_t1.shape, x_t1ce.shape, x_t2.shape, label.shape) # (240, 240, 1) (240, 240, 1) (240, 240, 1) (240, 240, 1) (240, 240, 1) 107 X_dis = np.concatenate((x_flair, x_t1, x_t1ce, x_t2), axis=2)

    in distort_imgs(data) 23 x1, x2, x3, x4, y = tl.prepro.zoom_multi([x1, x2, x3, x4, y], 24 zoom_range=[0.9, 1.1], is_random=True, ---> 25 fill_mode='constant') 26 return x1, x2, x3, x4, y 27

    TypeError: zoom_multi() got an unexpected keyword argument 'is_random'

    opened by BTapan 0
  • TensorFlow Implemetation

    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.

    opened by rupalkapdi 0
  • What is checkpoint?

    What is checkpoint?

    When I run "python train.py" and then have a checkpoint folder is created. What function of checkpoint folder? Thank you

    And I also have another question. When we had the picture, as follows. Is that the end result? I mean we can submit them to the Brast_2018 challenge? image

    Thank you very much.

    opened by tphankr 0
  • Making sense

    Making sense

    Novice here, i noticed the shape of the X_train arrays ended with 4. (240,240,4) Does each of those channel represent the type of the scan ( T1, t2, flair, t1ce ) ?

    opened by guido-niku 1
  • Classification Layer - Activation & Shape?

    Classification Layer - Activation & Shape?

    Hi!

    I went through this repository after reading your paper. Architecture on page 6, shows the final classification layer to produce feature maps of shape (240, 240, 2) which may indicate the use of a Softmax activation (not specified in the paper). On the contrary, model used in code has a classification layer of shape (240, 240, 1) using Sigmoid activation.

    Kindly clarify this ambiguity.

    opened by stalhabukhari 2
Releases(0.1)
Owner
Hao
Assistant Professor @ Peking University
Hao
This is the official pytorch implementation for our ICCV 2021 paper "TRAR: Routing the Attention Spans in Transformers for Visual Question Answering" on VQA Task

🌈 ERASOR (RA-L'21 with ICRA Option) Official page of "ERASOR: Egocentric Ratio of Pseudo Occupancy-based Dynamic Object Removal for Static 3D Point C

Hyungtae Lim 225 Dec 29, 2022
Faster Convex Lipschitz Regression

Faster Convex Lipschitz Regression This reepository provides a python implementation of our Faster Convex Lipschitz Regression algorithm with GPU and

Ali Siahkamari 0 Nov 19, 2021
Multi-Stage Progressive Image Restoration

Multi-Stage Progressive Image Restoration Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, Ming-Hsuan Yang, and Ling Sh

Syed Waqas Zamir 859 Dec 22, 2022
Official code of "Mitigating the Mutual Error Amplification for Semi-Supervised Object Detection"

CrossTeaching-SSOD 0. Introduction Official code of "Mitigating the Mutual Error Amplification for Semi-Supervised Object Detection" This repo include

Bruno Ma 9 Nov 29, 2022
More than a hundred strange attractors

dysts Analyze more than a hundred chaotic systems. Basic Usage Import a model and run a simulation with default initial conditions and parameter value

William Gilpin 185 Dec 23, 2022
Sarus implementation of classical ML models. The models are implemented using the Keras API of tensorflow 2. Vizualization are implemented and can be seen in tensorboard.

Sarus published models Sarus implementation of classical ML models. The models are implemented using the Keras API of tensorflow 2. Vizualization are

Sarus Technologies 39 Aug 19, 2022
NeurIPS'21 Tractable Density Estimation on Learned Manifolds with Conformal Embedding Flows

NeurIPS'21 Tractable Density Estimation on Learned Manifolds with Conformal Embedding Flows This repo contains the code for the paper Tractable Densit

Layer6 Labs 4 Dec 12, 2022
Diagnostic tests for linguistic capacities in language models

LM diagnostics This repository contains the diagnostic datasets and experimental code for What BERT is not: Lessons from a new suite of psycholinguist

61 Jan 02, 2023
AI assistant built in python.the features are it can display time,say weather,open-google,youtube,instagram.

AI assistant built in python.the features are it can display time,say weather,open-google,youtube,instagram.

AK-Shanmugananthan 1 Nov 29, 2021
Code for CVPR 2021 paper TransNAS-Bench-101: Improving Transferrability and Generalizability of Cross-Task Neural Architecture Search.

TransNAS-Bench-101 This repository contains the publishable code for CVPR 2021 paper TransNAS-Bench-101: Improving Transferrability and Generalizabili

Yawen Duan 17 Nov 20, 2022
Public Models considered for emotion estimation from EEG

Emotion-EEG Set of models for emotion estimation from EEG. Composed by the combination of two deep-learing models learning together (RNN and CNN) with

Victor Delvigne 21 Dec 23, 2022
Removing Inter-Experimental Variability from Functional Data in Systems Neuroscience

Removing Inter-Experimental Variability from Functional Data in Systems Neuroscience This repository is the official implementation of [https://www.bi

Eulerlab 6 Oct 09, 2022
Optimizing Value-at-Risk and Conditional Value-at-Risk of Black Box Functions with Lacing Values (LV)

BayesOpt-LV Optimizing Value-at-Risk and Conditional Value-at-Risk of Black Box Functions with Lacing Values (LV) About This repository contains the s

1 Nov 11, 2021
Learning hidden low dimensional dyanmics using a Generalized Onsager Principle and neural networks

OnsagerNet Learning hidden low dimensional dyanmics using a Generalized Onsager Principle and neural networks This is the original pyTorch implemenati

Haijun.Yu 3 Aug 24, 2022
Codes for Causal Semantic Generative model (CSG), the model proposed in "Learning Causal Semantic Representation for Out-of-Distribution Prediction" (NeurIPS-21)

Learning Causal Semantic Representation for Out-of-Distribution Prediction This repository is the official implementation of "Learning Causal Semantic

Chang Liu 54 Dec 01, 2022
Code for ACM MM2021 paper "Complementary Trilateral Decoder for Fast and Accurate Salient Object Detection"

CTDNet The PyTorch code for ACM MM2021 paper "Complementary Trilateral Decoder for Fast and Accurate Salient Object Detection" Requirements Python 3.6

CVTEAM 28 Oct 20, 2022
Joint Learning of 3D Shape Retrieval and Deformation, CVPR 2021

Joint Learning of 3D Shape Retrieval and Deformation Joint Learning of 3D Shape Retrieval and Deformation Mikaela Angelina Uy, Vladimir G. Kim, Minhyu

Mikaela Uy 38 Oct 18, 2022
HyDiff: Hybrid Differential Software Analysis

HyDiff: Hybrid Differential Software Analysis This repository provides the tool and the evaluation subjects for the paper HyDiff: Hybrid Differential

Yannic Noller 22 Oct 20, 2022
Semi-SDP Semi-supervised parser for semantic dependency parsing.

Semi-SDP Semi-supervised parser for semantic dependency parsing. This repo contains the code used for the semi-supervised semantic dependency parser i

12 Sep 17, 2021
Fast sparse deep learning on CPUs

SPARSEDNN **If you want to use this repo, please send me an email: [email pro

Ziheng Wang 44 Nov 30, 2022