ljwztc / CLIP-Driven-Universal-Model

[ICCV 2023] CLIP-Driven Universal Model; Rank first in MSD Competition.
Other
572 stars 69 forks source link

Question about model weights. #27

Closed transcendentsky closed 1 year ago

transcendentsky commented 1 year ago

Thanks for sharing your well-trained weights. There are two problems when trying.

  1. The keys of weights and model.state_dict() are not matched well. This is just a small problem which I fix it by force matching the keys.
  2. I tested swinunetr.pth on BTCV dataset but achieve bad performance. (using test.py)

Task01| Spleen: 0.0322, Right Kidney: 0.0960, Left Kidney: 0.0265, Gall Bladder: 0.0925, Esophagus: 0.0000, Liver: 0.4375, Stomach: 0.0439, Aorta: 0.0153, Postcava: 0.0270, Portal Vein and Splenic Vein: 0.0281, Pancreas: 0.0403, Right Adrenal Gland: 0.0000, Left Adrenal Gland: 0.0015, Duodenum: nan, Task01_2| Spleen: nan, Left Kidney: nan, Gall Bladder: nan, Esophagus: nan, Liver: nan, Stomach: nan, Pancreas: nan, Duodenum: nan, Task02| Spleen: nan, Left Kidney: nan, Gall Bladder: nan, Esophagus: nan, Liver: nan, Stomach: nan, Pancreas: nan, Duodenum: nan, Task03| Liver: nan, Task04| Liver: nan, Liver Tumor: nan, Task05| Right Kidney: nan, Left Kidney: nan, Kidney Tumor: nan, Kidney Cyst: nan, Task06| Spleen: nan, Right Kidney: nan, Left Kidney: nan, Gall Bladder: nan, Liver: nan, Stomach: nan, Pancreas: nan, Right Lung: nan, Left Lung: nan, Task07| Liver: nan, Spleen: nan, Left Kidney: nan, Right Kidney: nan, Stomach: nan, Gall Bladder: nan, Esophagus: nan, Pancreas: nan, Duodenum: nan, Colon: nan, Intestine: nan, Right Adrenal Gland: nan, Left Adrenal Gland: nan, Rectum: nan, Bladder: nan, Left Head of Femur: nan, Right Head of Femur: nan, Task08| Liver: nan, Right Kidney: nan, Left Kidney: nan, Spleen: nan, Pancreas: nan, Task09| Spleen: nan, Right Kidney: nan, Left Kidney: nan, Gall Bladder: nan, Esophagus: nan, Liver: nan, Stomach: nan, Aorta: nan, Postcava: nan, Pancreas: nan, Right Adrenal Gland: nan, Left Adrenal Gland: nan, Duodenum: nan, Bladder: nan, Prostate: nan, Task12| Liver: nan, Bladder: nan, Right Lung: nan, Left Lung: nan, Right Kidney: nan, Left Kidney: nan, Task13| Liver: nan, Right Kidney: nan, Left Kidney: nan, Spleen: nan, Pancreas: nan, Aorta: nan, Postcava: nan, Stomach: nan, Gall Bladder: nan, Esophagus: nan, Right Adrenal Gland: nan, Left Adrenal Gland: nan, Celiac Truck: nan, Task14| Pancreas: nan, Pancreas Tumor: nan, Task10_03| Liver: nan, Liver Tumor: nan, Task10_06| Lung Tumor: nan, Task10_07| Pancreas: nan, Pancreas Tumor: nan, Task10_08| Hepatic Vessel: nan, Hepatic Vessel Tumor: nan, Task10_09| Spleen: nan, Task10_10| Colon Tumor: nan, Task15| Spleen: nan, Right Kidney: nan, Left Kidney: nan, Gall Bladder: nan, Esophagus: nan, Liver: nan, Stomach: nan, Aorta: nan, Postcava: nan, Portal Vein and Splenic Vein: nan, Pancreas: nan, Right Adrenal Gland: nan, Left Adrenal Gland: nan, Duodenum: nan, Hepatic Vessel: nan, Right Lung: nan, Left Lung: nan, Average | Spleen: 0.0322, Right Kidney: 0.0960, Left Kidney: 0.0265, Gall Bladder: 0.0925, Esophagus: 0.0000, Liver: 0.4375, Stomach: 0.0439, Aorta: 0.0153, Postcava: 0.0270, Portal Vein and Splenic Vein: 0.0281, Pancreas: 0.0403, Right Adrenal Gland: 0.0000, Left Adrenal Gland: 0.0015, Duodenum: nan, Hepatic Vessel: nan, Right Lung: nan, Left Lung: nan, Colon: nan, Intestine: nan, Rectum: nan, Bladder: nan, Prostate: nan, Left Head of Femur: nan, Right Head of Femur: nan, Celiac Truck: nan, Kidney Tumor: nan, Liver Tumor: nan, Pancreas Tumor: nan, Hepatic Vessel Tumor: nan, Lung Tumor: nan, Colon Tumor: nan, Kidney Cyst: nan, average: nan,

How can i solve it ?

ljwztc commented 1 year ago

