Comments (13)
For reference, here's a Colab notebook in which I manage to run the segmentation (using TorchIO): https://colab.research.google.com/drive/1XprcAZ59dAYBGFjawgb7h9mx0Y9N6pTj?usp=sharing
I assumed a spacing of 1 x 1 x 9 mm and LPS orientation.
from brain-segmentation-pytorch.
Hi @fepegar, thanks for trying the model.
The notebook on PyTorch Hub runs inference on one slice.
This can be done, but the model was trained on images normalized per MRI volume.
from brain-segmentation-pytorch.
Thanks. I think that it's detrimental for you and for PyTorch that the provided example is not representative of the original model's performance. Could you update the example with a more appropriate image or with the preprocessing needed for this specific slice? If not? Could you please do that here?
from brain-segmentation-pytorch.
The problem is that it would require loading the entire 4D MRI volume in the code sample which is run as a test every time there is a PR to pytorch/hub repository.
Another option is that I hardcode the mean and standard deviation computed on a volume for the example slice.
However, I wanted to show that you have to normalize the input.
The fact that you have to normalize the input per volume is described at the beginning of the Example section: https://github.com/pytorch/hub/blob/master/mateuszbuda_brain-segmentation-pytorch_unet.md#example
There is also a link to the dataset that contains complete volumes.
Anyway, I will compute the mean and std that give expected predictions.
from brain-segmentation-pytorch.
The problem is that it would require loading the entire 4D MRI volume in the code sample which is run as a test every time there is a PR to pytorch/hub repository.
In my first suggestion (which I just edited, because there was a word missing), I meant that you could replace the current link with one to an already preprocessed slice of that 4D image.
Another option is that I hardcode the mean and standard deviation computed on a volume for the example slice.
This is what I meant by "the preprocessing needed for this specific slice".
The fact that you have to normalize the input per volume is described at the beginning of the Example section: https://github.com/pytorch/hub/blob/master/mateuszbuda_brain-segmentation-pytorch_unet.md#example
There is also a link to the dataset that contains complete volumes.
Sure, but I think that it would help you and the users if the example was self-contained, especially if you're explicitly using a sample image for it.
Let me know if I can help.
from brain-segmentation-pytorch.
By the way, the image I used, assuming 32 bits per voxel, takes 18 MB in memory. The frequency of PRs on pytorch/hub doesn't seem very high, so I think it would be fine to upload the actual 4D image, ideally in a format that supports 4D images such as NIfTI or NRRD. You could use TorchIO to convert the images to any of those formats.
from brain-segmentation-pytorch.
The problem is that it would require loading the entire 4D MRI volume in the code sample which is run as a test every time there is a PR to pytorch/hub repository.
Another option is that I hardcode the mean and standard deviation computed on a volume for the example slice.
However, I wanted to show that you have to normalize the input.
The fact that you have to normalize the input per volume is described at the beginning of the Example section: https://github.com/pytorch/hub/blob/master/mateuszbuda_brain-segmentation-pytorch_unet.md#example
There is also a link to the dataset that contains complete volumes.
Anyway, I will compute the mean and std that give expected predictions.
If i need to upload a 4D data test image and get the segmentation on that ? How to do it ?
from brain-segmentation-pytorch.
Hi, and thanks for sharing your work! I have run the notebook you shared on PyTorch Hub and added one cell:
import scipy.ndimage as ndi import matplotlib.pyplot as plt pred = output[0, 0].cpu().numpy() pred_bin = pred > 0.5 pred -= pred.min() pred /= pred.max() pred *= 255; borders = ndi.binary_dilation(pred_bin) ^ pred_bin input_array = np.array(input_image).copy() input_array[borders] = input_array.max() fig, axes = plt.subplots(1, 3, figsize=(12, 8)) axes[0].imshow(input_image) axes[1].imshow(pred) axes[2].imshow(input_array)The segmentation is very inaccurate. Am I doing something wrong?
@fepegar I tried this on few samples, it works great . But can the output be displayed as something like this using torchio ? can you please give inputs for this ?
ie overlapping the segmented part with the Brain MRI image
from brain-segmentation-pytorch.
Yes, you could potentially use TorchIO for that visualization. But it would probably be easier (or more powerful) to use SimpleITK and then matplotlib.
from brain-segmentation-pytorch.
Hi, and thanks for sharing your work! I have run the notebook you shared on PyTorch Hub and added one cell:
import scipy.ndimage as ndi import matplotlib.pyplot as plt pred = output[0, 0].cpu().numpy() pred_bin = pred > 0.5 pred -= pred.min() pred /= pred.max() pred *= 255; borders = ndi.binary_dilation(pred_bin) ^ pred_bin input_array = np.array(input_image).copy() input_array[borders] = input_array.max() fig, axes = plt.subplots(1, 3, figsize=(12, 8)) axes[0].imshow(input_image) axes[1].imshow(pred) axes[2].imshow(input_array)The segmentation is very inaccurate. Am I doing something wrong?
@fepegar I tried this on few samples, it works great . But can the output be displayed as something like this using torchio ? can you please give inputs for this ?
could you please share a colab notebook for this result @kruthikakr @fepegar
from brain-segmentation-pytorch.
There is no co lab notebook done for this . As said i just used the ITK only
from brain-segmentation-pytorch.
@kruthikakr can you share your notebook to get the above result?
from brain-segmentation-pytorch.
I've made the appropriate normalization.
Check the colab.
from brain-segmentation-pytorch.
Related Issues (20)
- Reproducibility issue HOT 5
- how to train on my dataset HOT 5
- Training on a custom dataset HOT 1
- in_channels parameter change causes size mismatch HOT 5
- Retraining on own dataset HOT 1
- ValueError: Sample larger than population or is negative HOT 2
- A puzzle about the code HOT 1
- How can I run the docker container if my GPU isn't nvidia
- Very large images on my dataset
- Run on the test data HOT 3
- Can I run the code on test folder without the masks??
- google colab
- how can I apply other loss functions
- IoU of the model
- Negative loss value HOT 3
- After UNet Inference, how to overlay / superimpose the different size predicted masks to the original image size?
- dice
- Error
- manifest for nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04 not found: manifest unknown: manifest unknown
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brain-segmentation-pytorch.