Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal jupyter notebook to train models #15

Open
rcillavicomtech opened this issue Mar 15, 2020 · 12 comments
Open

Minimal jupyter notebook to train models #15

rcillavicomtech opened this issue Mar 15, 2020 · 12 comments

Comments

@rcillavicomtech
Copy link

Hi,
I'm a deep learning researcher from Spain.
I have created a minimal jupyter notebook to train with the images from your repo.

https://drive.google.com/file/d/19T_qebLa1keUNpkp7FDNEBmsNRQUVtfJ/view?usp=sharing

I want to experiment with visual attention models on next days.
Rodrigo

@ieee8023
Copy link
Owner

Can you make that link public? Or maybe just upload the notebook to this issue page?

@rcillavicomtech
Copy link
Author

Now the link should work. I attach the notebook too.

COVID_19.ipynb.txt

@ieee8023
Copy link
Owner

Cool! Looks good! I had just released the torchxrayvision code! I have been doing something similar but I wasn't able to get good prediction performance. Can you include an AUC calculation on the resulting model? Also, I would expect monitoring test performance here as you do would cause you to overfit. Maybe leave out a few cases that you only test the final model on.

@rcillavicomtech
Copy link
Author

Yes, good ideas to keep improving it. I'll do it when I have spare time during the week.
Perhaps something like a VAE-GAN data augmentation approach could be useful to.

@jovenwayfarer
Copy link

Thanks for sharing,
In dataset class we have 9 labels, what they stand for?
And in your code we have 2 classes, could you explain it?
Thanks!!!

@rcillavicomtech
Copy link
Author

@jovenwayfarer Labels are binary. My code is to predict COVID19 status stored at column 2. Tomorrow I'll improve it with some ideas....

@RazaGR
Copy link

RazaGR commented Mar 19, 2020

@rcillavicomtech I tested your code 4 days ago, but due to CUDA usage in the snippet I had to run on colab, because I don't have access to any Nvidia GPU, so it took quiet some time to train the model... I am also trying to find more datasets, I look forward of your improved code

@jovenwayfarer
Copy link

model=xrv.models.DenseNet(num_classes=2).cuda()
is it densenet121? it is pretrained? if yes, on what?
Thnaks again for the notebook

@jovenwayfarer
Copy link

@ieee8023 Hi, could you help?
If I load a model like below
model=xrv.models.DenseNet(num_classes=2).cuda()
is it densenet121? it is pretrained? if yes, on what?

@ieee8023
Copy link
Owner

You can view the code here: https://github.com/mlmed/torchxrayvision/

If you specify weights you will get pretrained DenseNet 121 models based on the models trained for this paper: https://arxiv.org/abs/2002.02497

@dzlab
Copy link

dzlab commented Mar 24, 2020

@rcillavicomtech not sure to understand your training, what does PA and lab stands for?

        inputs=data['PA'].cuda()
        labels=data['lab'].long().cuda()

@Qing21
Copy link

Qing21 commented Feb 16, 2021

@rcillavicomtech Thank you for your great work! When I used the covid dataset the same way as yours, I encountered an assertion error:

Traceback (most recent call last):
File "/Users/Documents/ProgramData/Pycharm/EfficientNet-PyTorch-master/COVID-Test.py", line 222, in
train(model, train_dataloader, optimizer, criterion)
File "/Users/Documents/ProgramData/Pycharm/EfficientNet-PyTorch-master/COVID-Test.py", line 53, in train
for batch_idx, samples in enumerate(train_dataloader, 0):
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next
data = self._next_data()
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/Users/Documents/ProgramData/Pycharm/EfficientNet-PyTorch-master/dataset.py", line 304, in getitem
return self.dataset[self.idxs[idx]]
File "/Users/Documents/ProgramData/Pycharm/EfficientNet-PyTorch-master/dataset.py", line 247, in getitem
sample["img"] = self.transform(sample["img"])
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in call
img = t(img)
File "/Users/opt/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/Users/Documents/ProgramData/Pycharm/EfficientNet-PyTorch-master/utilsForCovid.py", line 35, in forward
assert isinstance(x, torch.Tensor)
AssertionError

Can anyone help with this problem? Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants