Hi,
I am trying to implement a custom transform for blurring the image using opencv.
I defined the blur_ function as:
def blur_(img):
kernel = np.ones((5,5),np.float32)/25
img=np.array(img)
dst = cv2.filter2D(img,-1,kernel)
return PILImage.create(dst)
I created the custom transform by defining the blur_transform class:
class blur_transform(Transform):
def init(self, aug): self.aug = aug)
def encodes(self, img: PILImage):
aug_img = self.aug(img)
return aug_img
Instantiated the custom transform:
blr_tfm = blur_transform(blur_)
Defined the datablock as under:
dblock=DataBlock(blocks=(ImageBlock,CategoryBlock),
get_items=get_image_files,
get_y=label_func,
item_tfms=[Resize(224),blr_tfm],
batch_tfms=[aug_transforms()],
splitter=RandomSplitter(seed=42))
To convert to dataloaders, when I run the following:
dls=dblock.dataloaders(source/‘images’)
I get the following output: Could not do one pass in your dataloader, there is something wrong in it
Where I am wrong?