openmedlab / MIS-FM

Apache License 2.0
226 stars 5 forks source link

RuntimeError #6

Open Zhenxiaoan opened 7 months ago

Zhenxiaoan commented 7 months ago

(LLM) root@node1:~/Desktop/LLM/OpenMED/MIS-FM# python train.py demo/pctnet_scratch.cfg dataset tensor_type float dataset task_type seg dataset root_dir /home/x/projects/PyMIC_project/PyMIC_examples/PyMIC_data/AtriaSeg/TrainingSet_crop dataset train_csv demo/data/image_train.csv dataset valid_csv demo/data/image_valid.csv dataset test_csv demo/data/image_test.csv dataset modal_num 1 dataset train_batch_size 2 dataset valid_batch_size 1 dataset patch_size [64, 128, 128] dataset train_transform ['RandomCrop', 'NormalizeWithMeanStd', 'RandomFlip', 'LabelToProbability'] dataset valid_transform ['NormalizeWithMeanStd', 'LabelToProbability'] dataset test_transform ['NormalizeWithMeanStd'] dataset normalizewithmeanstd_channels [0] dataset randomcrop_foreground_focus False dataset randomcrop_foreground_ratio None dataset randomcrop_mask_label None dataset randomcrop_inverse False dataset randomflip_flip_depth True dataset randomflip_flip_height True dataset randomflip_flip_width True dataset randomflip_inverse False dataset labeltoprobability_class_num 2 dataset labeltoprobability_inverse False dataset randomcrop_output_size [64, 128, 128] network net_type PCTNet network class_num 2 network in_chns 1 network input_size [64, 128, 128] network feature_chns [24, 48, 128, 256, 512] network dropout [0, 0, 0.2, 0.2, 0.2] network resolution_mode 1 network multiscale_pred True training gpus [0] training deep_supervise True training loss_type ['DiceLoss', 'CrossEntropyLoss'] training loss_weight [0.5, 0.5] training optimizer Adam training learning_rate 0.001 training momentum 0.9 training weight_decay 1e-05 training lr_scheduler StepLR training lr_gamma 0.5 training lr_step 4000 training early_stop_patience 10000 training ckpt_save_dir demo/model/pctnet_scratch training iter_start 0 training iter_max 10000 training iter_valid 500 training iter_save 10000 testing gpus [0] testing ckpt_mode 1 testing output_dir demo/result/pctnet_scratch testing sliding_window_enable True testing sliding_window_batch 8 testing sliding_window_size [64, 128, 128] testing sliding_window_stride [32, 64, 64] dataset tensor_type = float dataset task_type = seg dataset root_dir = /home/x/projects/PyMIC_project/PyMIC_examples/PyMIC_data/AtriaSeg/TrainingSet_crop dataset train_csv = demo/data/image_train.csv dataset valid_csv = demo/data/image_valid.csv dataset test_csv = demo/data/image_test.csv dataset modal_num = 1 dataset train_batch_size = 2 dataset valid_batch_size = 1 dataset patch_size = [64, 128, 128] dataset train_transform = ['RandomCrop', 'NormalizeWithMeanStd', 'RandomFlip', 'LabelToProbability'] dataset valid_transform = ['NormalizeWithMeanStd', 'LabelToProbability'] dataset test_transform = ['NormalizeWithMeanStd'] dataset normalizewithmeanstd_channels = [0] dataset randomcrop_foreground_focus = False dataset randomcrop_foreground_ratio = None dataset randomcrop_mask_label = None dataset randomcrop_inverse = False dataset randomflip_flip_depth = True dataset randomflip_flip_height = True dataset randomflip_flip_width = True dataset randomflip_inverse = False dataset labeltoprobability_class_num = 2 dataset labeltoprobability_inverse = False dataset randomcrop_output_size = [64, 128, 128] network net_type = PCTNet network class_num = 2 network in_chns = 1 network input_size = [64, 128, 128] network feature_chns = [24, 48, 128, 256, 512] network dropout = [0, 0, 0.2, 0.2, 0.2] network resolution_mode = 1 network multiscale_pred = True training gpus = [0] training deep_supervise = True training loss_type = ['DiceLoss', 'CrossEntropyLoss'] training loss_weight = [0.5, 0.5] training optimizer = Adam training learning_rate = 0.001 training momentum = 0.9 training weight_decay = 1e-05 training lr_scheduler = StepLR training lr_gamma = 0.5 training lr_step = 4000 training early_stop_patience = 10000 training ckpt_save_dir = demo/model/pctnet_scratch training iter_start = 0 training iter_max = 10000 training iter_valid = 500 training iter_save = 10000 testing gpus = [0] testing ckpt_mode = 1 testing output_dir = demo/result/pctnet_scratch testing sliding_window_enable = True testing sliding_window_batch = 8 testing sliding_window_size = [64, 128, 128] testing sliding_window_stride = [32, 64, 64] deterministric is true /root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/functional.py:507: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1711403392949/work/aten/src/ATen/native/TensorShape.cpp:3549.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] parameter number 45287730 2024-04-22 12:50:54 training start Traceback (most recent call last): File "/root/Desktop/LLM/OpenMED/MIS-FM/train.py", line 46, in main() File "/root/Desktop/LLM/OpenMED/MIS-FM/train.py", line 43, in main agent.run() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/net_run/agent_abstract.py", line 314, in run self.train_valid() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/net_run/agent_seg.py", line 314, in train_valid train_scalars = self.training() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/net_run/agent_seg.py", line 137, in training data = next(self.trainIter) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 631, in next data = self._next_data() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1346, in _next_data return self._process_data(data) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1372, in _process_data data.reraise() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/_utils.py", line 722, in reraise raise exception RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop data = fetcher.fetch(index) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 51, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/io/nifty_dataset.py", line 65, in getitem image_dict = load_image_as_nd_array(image_full_name) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/io/image_read_write.py", line 79, in load_image_as_nd_array image_dict = load_nifty_volume_as_4d_array(image_name) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/pymic/io/image_read_write.py", line 20, in load_nifty_volume_as_4d_array img_obj = sitk.ReadImage(filename) File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/SimpleITK/extra.py", line 375, in ReadImage return reader.Execute() File "/root/miniconda3/envs/LLM/lib/python3.9/site-packages/SimpleITK/SimpleITK.py", line 8430, in Execute return _SimpleITK.ImageFileReader_Execute(self) RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97: sitk::ERROR: The file "/home/x/projects/PyMIC_project/PyMIC_examples/PyMIC_data/AtriaSeg/TrainingSet_crop/BYSRSI3H4YTWKMM3MADP.nii.gz" does not exist. How to fix it?

taigw commented 1 day ago

From your error information, it seems that you have not set the path for training images correctly. Please see the latest readme file. You need to set train_dir in the configuration file correctly based on your own machine.