ChenWWWeixiang / OpenCovidDetector

New virsion for multi-categories were available. Since too many changes above old virsion, please refer to this site https://github.com/ChenWWWeixiang/diagnosis_covid19
18 stars 6 forks source link

Segmentation model #5

Closed hnguyentt closed 4 years ago

hnguyentt commented 4 years ago

Hello,

I used data from this repository to build a segmentation model: https://www.kaggle.com/kmader/finding-lungs-in-ct-data Then I tested my own data on your diagnosis network, the result was not good. I think that was because of the segmentation model.

Could you please share with us your trained segmentation model to test?

ChenWWWeixiang commented 4 years ago

The segmentation model and weights are available in https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/inprogram/segmentation and https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/inprogram/segmentation/lung_checkpoint.pth which are in the inprograming branch. Codes in this branch havn't been well organized.

The reason for bad results, I think, might come from diffenrent spacing or different CT scan areas. I suggest to change the code in https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/master/data/dataset.py in line 382 and 383. Since CTs in our experiments were all in spacing of 1x1x1, we simply use NO.-300 to NO.-40 in Z direction as lung areas. The better way is to use lung segmentaions to ditermine lung areas. I will also fix these codes in latter commit.

I hope it will help.

hnguyentt commented 4 years ago

Thank you very much for your detailed instructions. I will try and let you know the results.

The spacing in my CT scans model is also 1x1x1.

hnguyentt commented 4 years ago

The segmentation model and weights are available in https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/inprogram/segmentation and https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/inprogram/segmentation/lung_checkpoint.pth which are in the inprograming branch. Codes in this branch havn't been well organized.

The reason for bad results, I think, might come from diffenrent spacing or different CT scan areas. I suggest to change the code in https://github.com/ChenWWWeixiang/OpenCovidDetector/blob/master/data/dataset.py in line 382 and 383. Since CTs in our experiments were all in spacing of 1x1x1, we simply use NO.-300 to NO.-40 in Z direction as lung areas. The better way is to use lung segmentaions to ditermine lung areas. I will also fix these codes in latter commit.

I hope it will help.

The model lung_checkpoint.pth has 3-class output. I don't know why it is three. It should be 2: lung or no lung, shouldn't it? What is the third class?

hnguyentt commented 4 years ago

I also have another question: Why the image and the mask in your example data do not have the same shape:

Imag shape: (297, 295, 390) Mask shape: (282, 302, 390)

ChenWWWeixiang commented 4 years ago

The mismatch of shape came from padding and pooling layer of old version segmentation. The new version Unet model will work well. The Unet lung segmentation model output left and right lung as seperate classes so there are 3-class output.

hnguyentt commented 4 years ago

May I ask what segmentation model you use in the evaluation?

ChenWWWeixiang commented 4 years ago

The segmentation model we used in our preprint is deeplabV1 and we now use Unet which might be a better method. You can find the implement in https://github.com/ChenWWWeixiang/OpenCovidDetector/tree/inprogram/segmentation

hnguyentt commented 4 years ago

Hi @ChenWWWeixiang ,

I tested your unet model and thought that your deeplabV1 worked much better than your unet model. Could please share your trained deeplabv1 model? Following is the comparison:

ChenWWWeixiang commented 4 years ago

Hi @nguyenhoa93
I have checked my codes and your result. First, I think you might be using "checkpoint_200000.pth" rather than "lung_checkpoint.pth"and the former is a half-done checkpoint to segment lesion area. Then, I fixed a stupid bug in unet.py that input images had been divided by 255 outside in predict.py and was divided by 255 again in unet.py. The code works now. And the DeeplabV1 version model was developed by my collegue, there may be some time to get the pretrained weight. If Unet works, I suggest to use the new version model.

hnguyentt commented 4 years ago

Thank you @ChenWWWeixiang

One more question: Did you take raw data as input for your segmentation model? And then resampled them and put resampled data and resampled segmentation to diagnosis model?

ChenWWWeixiang commented 4 years ago

Yes