Closed taylover12138 closed 1 year ago
Hi, thank you for your interest towards our work! Just want to know more context about your experiments. Do you just use my pretrained model to run inference? Or you trained your own model with your dataset first and then perform testing?
Hi, thank you for your interest towards our work! Just want to know more context about your experiments. Do you just use my pretrained model to run inference? Or you trained your own model with your dataset first and then perform testing?
Thank you very much for your reply! I used your model to train my data set. I didn't use your pre-trained model. In addition, I found that the program error is the problem here:
Invertd(
keys="pred", # invert the pred
data field, also support multiple fields
transform=test_transforms,
orig_keys="image", # get the previously applied pre_transforms information on the img
data field,
pred
based on this information. we can use same info # for multiple fields, also support different orig_keys for different fields
meta_keys="pred_meta_dict", # key field to save inverted meta data, every item maps to `keys`
orig_meta_keys="image_meta_dict", # get the meta data from `img_meta_dict` field when inverting,
# for example, may need the `affine` to invert `Spacingd` transform,
# multiple fields can use the same meta data to invert
meta_key_postfix="meta_dict", # if `meta_keys=None`, use "{keys}_{meta_key_postfix}" as the meta key,
# if `orig_meta_keys=None`, use "{orig_keys}_{meta_key_postfix}",
# otherwise, no need this arg during inverting
nearest_interp=False, # don't change the interpolation mode to "nearest" when inverting transforms
# to ensure a smooth output, then execute `AsDiscreted` transform
to_tensor=True, # convert to PyTorch Tensor after inverting
),
When I deleted this code, the error didn't happen.
But I need this code, how do I change it?
Got it. Have you followed my installation instruction that installed the specific MONAI version? Because MONAI function changes a lot in each version and some of the code only can be used in particular version, especially for invertd this function.
I found that the version of MONAI I was using was 1.1.0. I will try to change the version to 0.9.0.
Make sense to me! Let's take a look and I believe it is the version problem.
Thank you very much! That's the problem with the MONAI version! The problem was fixed when I switched to 0.9.0.
Great! Just post any issues if you have any inquires on the code.
Hello! Thank you for your great work in 3DUX-Net! But I ran into a problem when running this project on my own data set: When I run this program: test_seg.py. Encountered this error:
Traceback (most recent call last): File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 102, in apply_transform return _apply_transform(transform, data, unpack_items) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 66, in _apply_transform return transform(parameters) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/croppad/dictionary.py", line 318, in inverse d[key] = self.cropper.inverse(d[key]) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/croppad/array.py", line 885, in inverse transform = self.get_most_recent_transform(img) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/inverse.py", line 186, in get_most_recent_transform raise ValueError(f"
data
should be eitherMetaTensor
or dictionary, got {type(data)}.") ValueError:data
should be eitherMetaTensor
or dictionary, got <class 'numpy.ndarray'>.The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 102, in apply_transform return _apply_transform(transform, data, unpack_items) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 66, in _apply_transform return transform(parameters) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/post/dictionary.py", line 701, in call inverted = self.transform.inverse(input_dict) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/compose.py", line 184, in inverse data = apply_transform(t.inverse, data, self.map_items, self.unpack_items, self.log_stats) File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 129, in apply_transform raise RuntimeError(f"applying transform {transform}") from e RuntimeError: applying transform <bound method Cropd.inverse of <monai.transforms.croppad.dictionary.CropForegroundd object at 0x7f56e00c1a90>>
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/root/autodl-tmp/project/seg/3DUX/3DUX-Net-main/test_seg.py", line 108, in
test_data = [post_transforms(i) for i in decollate_batch(test_data)]
File "/root/autodl-tmp/project/seg/3DUX/3DUX-Net-main/test_seg.py", line 108, in
test_data = [post_transforms(i) for i in decollate_batch(testdata)]
File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/compose.py", line 174, in call
input = apply_transform(transform, input, self.map_items, self.unpack_items, self.log_stats)
File "/root/miniconda3/lib/python3.8/site-packages/monai/transforms/transform.py", line 129, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.post.dictionary.Invertd object at 0x7f56e012ccd0>
I didn't know how to handle it so I came to ask you. Please reply as soon as possible, thank you!