Thanks for your interest. The weight can be used in our following works. So maybe there is some error in test code for this version. We would fix this as soon as possible.

Adoreeeeee commented 1 year ago

Thanks for your interest. The weight can be used in our following works. So maybe there is some error in test code for this version. We would fix this as soon as possible.

It's a wonderful job. Have you solved this problem so far? If not, how long will it take to resolve

ljwztc commented 1 year ago

Thanks for your reminder. The weight load problem has been fixed.

Adoreeeeee commented 1 year ago

Thank you for such a prompt reply! But after I updated the code you uploaded last night, the test results on BTCV61-80(test.py) are still poor. I followed the steps of READEME and I would like to know if you have any more advice for me so that I can reproduce your results. Hope to hear from you again. Spleen: dice 0.0008, recall 0.0018, precision 0.0005. Right Kidney: dice 0.0021, recall 0.0037, precision 0.0015. Left Kidney: dice 0.0016, recall 0.0024, precision 0.0012. Gall Bladder: dice 0.0114, recall 0.0078, precision 0.0209. Esophagus: dice 0.0025, recall 0.0015, precision 0.0089. Liver: dice 0.0004, recall 0.0049, precision 0.0002. Stomach: dice 0.0038, recall 0.0082, precision 0.0025. Aorta: dice 0.0009, recall 0.0008, precision 0.0010. Postcava: dice 0.0005, recall 0.0005, precision 0.0005. Portal Vein and Splenic Vein: dice 0.0001, recall 0.0001, precision 0.0002. Pancreas: dice 0.0038, recall 0.0034, precision 0.0043. Right Adrenal Gland: dice 0.0009, recall 0.0005, precision 0.0108. Left Adrenal Gland: dice 0.0006, recall 0.0003, precision 0.0078. Duodenum: dice 0.0033, recall 0.0030, precision 0.0035.

Adoreeeeee commented 1 year ago

And I don't quite understand how to test when doing BTCV test set testing, there is no mask. Execute python -W ignore label_transfer.py when doing preprocessing, how to proceed with a test set without masks.

ljwztc commented 1 year ago

If you only hope to do inference for case without masks, you can ignore the label_transfer step. Just correctly load the weight and store the prediction with --store_result. Then, you will find the prediction, and calculate dice score with ground truth.

Yes, you are right, the dice result in test.py is based on the post label processed by label_transfer.py. Since we re-split the data into train, validation and test, we just run the test.py to test the model performance.

This is the result of case0023. Spleen: dice 0.9544, recall 0.9380, precision 0.9714. Right Kidney: dice 0.9466, recall 0.9733, precision 0.9214. Left Kidney: dice 0.9416, recall 0.9773, precision 0.9084. Esophagus: dice 0.8707, recall 0.8867, precision 0.8554. Liver: dice 0.9675, recall 0.9649, precision 0.9702. Stomach: dice 0.9477, recall 0.9463, precision 0.9491. Aorta: dice 0.9004, recall 0.8550, precision 0.9508. Postcava: dice 0.8713, recall 0.9347, precision 0.8160. Portal Vein and Splenic Vein: dice 0.7708, recall 0.7162, precision 0.8347. Pancreas: dice 0.8113, recall 0.9133, precision 0.7299. Right Adrenal Gland: dice 0.7384, recall 0.8414, precision 0.6582. Left Adrenal Gland: dice 0.8280, recall 0.8206, precision 0.8360. Duodenum: dice 0.8835, recall 0.8852, precision 0.8819. case01_Multi-Atlas_Labeling/label/label0023| Spleen: 0.9544, Right Kidney: 0.9466, Left Kidney: 0.9416, Esophagus: 0.8707, Liver: 0.9675, Stomach: 0.9477, Aorta: 0.9004, Postcava: 0.8713, Portal Vein and Splenic Vein: 0.7708, Pancreas: 0.8113, Right Adrenal Gland: 0.7384, Left Adrenal Gland: 0.8280, Duodenum: 0.8835,

Adoreeeeee commented 1 year ago

Your advice is very effective! And I have reproduced similar results to yours (case0023). But I still failed on how a test set without labels produces valid predictions. I read your other responses carefully, intending to use pred_pseudo.py to generate GT and then test it with test.py. But the pred_pseudo.py must have a corresponding image tag and a corresponding .h5 file, but my test set does not have a corresponding tag, and I can't do this. Hope to hear from you again. Task01| Spleen: 0.9436, Right Kidney: 0.9222, Left Kidney: 0.9273, Gall Bladder: nan, Esophagus: 0.8578, Liver: 0.9640, Stomach: 0.9392, Aorta: 0.8480, Postcava: 0.8242, Portal Vein and Splenic Vein: 0.4924, Pancreas: 0.7396, Right Adrenal Gland: 0.7397, Left Adrenal Gland: 0.7310, Duodenum: nan.........

ljwztc commented 1 year ago

Hi @Adoreeeeee , I have revised the related code and now you can run pred_pseudo.py to obtain the prediction with image input only.

Adoreeeeee commented 1 year ago

Thank you for your suggestions and updates! They are very useful.