WAMAWAMA / TNSCUI2020-Seg-Rank1st

This is the source code of the 1st place solution for segmentation task in MICCAI 2020 TN-SCUI challenge.
481 stars 78 forks source link

Dataset #1

Closed cuongnc220592 closed 4 years ago

cuongnc220592 commented 4 years ago

Hi

Could you please upload the dataset of the competition I do not have the permission to download it on the website https://tn-scui2020.grand-challenge.org/Source_links/

Thank you very much

WAMAWAMA commented 4 years ago

Since the sponsor of TNSCUI challenge does not allow the dissemination of the 2020 TN-SCUI dataset, we give another thyroid ultrasound dataset demo for your reference. The demo dataset was derived from the DDTI open-access dataset, and we have processed the dataset into the format of 2020 TN-SCUI dataset,you can download it here 😉.

cuongnc220592 commented 4 years ago

Hi @WAMAWAMA As you mentioned that you only train with the second network, right.? If i try to train the model from scratch with my dataset. Do I need to train both stage 1 and stage 2 models ??

WAMAWAMA commented 4 years ago

Hi @WAMAWAMA As you mentioned that you only train with the second network, right.? If i try to train the model from scratch with my dataset. Do I need to train both stage 1 and stage 2 models ??

Hi @cuongnc220592 I don't understand your question. I trained both the 1st and 2nd networks. You can download the DDTI dataset from our link, and you will find the two folders:

the images in folder stage1 are for training the 1st network, and the images in folder stage2 are for training the 2nd one.

And, if you want to train the model from scratch with your dataset, of course you need to train both stage 1 and stage 2 models, respectively. The only and necessary difference between training the two networks is the training dataset. The full image is used to train the first network for locating, 'ROI' image is used to train the second network for refining.

cuongnc220592 commented 4 years ago

Thanks for your help @WAMAWAMA This sentence make me confused. But I understand now.

Our preliminary experiments show that the provided context information in first network may do not play a significant auxiliary role for refinement of the second network. Therefore, we only train the second network using images within region of interest (ROI) obtained from ground truth (GT).

Could you explain to me about the training network? Did you use the original UNET architecture for both stage1 and stage2 ? I do not see you mention it on the README. Thanks you very much

WAMAWAMA commented 4 years ago

@cuongnc220592 😮 I am sorry that I did not describe the full training details in the readme. We use the DeeplabV3+ with efficientnet-B6 encodermodel for both stage1 and stage2, which implemented by smp Lib.
And smp actually contains Unet structure as well, but it's different from the original structure, because smp takes some network structures with pre-trained weights as encoder, and this leads to some performance improvements relative to the original Unet structure. (BTW, we also tried original Unet or Unet++ , based on this repo: https://github.com/4uiiurz1/pytorch-nested-unet

cuongnc220592 commented 3 years ago

I have a question for training second network. Do I need set image_size to 512 for second network? You do not mention in README.

I also have a negative dataset (the images without thyroid nodule). I found your testing strategy is founding the largest connected components, right? Therefore, the number of false positive is high. Do you have any idea(e.g calcualte the probability of detection)to test the performance on negative dataset (as low as possible) Thanks you @WAMAWAMA

WAMAWAMA commented 3 years ago

@cuongnc220592 sorry for confusing you, i'll modify the README soon😉 (BTW, both 512 and 256 are OK, There is little difference in performance between the two image_size settings) and for the 'false positive’ problem,the process about "get the largest connected components" was designed for THIS CHALLENGE, so it is only suitable for 'Single target sementation'. In my experience, there may be 2 ways: 1.multi-task learning with segmentation and classification(e.g. image has nodule or not);

  1. segmenting the background but not nodules, may add a post classification network to classify the predicted mask
cuongnc220592 commented 3 years ago

Dear @WAMAWAMA

Dear author, I have a weird problem in training. I use our private dataset In the first training time of first model, everything is OK with the loss decrease and IOU, DICE score increase each epoch. Epoch[1/405], Loss: 0.8821 [Validation] Acc: 0.4715, SE: 0.5164, SP: 0.4716, PC: 0.0447, Dice: 0.0723, IOU: 0.0395 Best model in epoch 1, score : 0.0395 Epoch [2/405], Loss: 0.6939 [Validation] Acc: 0.8723, SE: 0.9429, SP: 0.8736, PC: 0.3950, Dice: 0.4846, IOU: 0.3708 Best model in epoch 2, score : 0.3708 Epoch [3/405], Loss: 0.4919 [Validation] Acc: 0.9625, SE: 0.9125, SP: 0.9652, PC: 0.5708, Dice: 0.6609, IOU: 0.5300 Best model in epoch 3, score : 0.5300

However, when I try to retrain model in second time, everything (data model, and configuration) is similar. the accuracy at the first step is very high at the first epoch, but the IOU and DICE do not improve. Training... Epoch [1/405], Loss: 0.8887 [Validation] Acc: 0.9504, SE: 0.0496, SP: 1.0000, PC: 0.0496, Dice: 1.9998, IOU: 0.0496 Best model in epoch 1, score : 0.0496 Epoch [2/405], Loss: 0.6360 [Validation] Acc: 0.9595, SE: 0.0818, SP: 0.9587, PC: 0.0818, Dice: 1.4096, IOU: 0.0818 Best model in epoch 2, score : 0.0818 Epoch [3/405], Loss: 0.3846 [Validation] Acc: 0.9783, SE: 0.0614, SP: 0.9603, PC: 0.0614, Dice: 1.2773, IOU: 0.0614 Epoch [4/405], Loss: 0.2970 [Validation] Acc: 0.9783, SE: 0.0638, SP: 0.9579, PC: 0.0638, Dice: 1.2689, IOU: 0.0638

Iam using torchvision= 0.8.1, pytorch= 1.2.0

Could you give me some suggestion to solve the problem. Thank you very much

WAMAWAMA commented 3 years ago

@cuongnc220592 Hi cuongnc220592 , sorry for replying so late 😂 The cause of this problem may be the torch version. Because DICE and IoU was calculated with torch tensor when training, torch version may make this process wrong, this bug was also found in this issue #8
You can modify the code of calculating DICE and IoU with numpy to remove this bug👍 ill try to remove this bug in few days

cuongnc220592 commented 3 years ago

Hi @WAMAWAMA I have one more concern that I have a dataset with image size 512x512 and small segmented objects (~30 mm). Hence, I would like train stage_1 model on the same image size (512x512) to save the information of small objects. In step_2 model I crop the object to 512x512 with original model. Do my idea can implement in your code? Do I need to change anything to implement (image_size at stage_1, etc ...) Thank you so much. Best.

WAMAWAMA commented 3 years ago

Actually, your idea has already be implemented in this code, in the step3_TestOrInference.py you just need to: 1) train the two different stage model, stage 1 with the full-size images in the size of 512 x 512 pixels, stage 2 with cropped and resized images of "small segmented objects" in the size of 512 x 512 pixels, 2) test by changing the params c1_size and c1_size to 512 in step3_TestOrInference.py.

cuongnc220592 commented 3 years ago

How about the result when you implement with same image size in both models? Why you decide to reduce the image size at stage 1 ?

WAMAWAMA commented 3 years ago

1) DSC will go down a little bit when using the same input size, but I think that's because of dataset specificity, you may get different results in other datasets. 2) I decide to reduce the image size at stage 1 because stage 1 is just trained for localization, so there's no need to feed a huge and high-resolution image to train it.