openmedlab / MedLSAM

MedLSAM: Localize and Segment Anything Model for 3D Medical Images
Apache License 2.0
489 stars 19 forks source link

I don't need to do any prompt words, you can get the desired segmentation mask, your code can achieve this function.I don't need to do any prompt words, you can get the desired segmentation mask, your code can achieve this function. #5

Open BelieferQAQ opened 1 year ago

BelieferQAQ commented 1 year ago

Thank you for your contribution. I currently want to perform node segmentation, which is a binary segmentation, and the dataset file is in NIFIT format. I don't need to do any prompt words, you can get the desired segmentation mask, your code can achieve this function. Looking forward to your reply.

LWHYC commented 1 year ago

Thank you for your interest in my project. The current version of MedLSAM is designed for anatomical structure segmentation and localization, not specifically for nodule detection and segmentation. Therefore, it may not perform well on nodule segmentation tasks without significant modifications or adaptation. I would recommend looking for a tool or method specifically designed for nodule detection and segmentation. Best of luck with your work!

BelieferQAQ commented 1 year ago

Thank your reply! but i meet some problems when i run your code , MedLSAM_inference.py。The setting code is:parser.add_argument('-c', '--config_file', type=str, default='config/test_config/test_structseg_medlam_medsam.txt', help='path to the config file') The problem is below: The image is not in the target orientation. Reorienting... The image is not in the target orientation. Reorienting... 60%|████████████████████████████████████████████████████▊ | 3/5 [00:22<00:14, 7.37s/it] Traceback (most recent call last): File "/data/jupyter/wd/MedLSAM-LymNode/MedLSAM_Inference.py", line 93, in ana_det = AnatomyDetection(args.config_file) File "/data/jupyter/wd/MedLSAM-LymNode/MedLAM/Anatomy_detection.py", line 58, in init self.RD=process_support(self.RD, support_image_ls, support_label_ls, self.patch_size, fg_class) File "/data/jupyter/wd/MedLSAM-LymNode/MedLAM/Cal_support_feature.py", line 19, in process_support support_label = pad(load_and_pre_ct(support_label_ls[idx], mode='label')['image'], patch_size) File "/data/jupyter/wd/MedLSAM-LymNode/data_process/data_process_func.py", line 133, in load_and_pre_ct image = np.int32(resize_Multi_label_to_given_shape(np.int32(image), zoom_factor=zoom_factor).numpy()) File "/data/jupyter/wd/MedLSAM-LymNode/data_process/data_process_func.py", line 182, in resize_Multi_label_to_given_shape oh_volume = torch.nn.functional.one_hot(volume, -1).float().permute(3,0,1,2).unsqueeze(0) RuntimeError: index 1048576 is out of bounds for dimension 3 with size 23

LWHYC commented 1 year ago

Hi, This error message indicates that while performing one-hot encoding on your data, the input data contained labels that exceeded the expected range. In this case, your code expects the maximum label value to be 22 (since the size of dimension 3 is 23, and the indexing of one-hot encoding starts from 0), but it found an element with a label value of 1048576 in the input data, which caused the error.

I will suggest you check the input label to ensure all label values fall within the expected range. If you are using the original structseg dataset, I wonder if you could recheck whether your label input path is correct.