Git Product home page Git Product logo

rubics-xuan / transbts Goto Github PK

View Code? Open in Web Editor NEW
379.0 379.0 79.0 72.43 MB

This repo provides the official code for : 1) TransBTS: Multimodal Brain Tumor Segmentation Using Transformer (https://arxiv.org/abs/2103.04430) , accepted by MICCAI2021. 2) TransBTSV2: Towards Better and More Efficient Volumetric Segmentation of Medical Images(https://arxiv.org/abs/2201.12785).

License: Apache License 2.0

Python 100.00%
medical-image-segmentation pytorch transformer

transbts's Introduction

Hi there 👋

Anurag's GitHub stats

transbts's People

Contributors

rubics-xuan 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

transbts's Issues

What's the position mean in TransUNet3D?

I just want to use your 3D TransUNet in your code.
but I don't know the input shape of the position parameter in forward, I use
position=torch.Tensor([1,512,2,2,2, 64])
to match the
self.pos_emb_layer = nn.Linear(6, emb_channels)
I feel I was wrong.

关于num_gpu的疑问

Wenxuan您好,
在train.py中,有:
train_loader = DataLoader(dataset=train_set, sampler=train_sampler, batch_size=args.batch_size // num_gpu, drop_last=True, num_workers=args.num_workers, pin_memory=True)
此处,我不是太明白batch_size这里为什么要用args.batch_size除以num_gpu?
args.batch_size 为8, 再除以gpu数量4, 等于2, 相当于每个gpu得到的数据batch_size为2?
难道不是每个gpu得到的数据batch_size就是args.batch_size 吗?
谢谢,并祝好!

CUDA out of memory

進行訓練的時候出現=》RuntimeError: CUDA out of memory. Tried to allocate 128.00 MiB (GPU 0; 10.92 GiB total capacity; 10.17 GiB already allocated; 99.81 MiB free; 10.20 GiB reserved in total by PyTorch)
我的GPU配置:
NVIDIA GeForce GTX 1080 Ti 11264 MB
我有嘗試把batch_sizej降低至1,還是未能解決,不知是否還有其他方法可以解決問題

Calculation Dice score

How to call dice score function in predict.py
What are its parameters??

Tried output and target as parameter but got very low dice score but mri images of output and target looks same

TransBTSV2 模型的代码请求

由于没有在TransBTSV2文件夹下看到关于TransBTSV2网络模型的相关代码,请问可以更新一下吗?感谢

in the transformer part, is there any Pytorch API to Transformer Encoder?

Hi Dude , good afternoon.
I'm reading your code. To my understanding , Transformer.py is for define the transformer encoder.
I'm wondering whether there is any API that we can use directly instead of tedious coding.

I just found torch.nn.TransformerEncoder exists. Is it usable in this project? Have you ever thought about this problem before?

Many thanks!

DBM Code

Hello,
I am following your paper of TransBTSV2. After analyzing your repo, I found that code of BDM block is not opensourced. Could you please open-source the code of DBM. It will be quite helpful for our research work.
Thank you

About training settings

First of all, thank you for your paper and code. Actually, I am a bit puzzled about the training settings. As mentioned in the paper, the model was trained for 6000 epochs, with batch size 8 on 4 RTX GPU. Indeed I am not quite familiar with this dataset and wonder the scale of it? how many iterations/ steps in each epoch? if the dataset is small, why it takes so many epochs to converge ?
Thanks again!

output

Thanks for your great work. But when I finished the test, why did the output image like this?
image

Looking forward to your reply.

Some question about the code

Hi, Great work. But there are few small problems that puzzle me. 1) The image shape changes from 240240155 to 240240160,what are the considerations here? 2) I can't understand the intmd_encoder_outputs of the encoder which is the output intmd_x of transformer, what's the difference between x and intmd_x? Besides, the encoder_output seems to be not used in Decoder.

x, intmd_x = self.transformer(x)

def forward(self, x, auxillary_output_layers=[1, 2, 3, 4]):

     x1_1, x2_1, x3_1, encoder_output, intmd_encoder_outputs = self.encode(x)

     decoder_output = self.decode(
         x1_1, x2_1, x3_1, encoder_output, intmd_encoder_outputs, auxillary_output_layers
     )

     if auxillary_output_layers is not None:
         auxillary_outputs = {}
         for i in auxillary_output_layers:
             val = str(2 * i - 1)
             _key = 'Z' + str(i)
             auxillary_outputs[_key] = intmd_encoder_outputs[val]

         return decoder_output

     return decoder_output

Subject Split file missing

Hi Wenxuan

I am currently running your code. After downloading the MICCAI_BraTS_2019_Data, I found that there is no subject split files ' flist' like 'all.txt' or 'valid.txt'. So could not run the preprocess? Will you provide these files? Thanks

A bug for the input

In the TransBTS_downsample8x_skipconnection.TransformerBTS:

self.Unet = Unet(in_channels=4, base_channels=16, num_classes=4)

This code would force the input has 4 channel. I think it should be modified as:

