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
Node Dependent Local Smoothing for Scalable Graph Learning

Node Dependent Local Smoothing for Scalable Graph Learning Requirements Environments: Xeon Gold 5120 (CPU), 384GB(RAM), TITAN RTX (GPU), Ubuntu 16.04

Wentao Zhang 15 Nov 28, 2022
Sequential Model-based Algorithm Configuration

SMAC v3 Project Copyright (C) 2016-2018 AutoML Group Attention: This package is a reimplementation of the original SMAC tool (see reference below). Ho

AutoML-Freiburg-Hannover 778 Jan 05, 2023
FlexConv: Continuous Kernel Convolutions with Differentiable Kernel Sizes

FlexConv: Continuous Kernel Convolutions with Differentiable Kernel Sizes This repository contains the source code accompanying the paper: FlexConv: C

Robert-Jan Bruintjes 96 Dec 12, 2022
Active and Sample-Efficient Model Evaluation

Active Testing: Sample-Efficient Model Evaluation Hi, good to see you here! 👋 This is code for "Active Testing: Sample-Efficient Model Evaluation". P

Jannik Kossen 19 Oct 30, 2022
Direct design of biquad filter cascades with deep learning by sampling random polynomials.

IIRNet Direct design of biquad filter cascades with deep learning by sampling random polynomials. Usage git clone https://github.com/csteinmetz1/IIRNe

Christian J. Steinmetz 55 Nov 02, 2022
Minimisation of a negative log likelihood fit to extract the lifetime of the D^0 meson (MNLL2ELDM)

Minimisation of a negative log likelihood fit to extract the lifetime of the D^0 meson (MNLL2ELDM) Introduction The average lifetime of the $D^{0}$ me

Son Gyo Jung 1 Dec 17, 2021
A Domain-Agnostic Benchmark for Self-Supervised Learning

DABS: A Domain Agnostic Benchmark for Self-Supervised Learning This repository contains the code for DABS, a benchmark for domain-agnostic self-superv

Alex Tamkin 81 Dec 09, 2022
nanodet_plus,yolov5_v6.0

OAK_Detection OAK设备上适配nanodet_plus,yolov5_v6.0 Environment pytorch = 1.7.0

炼丹去了 1 Feb 18, 2022
Code for the paper Open Sesame: Getting Inside BERT's Linguistic Knowledge.

Open Sesame This repository contains the code for the paper Open Sesame: Getting Inside BERT's Linguistic Knowledge. Credits We built the project on t

9 Jul 24, 2022
Official repository for "On Generating Transferable Targeted Perturbations" (ICCV 2021)

On Generating Transferable Targeted Perturbations (ICCV'21) Muzammal Naseer, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Fatih Porikli Paper:

Muzammal Naseer 46 Nov 17, 2022
Code for the CVPR 2021 paper "Triple-cooperative Video Shadow Detection"

Triple-cooperative Video Shadow Detection Code and dataset for the CVPR 2021 paper "Triple-cooperative Video Shadow Detection"[arXiv link] [official l

Zhihao Chen 24 Oct 04, 2022
A PyTorch Implementation of PGL-SUM from "Combining Global and Local Attention with Positional Encoding for Video Summarization", Proc. IEEE ISM 2021

PGL-SUM: Combining Global and Local Attention with Positional Encoding for Video Summarization PyTorch Implementation of PGL-SUM From "PGL-SUM: Combin

Evlampios Apostolidis 35 Dec 22, 2022
DECA: Detailed Expression Capture and Animation (SIGGRAPH 2021)

DECA: Detailed Expression Capture and Animation (SIGGRAPH2021) input image, aligned reconstruction, animation with various poses & expressions This is

Yao Feng 1.5k Jan 02, 2023
You Only Look Once for Panopitic Driving Perception

You Only 👀 Once for Panoptic 🚗 Perception You Only Look at Once for Panoptic driving Perception by Dong Wu, Manwen Liao, Weitian Zhang, Xinggang Wan

Hust Visual Learning Team 1.4k Jan 04, 2023
Official PyTorch implementation of "Contrastive Learning from Extremely Augmented Skeleton Sequences for Self-supervised Action Recognition" in AAAI2022.

AimCLR This is an official PyTorch implementation of "Contrastive Learning from Extremely Augmented Skeleton Sequences for Self-supervised Action Reco

Gty 44 Dec 17, 2022
NEATEST: Evolving Neural Networks Through Augmenting Topologies with Evolution Strategy Training

NEATEST: Evolving Neural Networks Through Augmenting Topologies with Evolution Strategy Training

Göktuğ Karakaşlı 16 Dec 05, 2022
Towards Interpretable Deep Metric Learning with Structural Matching

DIML Created by Wenliang Zhao*, Yongming Rao*, Ziyi Wang, Jiwen Lu, Jie Zhou This repository contains PyTorch implementation for paper Towards Interpr

Wenliang Zhao 75 Nov 11, 2022
This game was designed to encourage young people not to gamble on lotteries, as the probablity of correctly guessing the number is infinitesimal!

Lottery Simulator 2022 for Web Launch Application Developed by John Seong in Ontario. This game was designed to encourage young people not to gamble o

John Seong 2 Sep 02, 2022
Project ArXiv Citation Network

Project ArXiv Citation Network Overview This project involved the analysis of the ArXiv citation network. Usage The complete code of this project is i

Dennis Núñez-Fernández 5 Oct 20, 2022
BraTs-VNet - BraTS(Brain Tumour Segmentation) using V-Net

BraTS(Brain Tumour Segmentation) using V-Net This project is an approach to dete

Rituraj Dutta 7 Nov 27, 2022