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

請問已經訓練出模型出來,該如何去測試模型分割是否理想? #328

Open
Yueem opened this issue Dec 5, 2023 · 9 comments

Comments

@Yueem
Copy link

Yueem commented Dec 5, 2023

No description provided.

@ellisdg
Copy link
Owner

ellisdg commented Dec 5, 2023

You can generate predictions using predict.py and then create a notebook or script to load the images with nibabel/numpy and generate metrics against the ground truth.
Monai has some metrics you can use: https://docs.monai.io/en/stable/metrics.html

@Yueem
Copy link
Author

Yueem commented Dec 5, 2023

抱歉我描述錯誤,其實我是想去測試資料集中其中一個nii檔,使用predict.py分割可以得到分割後的nii檔案或圖片。但我不太懂predict.py的參數
python D:\3DUnetCNN\unet3d\scripts\predict.py --output_directory test_seg --config_filename brats2020_config.json --model_filename brats2020_config\fold5\model_best.pth --group test\BraTS20_Training_048_t1.nii

@ellisdg
Copy link
Owner

ellisdg commented Dec 6, 2023

The filenames in the configuration file are split up into different "groups", typically: "training", "validation", and sometimes "test". If you are using the BRATS 2020 example, I think you should use "validation" as your group.
So the command should look like:
python D:\3DUnetCNN\unet3d\scripts\predict.py --output_directory test_seg --config_filename brats2020_config\fold5\config.json --model_filename brats2020_config\fold5\model_best.pth --group validation

Let me know if that works and I will add it to the tutorial.

@Yueem
Copy link
Author

Yueem commented Dec 13, 2023

不好意思,我找不到brats2020_config\fold5\config.json這個檔案

@ellisdg
Copy link
Owner

ellisdg commented Dec 13, 2023 via email

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are still wanting followup to this issue, please ping the thread by leaving a comment. You may also contact [email protected] with questions.

@stale stale bot added the wontfix label Mar 17, 2024
@Zzz0251
Copy link

Zzz0251 commented Aug 20, 2024

sorry to bother,you. I am using my own dataset and commands you mentioned, but don't get a normal 0-1 segmentation but a result like this below, I wonder why this happened
(the command I use:python -m unet3d.scripts.predict --output_directory data_core\predicted_t --config_filename E:\Projects\TabularSeg_FiLM\3DUnetCNN\examples\CTPseg\CTPsegCore_config\fold1.json --model_filename CTPseg\CTPsegCore_config\fold1\model_best.pth --group test)

image,

@stale stale bot removed the wontfix label Aug 20, 2024
@ellisdg
Copy link
Owner

ellisdg commented Aug 21, 2024

The predict.py script writes the output from your model which will be logit values. Using the predict.py script you can specify for it to pass the logit values through an activation function such as "sigmoid" or "softmax" before writing the predictions to file. Then to get binary values you can load the images in python using nibabel and use numpy to apply a threshold to the values (i.e. > 0.5) to get binary segmentation values.

@Zzz0251
Copy link

Zzz0251 commented Aug 22, 2024

Thanks a lot!
Here is what I did: I put my test set filenames in configuration json file ,"test_filenames". when the training is done, I get the test results.
image

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

No branches or pull requests

3 participants