I want to load nii.gz file from s3 and apply transform on that image.
LoadImaged in compose need file path as input. But when i load image as object. So i feel transfrom is failing as LoadImaged cant accept objects.
Below code works fine when i run on sagemaker. As i don't need to download image from s3
val_transforms = Compose(
[
LoadImaged(keys=["image"]),
EnsureChannelFirstd(keys=["image"]),
Spacingd(keys=["image"], pixdim=(
1.5, 1.5, 2.0), mode=("bilinear")),
Orientationd(keys=["image"], axcodes="RAS"),
ScaleIntensityRanged(
keys=["image"], a_min=-57, a_max=164,
b_min=0.0, b_max=1.0, clip=True,
),
CropForegroundd(keys=["image"], source_key="image"),
EnsureTyped(keys=["image"]),
]
)
test_data = {"image": filepath}
Transformed_data = val_transforms(test_data)
Below code is same as above with extra lines of code to download object from s3.
val_transforms = Compose(
[
LoadImaged(keys=["image"]),
EnsureChannelFirstd(keys=["image"]),
Spacingd(keys=["image"], pixdim=(
1.5, 1.5, 2.0), mode=("bilinear")),
Orientationd(keys=["image"], axcodes="RAS"),
ScaleIntensityRanged(
keys=["image"], a_min=-57, a_max=164,
b_min=0.0, b_max=1.0, clip=True,
),
CropForegroundd(keys=["image"], source_key="image"),
EnsureTyped(keys=["image"]),
]
)
object = bucket.Object(key)
response = object.get()
file_stream = response['body']
test_data = {"image": file_stream}
Transformed_data = val_transforms(test_data)
Please suggest me the different ways to load the images and apply transform.
Note: i cant get the path of the image to pass it to LoadImaged or LoadImage
I want to load nii.gz file from s3 and apply transform on that image.
LoadImaged in compose need file path as input. But when i load image as object. So i feel transfrom is failing as LoadImaged cant accept objects.
Below code works fine when i run on sagemaker. As i don't need to download image from s3
Below code is same as above with extra lines of code to download object from s3.
Please suggest me the different ways to load the images and apply transform.
Note: i cant get the path of the image to pass it to
LoadImagedorLoadImage