self.Unet = Unet(in_channels=num_channels, base_channels=16, num_classes=4)

Am I right?

About the kindey tumor dataset KiTS mentioned in Data Acquisition

I noticed that you used the BraTS data set in preprocess.py to process the 4 dimensions of the MRI image. I would like to ask that there is only one image.nii and one segmentation.nii in KiTS, and there is no 4-dimensional .nii , May I ask how to do preprocessing for this piece?
my solution:
Is it possible to just remove this part of the code? Or copy 4 copies of image.nii and use this code?
Hope to get your reply, best wishes!
preprocess

On the Number of GPUs

Hello, I see that you use four GPUs to run the code. Is there only one GPU in my computer that can run through? Look forward to your reply.

why are there no label 0 in my predict ?

My dear friend, when I run your code, there are only label 1,2,4 in my result . All the background are label 1, I was puzzled.
I just only download your code here , then change the path to my environment, and edit the parallel code into single GPU.
My platform is Ubuntu20.04 + RXT 3090.

Have you ever encountered the same problem ?

Would you please give me some suggestions?

Many thanks in advance!

DEBlock in code have not deformable convolution.

Hi Wen,
I have read you paper "TransBTS",but i find your code have not deformable convolution in DEBlock. I can not understand it, and can you tell me the reason? Thank you very much!

ZhuangLong

question of performance reproduce

Hiiii Wenxuan. Thanks a lot for your nice work sharing!
I have a question for performance reproducing on Brats 2019 dataset using your codes of TransBTS model. I directly run the train and test codes without any modifying. I get the performance feedback after submitting the test inference results on 125 validation data. The Dice_ET value only has 0.74 in mean which is different from 0.78~0.79. Could you help me with my concern? Thanks in advance!!!

Pre-trained Model

Could you provide the pre-trained model to reproduce the results reported in your paper?

数据集怎么处理

您好,最近在复现您的代码呢,但是我第一步就遇到了问题,看您的data里有train.txt,这是处理过后的吗?能讲解一下数据处理导入这一块是怎么回事吗?谢谢您

evaluate ET, WT, TC

Thank you for sharing your codes. I am wondering how to achieve the Dice scores of 78.93%, 90.00%, 81.94% on ET, WT, TC, respectively. Do you use the model to train for ET, WT, TC, respectively?

Thanks!

Log error

Traceback (most recent call last):
File "train.py", line 290, in
main_worker()
File "train.py", line 114, in main_worker
log_args(log_file)
File "train.py", line 271, in log_args
fh = logging.FileHandler(log_file)
File "/usr/lib/python3.7/logging/init.py", line 1087, in init
StreamHandler.init(self, self._open())
File "/usr/lib/python3.7/logging/init.py", line 1116, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Colab Notebooks/Wenxuan_segmentation/log/TransBTS2021-06-26.txt'

On the number of GPUs

Hello, I see that you use four GPUs to run the code. Is there only one GPU in my computer that can run through? Look forward to your reply.

About 3D transformer

Hello, I run the tranBTS code for 3D medical images, the shape of the generated attention weight is (Batch_size,num_heads, n_patches,n_patches ), is this not applicable to 3D images?
Thank you in advance!

关于训练时显存爆掉

您好,我使用了4块1080并行训练,并且设置将batchsize改小为4,可每次训练显存还是会不足,根据代码可知batchsize设置为4已经是最小值,您有什么建议?

Some questions about the paper

Hi, I have read your paper "TransBTS: Multimodal Brain Tumor Segmentation Using Transformer", which implements transformer module in 3D medical image segmentation task. This task is absorbing, and I have some questions to ask:

  1. Why are there no experiments of TransUnet and nnUnet in Table?
  2. How many iterations in one epoch? Because I see 8000 epoch in your experiments. It's a little large for me. How many time will an experiment with 8000 epoch cost?

Best,
Eric

Test image is not normal

I used your code to train 600 epochs on BraTS2020 dataset, but the background of the test image is red, how can this be?
110

About validation set and test set

I divided my data into training sets, validation sets, and test sets. When training, I use "mode=train", but when I learn the code, I find that the validation set is not in training, and there is no parameter adjustment. In test.py, although there is an option to opt out of validation at training time, the setup of a single dataset file does not satisfy both validation and testing.
我将我的数据分为训练集、验证集和测试集。训练时,使用"mode=train",但我学习代码时发现验证集并没有进入训练,没有进行参数调整.在test.py中,尽管有选择在训练时未进行验证的选项,但只有一个数据集文件的设置, 并不能同时满足验证和测试。

Some question about the paper

Hi, I have read your paper "TransBTS: Multimodal Brain Tumor Segmentation Using Transformer", which implements transformer module in 3D medical image segmentation task. This task is absorbing, and I have some questions to ask:

  1. Why are there no experiments of TransUnet and nnUnet in Table?
  2. How many iterations in one epoch? Because I see 8000 epoch in your experiments. It's a little large for me. How many time will an experiment with 8000 epoch cost?

Best,
Eric

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.