Giter Club home page Giter Club logo

u2net_torch's Introduction

by Chao Huang, Qingsong Yao, Hu Han, Shankuan Zhu, Shaohua Zhou. This is a code repo of the paper early accepted by MICCAI2019.

In case of any questions about this repo, please feel free to contact Chao Huang([email protected]).

Abstract. Fully convolutional neural networks like U-Net have been the state-of-art methods in medical image segmentation. Practically, a network is highly specialized and trained separately for each segmenta- tion task. Instead of a collection of multiple models, it is highly desirable to learn a universal data representation for different tasks, ideally a sin- gle model with the addition of a minimal number of parameters to steer to each task. Inspired by the recent success of multi-domain learning in image classification, for the first time we explore a promising universal architecture that can handle multiple medical segmentation tasks, re- gardless of different organs and imaging modalities. Our 3D Universal U-Net (3D U2-Net) is built upon separable convolution, assuming that images from different domains have domain-specific spatial correlations which can be probed with channel-wise convolution while also share cross- channel correlations which can be modeled with pointwise convolution. We evaluate the 3D U2-Net on five organ segmentation datasets. Experimen- tal results show that this universal network is capable of competing with traditional models in terms of segmentation accuracy, while requiring only 1% of the parameters. Additionally, we observe that the architecture can be easily and effectively adapted to a new domain without sacrificing performance in the domains used to learn the shared parameterization of the universal network.

Overview

Brief instruction to apply the code:

  1. Most requirements are listed in requirments.txt. Besides, batchgenerators is a python package developed by researchers at the Division of Medical Image Computing at the German Cancer Research Center (DKFZ) to do data augmentation for images. Introduction and installation instructions are listed inMIC-DKFZ/batchgenerators/.
  2. Please put the datasets downloaded from Medical Segmentation Decathlon in dataset.
  3. data_explore.py is to explore the characteristics of the images, e.g. pixel spacings.
  4. preprocess_taskSep.py is used to do offline preprocessing (e.g. cropping, resampling) of the data samples to save time for training.
  5. train_model_no_adapters.py is the mainfile to train the independent models as well as the shared model.
  6. train_model_wt_adapters.py is the mainfile to train the propsed universal model with separable convolution.
  7. Terminal commands to train all models are presented in train_models.sh.

To accelerate training, we built a fast tool to do online image augmentation with CUDA on GPU(especially for elastic deformation). cuda_spatial_defrom.

Citation

If you use this code, please cite our paper as:

Huang C., Han H., Yao Q., Zhu S., Zhou S.K. (2019) 3D U 2-Net: A 3D Universal U-Net for Multi-domain Medical Image Segmentation. In: Shen D. et al. (eds) Medical Image Computing and Computer Assisted Intervention – MICCAI 2019. MICCAI 2019. Lecture Notes in Computer Science, vol 11765. Springer, Cham

Acknowledgement

We give a lot of thanks to the open-access data science community for the public data science knowledge. Special thanks are given to @Guotai Wang and @Rebuffi as some of the code is borrowed from their repos: https://github.com/taigw/brats17/ and https://github.com/srebuffi/residual_adapters.

u2net_torch's People

Contributors

huangmozhilv 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

u2net_torch's Issues

TypeError: leaky_relu(): argument 'input' (position 1) must be Tensor, not NoneType

Hi bro:
When I run the command "CUDA_VISIBLE_DEVICES=0 python train_model_no_adapters.py --trainMode 'independent' --out_tag '20200928' --tasks 'Task05_Prostate'", I got an error which is TypeError: leaky_relu(): argument 'input' (position 1) must be Tensor, not NoneType. However, I don't know how to fix it. Does anyone know how to fix it? Thanks!!!
leaky_RELU_error

Question about the result of Task03_Liver with u2net

Hi, Huang
I train the Task03_Liver data with the u2net, model is 'independent'
The result of the dirtory 'Task03_Liver/eval_out':
1. the file 'independent_eval_res.csv' is:
independent,Task03_Liver,43,300,background,0.8916431518030707,20191105_0552
independent,Task03_Liver,43,300,liver,0.21799891788565087,20191105_0552
2.the file 'Task03_Liver_eval_res.csv' is like:
43,20191105_0447,liver_101,0.8264607633464421,0.2039704202942287
43,20191105_0449,liver_11,0.8457022631483909,0.16228892270692075
43,20191105_0452,liver_112,0.8737011154430623,0.14028567103856587
43,20191105_0455,liver_115,0.8791505887936942,0.11115132973364941
......
I think the result of the inference is not right. What do you think?
The training only took 43 epoch, will it take more epoch?
And in the 'preprocess_taskSep.py' , I was confused with the 'fuseCa = True'.
Best,
Yaliang

