black0017 / medicalzoopytorch Goto Github PK
View Code? Open in Web Editor NEWA pytorch-based deep learning framework for multi-modal 2D/3D medical image segmentation
License: MIT License
A pytorch-based deep learning framework for multi-modal 2D/3D medical image segmentation
License: MIT License
Hi,
I would like to train using my own data. I have volume x,y,z and corresponding 1 segmentation with 99 classes. what is the data size that feeded into the model. since I don't have access into the data example, what is the size of data example used?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
!python test_covid_ct.py --dataset_name covid_seg
2020-05-01 11:52:26.733364: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
COVID SEGMENTATION DATASET
0
Mode: train Subvolume samples to generate: 10 Volumes: 0
Traceback (most recent call last):
File "test_covid_ct.py", line 76, in <module>
main()
File "test_covid_ct.py", line 27, in main
path='.././datasets')
File "/content/MedicalZooPytorch/lib/medloaders/__init__.py", line 79, in generate_datasets
fold=args.fold_id, samples=samples_train, save=True)
File "/content/MedicalZooPytorch/lib/medloaders/Covid_Segmentation_dataset.py", line 70, in __init__
self.create_sub_volumes()
File "/content/MedicalZooPytorch/lib/medloaders/Covid_Segmentation_dataset.py", line 96, in create_sub_volumes
random_index = np.random.randint(total)
File "mtrand.pyx", line 743, in numpy.random.mtrand.RandomState.randint
File "_bounded_integers.pyx", line 1260, in numpy.random._bounded_integers._rand_int64
ValueError: low >= high
Can you please provide the exact command lines to train and infer a segmentation model on the COVID dataset? I see you've provided data loaders, but it's not quite clear what commands to use.
Thanks.
Does anyone has solution to this
Data: brats2018 dataset
A bug in tests.test_vizual.py
Line: 37: visualize_3D_no_overlap_new(args, full_volume, affine, model, 10, args.dim)
This leads to lib/visual3D_temp/[viz.py]
Line 111: modalities, slices, height, width = full_volume.shape
TODO:
medzoo train
medzoo infer
(we don't have inference yet)When I used the mrbrains18 dataset for training, the following error occurred
Traceback (most recent call last):
File "./train_mrbrains_9_classes.py", line 81, in
main()
File "./train_mrbrains_9_classes.py", line 26, in main
path='/home/zwj/MedicalZooPytorch-master/datasets/mrbrains_2018/training')
File "/home/zwj/MedicalZooPytorch-master/lib/medloaders/init.py", line 50, in generate_datasets
split_id=0, samples=samples_train, load=args.loadData)
AttributeError: 'Namespace' object has no attribute 'loadData'
command:
!python test_miccai_2019.py --dataset_name MICCAI_2019_pathology_challenge --nEpochs 2 --opt adam --model UNET2D
output:
2020-05-01 07:37:33.986079: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
Traceback (most recent call last):
File "test_miccai_2019.py", line 86, in <module>
main()
File "test_miccai_2019.py", line 34, in main
path='.././datasets')
File "/content/MedicalZooPytorch/lib/medloaders/__init__.py", line 17, in generate_datasets
samples_train = args.samples_train
AttributeError: 'Namespace' object has no attribute 'samples_train'
updated command :
!python test_miccai_2019.py --dataset_name MICCAI_2019_pathology_challenge --nEpochs 2 --opt adam --model UNET2D --samples_train 10
ouput:
usage: test_miccai_2019.py [-h] [--batchSz BATCHSZ]
[--dataset_name DATASET_NAME] [--nEpochs NEPOCHS]
[--dim DIM [DIM ...]] [--classes CLASSES]
[--inChannels INCHANNELS]
[--inModalities INMODALITIES] [--fold_id FOLD_ID]
[--lr LR] [--cuda] [--resume PATH]
[--model {VNET,VNET2,UNET3D,DENSENET1,DENSENET2,DENSENET3,HYPERDENSENET,UNET2D}]
[--opt {sgd,adam,rmsprop}]
test_miccai_2019.py: error: unrecognized arguments: --samples_train 10
Other way around by altering the test_miccai_2019.py code:
medical_loaders.generate_datasets(args, path='.././datasets',samples_train=samples_train,
samples_val=samples_val)
Adding samples_train and Samples_val ,rises error in generate_dataset()
After replacing the getitem method in line 77 of the file lib->medloaders>mrbrains2018.py with the following code, the error disappears and the training can proceed normally.
def __getitem__(self, index):
t1_path, ir_path, flair_path, seg_path = self.list[index]
t1_data, ir_data, flair_data, seg_data = np.load(t1_path), np.load(ir_path), np.load(flair_path), np.load(
seg_path)
return torch.FloatTensor(t1_data.copy()).unsqueeze(0), torch.FloatTensor(ir_data.copy()).unsqueeze(0), \
torch.FloatTensor(flair_data.copy()).unsqueeze(0), torch.FloatTensor(seg_data.copy())
According to the structure diagram of the paper, the final OutputTransition should look like the following:
class OutputTransition(nn.Module):
def __init__(self, in_channels, classes, elu):
super(OutputTransition, self).__init__()
self.classes = classes
# self.conv1 = nn.Conv3d(in_channels, classes, kernel_size=5, padding=2) # 修改
self.conv1 = nn.Conv3d(in_channels, classes, kernel_size=1)
self.bn1 = torch.nn.BatchNorm3d(classes)
self.conv2 = nn.Conv3d(classes, classes, kernel_size=1)
self.relu1 = ELUCons(elu, classes)
def forward(self, x):
out = self.relu1(self.bn1(self.conv1(x)))
# out = self.conv2(out) # 修改
return out
We simply use the only 111 convolutional layer to make the number of channels the same as the classes.
Can you tell me why cone to it and how to solve it?
Traceback (most recent call last):
File "train_brats2018_new.py", line 75, in
main()
File "train_brats2018_new.py", line 33, in main
trainer.training()
File "/data/Disk_A/guoyang/mqp/MedicalZooPytorch-master/lib/train/trainer.py", line 38, in training
self.validate_epoch(epoch)
File "/data/Disk_A/guoyang/mqp/MedicalZooPytorch-master/lib/train/trainer.py", line 83, in validate_epoch
output = self.model(input_tensor)
File "/data/Disk_A/guoyang/.conda/envs/pt041/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/data/Disk_A/guoyang/mqp/MedicalZooPytorch-master/lib/medzoo/Unet3D.py", line 114, in forward
out = self.conv3d_c1_1(x)
File "/data/Disk_A/guoyang/.conda/envs/pt041/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/data/Disk_A/guoyang/.conda/envs/pt041/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 478, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected 5-dimensional input for 5-dimensional weight 8 4 3 3, but got 4-dimensional input of size [4, 256, 64, 64] instead
I would like to ask about the format of using your own data set, including how many bits of data it is and what data must be included in the folder
when load processed data, there is a bug
if load:
## load pre-generated data
self.list = utils.load_list(self.save_name)
return
...
self.affine = img_loader.load_affine_matrix(list_reg_t1[0]) # it is a bug
Hi,
When trying to do inference using iseg2017 model.
I am getting below error
File "inference.py", line 80, in <module> main() File "inference.py", line 24, in main training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(args, File "/mnt/nas02/Sampledata_BrainVolumetry/brain_try/MedicalZoo/MedicalZooPytorch/lib/medloaders/__init__.py", line 28, in generate_datasets split_id=split_idx, samples=samples_train, load=args.loadData) AttributeError: 'Namespace' object has no attribute 'loadData'
When I check inference.py file its not taking any input argument for loadData
Hello!
I have trained a segmentation model using my own datasets,there is nothing wrong with my valuation dataset and the dice is high.But when I use the 'non_overlap_padding' fuction in the inference.py ,the dice score is very low.I have tried to output the prediction image (image bellow),there might something wrong with the patches index.Would you mind help me to fix this problem?Thank you very much !
Hello,
How do I perform multi class semantic (instance) segmentation over my set of 2D PNG/TIF grayscale images and their corresponding masks file (NPY numpy array, TIF or any other) matrix representation with # channels corresponding to the classes?
Do I need to use NIFTI_interface? If so, how do I convert my PNG/TIF/NPY files to this format?
Thank you
Hi @black0017 ,
Thanks for your great work.
I notice that you are also working on pre-trained models on public datasets.
Here is a benchmark for lung and infection segmentation in COVID-19 CT scans.
Are you interested in including this COVID-19 segmentation dataset for pre-trained models?
Best regards,
Jun
When I read MRbrainS18 data and use 'load_medical_image' to get volume, I find that the shape of the volume is (240, 240, 48) -> (width, height, slice). However, the shape of the crop is (slice, width, height), Is it a bug?
def load_medical_image(path, type=None, resample=None,
viz3d=False, to_canonical=False, rescale=None, normalization='full_volume_mean',
clip_intenisty=True, crop_size=(0, 0, 0), crop=(0, 0, 0), ):
img_nii = nib.load(path)
if to_canonical:
img_nii = nib.as_closest_canonical(img_nii)
if resample is not None:
img_nii = resample_to_output(img_nii, voxel_sizes=resample)
img_np = np.squeeze(img_nii.get_fdata(dtype=np.float32))
if viz3d:
> return torch.from_numpy(img_np) # shape:(240,240,48), whether it is a bug?
Hi,
How to perform 3D segmentation to the custom dataset with 3D volume and corresponding segmentation.
A dataset file structure might be helpful for iseg_2017 example.
Thanks
图像文件和标签文件的结构具体是什么样子的?????
Hi,
When I want to train on BraTS2018, I use this command line
"python train_brats2018_new.py"
It shows this problem
Summary train Epoch 1: Loss:0.7025 DSC:29.7528 Background : 0.8263 NCR/NET : 0.0612 ED : 0.2336 ET : 0.0689
Traceback (most recent call last):
File "train_brats2018_new.py", line 75, in
main()
File "train_brats2018_new.py", line 33, in main
trainer.training()
File "/content/drive/My Drive/MedicalZooPytorch/lib/train/trainer.py", line 38, in training
self.validate_epoch(epoch)
File "/content/drive/My Drive/MedicalZooPytorch/lib/train/trainer.py", line 83, in validate_epoch
output = self.model(input_tensor)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/content/drive/My Drive/MedicalZooPytorch/lib/medzoo/Vnet.py", line 150, in forward
out16 = self.in_tr(x)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/content/drive/My Drive/MedicalZooPytorch/lib/medzoo/Vnet.py", line 58, in forward
out = self.conv1(x)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 480, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected 5-dimensional input for 5-dimensional weight 16 4 5 5 5, but got 4-dimensional input of size [4, 256, 64, 64] instead
Could you help me solve that?
Would you please share your pre-trained model weights (on any datasets)? Might be greatly helpful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.