airlab-unibas / airlab

Image registration laboratory for 2D and 3D image data
Apache License 2.0
408 stars 92 forks source link

LCC and SSIM loss function error #28

Open wpstephen opened 4 years ago

wpstephen commented 4 years ago

I am trying to do some Rigid Registration on binary images of size 64x64 and I was playing around with different loss functions. But while trying to use both LCC and SSIM loss functions, I got following error: RuntimeError: Subtraction, the - operator, with a bool tensor is not supported. If you are trying to invert a mask, use the ~ or logical_not() operator instead.

I am not quite sure what this error entails, could anyone assist me here?

RobinSandkuehler commented 4 years ago

Hi,

I think this is versioning issue with PyTorch. We work on it in order to support the newest PyTorch version.

wpstephen commented 4 years ago

Can this be solved by downgrading to a lower version of PyTorch? If so, what version would work? Thank you!

On 23 Apr 2020, at 20:29, RobinSandkuehler notifications@github.com<mailto:notifications@github.com> wrote:

Hi,

I think this is versioning issue with PyTorch. We work on it in order to support the newest PyTorch version.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fairlab-unibas%2Fairlab%2Fissues%2F28%23issuecomment-618573736&data=02%7C01%7C%7Cc552442f50154dd1825608d7e7b44ace%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232633840636634&sdata=NAPg%2F1nkzK3jGOehaKmHWHvG6rUsAS0GZKUWSaQ%2B46E%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGIE33JTKM5UGGWYNFBB2RTROCCJNANCNFSM4MPAR5DQ&data=02%7C01%7C%7Cc552442f50154dd1825608d7e7b44ace%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232633840646629&sdata=Q%2F4ZCGZjOy%2Be6Pb4n5LV2Xdalvb2n4lQ5g6YRuXy3Ls%3D&reserved=0.

RobinSandkuehler commented 4 years ago

Yes, Try Version 1.3 or below

wpstephen commented 4 years ago

Alright, I will try that. Thank you for your fast help. I will keep you up to date!

On 23 Apr 2020, at 20:32, RobinSandkuehler notifications@github.com<mailto:notifications@github.com> wrote:

Yes, Try Version 1.3 or below

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fairlab-unibas%2Fairlab%2Fissues%2F28%23issuecomment-618575794&data=02%7C01%7C%7C651a80f99c1f4812995008d7e7b4b5b0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232635633200858&sdata=Nrx8UiRk%2BM%2F3FE3g7anmAOr4CfxFruux37Czoa9jA2M%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGIE33IVMCDCDTBZD5VXUSLROCCUTANCNFSM4MPAR5DQ&data=02%7C01%7C%7C651a80f99c1f4812995008d7e7b4b5b0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232635633200858&sdata=PVopPrHoJbXP%2FOlRlrZpXXpH3PT0EWCxczRjjvB3pQY%3D&reserved=0.

wpstephen commented 4 years ago

@RobinSandkuehler I tried on torch verson 1.3 and 1.2 but both produced another error:

RuntimeError: expected device cpu and dtype Byte but got device cpu and dtype Bool

I tried figuring out why dtype is set to Bool, but I cannot seem to figure out why it is happening

jlevy44 commented 4 years ago

@sumanthratna

mysakbm commented 2 years ago

The issue is that the mask is a boolean tensor. In the code on line 267, there is "mask = 1-mask" which is not supported by torch. You need to convert the mask into array of ints: mask = 1 - mask.type(th.uint8)