ValueError: y_pred and y should have same shapes #596
-
Hello @yiheng-wang-nv @wyli @rijobro @Nic-Ma https://github.com/HripsimeS/Computer-Vision/blob/main/3DUnet_testing.ipynb |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hi @HripsimeS , sorry for late reply. I checked your code, Where you used
Can you please change it into: |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply!
Here is where I am getting errors without using labels as key in validation
transform.
#596 (reply in thread)
and thanks for suggestions about inference mode!
*Best Regards,*
Virendra Ashiwal,
Linz, Austria
…On Sun, 27 Mar 2022 at 07:57, Hripsime Snkhchyan ***@***.***> wrote:
@ashiwalv <https://github.com/ashiwalv> below label is removed from
Orientationd, Spacingd and CropForegroundd which will calculate the metric
on original shapes.
Like this you can text your model on dataset outside of your training
model, in test dataset you need to have images with their masks.
val_org_transforms = Compose(
[
LoadImaged(keys=["image", "label"]),
EnsureChannelFirstd(keys=["image", "label"]),
Orientationd(keys=["image"], axcodes="RAS"),
Spacingd(keys=["image"], pixdim=(1.5, 1.5, 2.0), mode="bilinear"),
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", "label"]),
]
)
But if you want to test your model on inference mode, it means just upload
the image and receive a predicied mask, you can do this
test_org_transforms = Compose(
[
LoadImaged(keys="image"),
EnsureChannelFirstd(keys="image"),
Orientationd(keys=["image"], axcodes="RAS"),
Spacingd(keys=["image"], pixdim=(1.5, 1.5, 2.0), mode="bilinear"),
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"),
]
)
—
Reply to this email directly, view it on GitHub
<#596 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY5AKVY7OXOHZBMI5CMD3TVCABFLANCNFSM5PXKHD5Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello @yiheng-wang-nv @wyli @rijobro @Nic-Ma, because my label is very small, when I use the CropForegroundd function to crop the image with the label as the source_key, the shapes of y and y_pred are inconsistent. How should I solve this problem?
The error that occurs is as follows:
|
Beta Was this translation helpful? Give feedback.
Hi @HripsimeS , sorry for late reply. I checked your code, Where you used
Spacingd(keys=["image", "mask"], pixdim=(1.0, 1.0, 1.0), mode=("bilinear", "nearest"))
:Can you please change it i…