How to train the self-data

Hi,
Thank you for your great work!
but I want to know how to train my self data with your model.
For example, how to set the batch_size, and the patch_size and other parameters in the config.py.
and how to inference the test data.
Best,
Yaliang

Loss function error

Sorry to bother, i've used dice_loss function to train my 3d models, but the loss value has always been negative. i've tried many methods but it didn't work. My outputs is like [batchsize, class_nums, depth, width, height],where class_nums = 3 and I have coded the label one-hot, so the label is also like [batchsize, class_nums, depth, width, height]. I want to know how to use the loss function. Thank you very much! : ). By the way, I commented this line of code in dice_loss.py "target = one_hot(target, num_class)",because i've preprocess the label one-hot. I use pytorch 1.2.0.

question about memory

Hi, thanks for your work. I have fix some small question about your code, then I got right performance. But I have some question about your experiment and your code.
That is, I use torchsummary to see how much memory your model need to occupied, and I got 19136MB with input size(2, 1, 80, 192, 128), but my gpu has just 11GB memory to use, and I can run the code. That's amazing! I checked your code, but I can not find the mechanism to reduce memory so obviously.
Can you or somebody else can answer me? Thanks so much.

TypeError: stat: path should be string, bytes, os.PathLike or integer, not list

Hi brother:
Thank you for sharing, I am a little white in image processing. I hope to get your helpI When I run " CUDA_VISIBLE_DEVICES=1 python train_model_no_adapters.py --trainMode 'independent' --out_tag '20190312' --tasks 'Task10_Colon" on my terminal. The following problem arises
image

Maybe my data path is not set correctly, where should I modify my path?

image
Is it here?This problem occurred again after I modified it
image
I'm looking forward to receiving your reply as soon as possible
Best wish!

No module named 'batchgenerators'

Hi, your work is really admirable, but when I train it on google colab, an unexpected error occured. I have no idea, could you help me address this problem? Thanks
14 from termcolor import colored
15
---> 16 import batchgenerators
17
18 import ccToolkits.logger as logger

ModuleNotFoundError: No module named 'batchgenerators'

some problems about batchgenerators

when i try to run independent model for task_01 braintumour ,the error came like this:
image
error in for-loop of trQueue:module 'batchgenerators.augmentations' has no attribute 'spatial_transformations'
i am more than grateful for your helping, anything will be my luck

Task06_Lung

why you don't have this task?
or could you please help me to modify the code for it?

A Small Bug using resume_ckp and continueing training.

I stopped training model when lr was smaller than 3e-7 in before. Then I set the min_lr to 1e-8 and use the resume_ckp and resume_epoch to continue training. But i find the lr is resumed uncorrectly in

optimizer = checkpoint['optimizer']

lr = config.base_lr
if args.resume_ckp != '':
    optimizer = checkpoint['optimizer']
else:
    optimizer = torch.optim.Adam(model.parameters(), lr=lr, weight_decay=config.weight_decay) # 

this can be fixed liked:

lr = config.base_lr
if args.resume_ckp != '':
    optimizer = checkpoint['optimizer']
    lr = optimizer.param_groups[0]['lr]   # resume original learning rate
else:
    optimizer = torch.optim.Adam(model.parameters(), lr=lr, weight_decay=config.weight_decay) # 

At last, thanks for your sharing!

Some problems about the implement of conv_unit?

In conv_unit module, when config.module == 'separable_adapter', the conv_unit will return three tensor out, share_map, para_map.

return out, share_map, para_map

And in the module DownBlock, only when 'config.module == parallel_adapter', the module will run out, share_map, para_map = self.op1(x). When separable_adapter, it will run out = self.op1(x) and the out now is the list of (out, share_map, para_map). Next step the leakly ReLU activation out = self.act1(out) will raise error TypeError: leaky_relu(): argument 'input' (position 1) must be Tensor, not tuple

if config.module == 'parallel_adapter':

I'm not sure if it's just me, my pytorch version is 1.1.
In the end, thanks for your contirbutions and sharing!

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.