crack_segmentation icon indicating copy to clipboard operation
crack_segmentation copied to clipboard

where is the joint_transforms

Open zuiyichangdi opened this issue 4 years ago • 3 comments

When I was reading train_tiramisu.py, I found that the code need to import JointRandomSizedCrop from joint_transforms. However, I did not find the joint_transforms. Whether it is a package, or you deleted it?

zuiyichangdi avatar Jul 21 '20 06:07 zuiyichangdi

train_tiramisu.py no module 'joint_transforms', how to do? thank u! @zuiyichangdi

li0128 avatar Jul 06 '22 02:07 li0128

train_tiramisu.py no module 'joint_transforms', how to do? thank u! @zuiyichangdi

Oh, sorry, I didn't find a solution. And it's been two years, I almost forgot about the project. I regret not being able to advise you.

zuiyichangdi avatar Jul 06 '22 06:07 zuiyichangdi

I think this function should be useful.

def joint_transform(img, mask):
  img = transforms.ToTensor()(img)
  mask = transforms.ToTensor()(mask)
  both_images = torch.cat((img, mask), 0)
  
  # Apply the transformations to both images simultaneously:
  transformed_images = transforms.RandomResizedCrop(224, antialias=True)(both_images)
  
  # Get the transformed images:
  img = transforms.ToPILImage()(transformed_images[0:3])
  mask = transforms.ToPILImage()(transformed_images[3:6])
  return img, mask

cleverk1ng avatar Nov 30 '23 16:11 cleverk1ng