How to create a custom Transform which would work during inference

Hello, this may help some. It is an area I have been recently playing in image segmentation for image transformations (augmentations). And you should be able to translate this idea to your code.

class SegmentationAlbumentationsTransform(ItemTransform):
#    split_idx=0
    def __init__(self, aug, **kwargs): 
        super().__init__(**kwargs)
        self.aug = aug
        
    def encodes(self, x: tuple):   
         #this code is called on in the learn.fit_one_cycle phase
    
    def encodes(self, img: TensorImage):
         #this code is called on in the learn.predict phase

The discussion for this was had here
Probably in your “class NNAudioTransform(Transform):” class.
So depends on the encodes input parameters as to which encodes is called. Therefore you will need to add another encodes function.

1 Like