Message Boards Message Boards

GROUPS:

ImageAugmentationLayer on image and target mask

Posted 15 days ago
165 Views
|
2 Replies
|
2 Total Likes
|

Hi, I'd like to use ImageAugmentationLayer in my binary image segmentation neural network. However, it seems like I can't get the ImageSegmentationLayer to do exactly the same transform on my input image as on my target mask. Is there a hidden way to do this that's not mentioned in the docs? It seems like every invocation of the layer will use a new random crop, but I need to do the exact same random crop on pairs of images. Cheers!

2 Replies
Posted 15 days ago

In the meantime I'm using this function to do it.

randomCrop[is_, sz_] := 
 Module[{x = RandomReal[{-1, 1}], y = RandomReal[{-1, 1}]},
  ImageCrop[#, sz, {x, y}] & /@ is
  ]

Hi Carl, unfortunately there is no way to link two ImageAugmentationLayers currently. NetMapOperator will also give you two different crops. You will have to perform the augmentation outside the Neural Net as a pre-processing step. You can either pre-compute you augmented dataset before traning, or you can have online augmentation during training (as ImageAugmentationLayer would give you) by using the "generator" syntax of NetTrain: NetTrain[net, f], as in the 5th signature of the NetTrain doc page:

https://reference.wolfram.com/language/ref/NetTrain.html

Inside the generator function you will have to take the current minibatch, apply your linked random cropping and return the cropped minibatch.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract