replace opencv blur to pil blur

This commit is contained in:
xieenze 2020-09-27 14:47:53 +08:00
parent 06220225ce
commit 98151b985a

View File

@ -1,7 +1,8 @@
import cv2 import cv2
import inspect import inspect
import numpy as np import numpy as np
from PIL import Image from PIL import Image, ImageFilter
import torch import torch
from torchvision import transforms as _transforms from torchvision import transforms as _transforms
@ -87,9 +88,8 @@ class GaussianBlur(object):
def __call__(self, img): def __call__(self, img):
sigma = np.random.uniform(self.sigma_min, self.sigma_max) sigma = np.random.uniform(self.sigma_min, self.sigma_max)
img = cv2.GaussianBlur( img = img.filter(ImageFilter.GaussianBlur(radius=sigma))
np.array(img), (self.kernel_size, self.kernel_size), sigma) return img
return Image.fromarray(img.astype(np.uint8))
def __repr__(self): def __repr__(self):
repr_str = self.__class__.__name__ repr_str = self.__class__.__name__