amanbasu / 3d-prostate-segmentation

Segmentation of prostate from MRI scans
GNU General Public License v3.0
44 stars 13 forks source link

Output from predict.py #6

Closed ghost closed 3 years ago

ghost commented 4 years ago

I would like to make prediction based on my trained model. I put my test data in the folder of val-data and run predict.py. The code is running, however, I don't see any output of segmentation image after the code has been executed successfully. I would like to know what the output I should see on predict.py?

Thanks.

amanbasu commented 4 years ago

The file predict.py doesn't give you the option to save the prediction. For that, you need to make some changes to the code. The last line of the file stores the prediction in a python list which you can save to get the model predictions. Here is the code that you can use.

import SimpleITK as sitk for i in range(5):

index = i*2
index1 = i*2+1
if index<10:
    index = '0'+str(index)
if index1<10:
    index1 = '0'+str(index1)

p1 = sitk.GetImageFromArray(np.transpose((predictions

[i][0]>0.5).astype(np.uint8),(2,0,1))) sitk.WriteImage(p1, 'prediction/Case{}.mhd'.format(index))

p2 = sitk.GetImageFromArray(np.transpose((predictions

[i][1]>0.5).astype(np.uint8),(2,0,1))) sitk.WriteImage(p2, 'prediction/Case{}.mhd'.format(index1))

On Tue, Mar 24, 2020 at 5:59 PM harrislin2018 notifications@github.com wrote:

I would like to make prediction based on my trained model. I put my test data in the folder of val-data and run predict.py. The code is running, however, I don't see any output of segmentation image after the code has been executed successfully. I would like to know what the output I should see on predict.py?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/amanbasu/3d-prostate-segmentation/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGD6WLW6OBLNJFQ6ZIEV4BLRJCRT5ANCNFSM4LSTO2IA .

-- Regards, Aman

Email: amanag.11@gmail.com | Mobile: +91 75740 14476 | Homepage: Aman Agarwal https://amanbasu.github.io/portfolio

amanbasu commented 3 years ago

I hope this query is resolved.