I am trying to run inference locally, using the following command:
$ PYTHONPATH=/tmp/Hippocampus_ python \
~/git/RadiomicsNN/innereye-deeplearning/score.py \
--data_folder /tmp/inputs \
--model_folder /tmp/Hippocampus_ \
--no-use_gpu
I got the following error:
Traceback (most recent call last):
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/score.py", line 311, in <module>
main()
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/score.py", line 307, in main
score_image(ScorePipelineConfig.parse_args())
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/score.py", line 289, in score_image
segmentation = run_inference(images, inference_pipeline, config)
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/score.py", line 132, in run_inference
photo_norm_images = [photo_norm.transform(image_with_header.image) for image_with_header in images_with_header]
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/score.py", line 132, in <listcomp>
photo_norm_images = [photo_norm.transform(image_with_header.image) for image_with_header in images_with_header]
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/InnerEye/ML/photometric_normalization.py", line 99, in transform
self.output_range, self.sharpen, self.tail, self.debug_mode
File "/home/fernando/git/RadiomicsNN/innereye-deeplearning/InnerEye/ML/photometric_normalization.py", line 300, in mri_window
min(max_foreground, level + tail[ichannel] * std_i * sharpen))
IndexError: list index out of range
In photometric_normalization.py:
|
nchannel = image_in.shape[0] |
Hence, this function expects a 4D image with the channels dimension being the first. However, images are loaded in
|
def read_image_as_array_with_header(file_path: Path) -> Tuple[np.ndarray, ImageHeader]: |
|
""" |
|
Read image with simpleITK as a ndarray. |
|
|
|
:param file_path: |
|
:return: Tuple of ndarray with image in Z Y X and Spacing in Z X Y |
|
""" |
|
image: sitk.Image = sitk.ReadImage(str(file_path)) |
|
img = sitk.GetArrayFromImage(image) # This call changes the shape to ZYX |
|
spacing = reverse_tuple_float3(image.GetSpacing()) |
|
# We keep origin and direction on the original shape since it is not used in this library |
|
# only for saving images correctly |
|
origin = image.GetOrigin() |
|
direction = image.GetDirection() |
|
|
|
return img, ImageHeader(origin=origin, direction=direction, spacing=spacing) |
which returns a 3D image.
I'm not sure what an appropriate solution would be. Maybe just adding a channels dimension at the beginning of PhotometricNormalization.transform and removing it before returning?
AB#5331
I am trying to run inference locally, using the following command:
$ PYTHONPATH=/tmp/Hippocampus_ python \ ~/git/RadiomicsNN/innereye-deeplearning/score.py \ --data_folder /tmp/inputs \ --model_folder /tmp/Hippocampus_ \ --no-use_gpuI got the following error:
In
photometric_normalization.py:InnerEye-DeepLearning/InnerEye/ML/photometric_normalization.py
Line 276 in 95d8b72
Hence, this function expects a 4D image with the channels dimension being the first. However, images are loaded in
InnerEye-DeepLearning/InnerEye/ML/utils/io_util.py
Lines 186 to 201 in 95d8b72
which returns a 3D image.
I'm not sure what an appropriate solution would be. Maybe just adding a channels dimension at the beginning of
PhotometricNormalization.transformand removing it before returning?AB#5331