Tutorial: Imagenet-c¶
1. Use individual imagenet_c
transformations¶
[9]:
import beacon_aug as BA
import skimage.io as io
import matplotlib.pyplot as plt
img = io.imread("../data/example.png")
aug = BA.Snow(library="imagenet_c")
img_auged = aug(image=img)["image"]
plt.imshow(img)
/Users/xiaoli/opt/beacon-aug/beacon_aug/external/imagenet_c/corruptions.py:306: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
snow_layer = cv2.imdecode(np.fromstring(snow_layer.make_blob(), np.uint8),
[9]:
<matplotlib.image.AxesImage at 0x7fa202fac510>
[13]:
import beacon_aug as BA
import skimage.io as io
import matplotlib.pyplot as plt
image = io.imread("../data/example.png")
fig, axs = plt.subplots(1,4)
for i in range(4):
auto_pipeline = BA.Snow(library="imagenet_c", severity=i+1)
image_auged = auto_pipeline(image=image)["image"]
axs[i].set_title("s="+str(i+1))
axs[i].imshow(image_auged)
axs[i].axis("off")
/Users/xiaoli/opt/beacon-aug/beacon_aug/external/imagenet_c/corruptions.py:306: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
snow_layer = cv2.imdecode(np.fromstring(snow_layer.make_blob(), np.uint8),
/Users/xiaoli/opt/beacon-aug/beacon_aug/external/imagenet_c/corruptions.py:306: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
snow_layer = cv2.imdecode(np.fromstring(snow_layer.make_blob(), np.uint8),
/Users/xiaoli/opt/beacon-aug/beacon_aug/external/imagenet_c/corruptions.py:306: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
snow_layer = cv2.imdecode(np.fromstring(snow_layer.make_blob(), np.uint8),
/Users/xiaoli/opt/beacon-aug/beacon_aug/external/imagenet_c/corruptions.py:306: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
snow_layer = cv2.imdecode(np.fromstring(snow_layer.make_blob(), np.uint8),
2. Run a sequence of imagenet_c
transformations¶
[11]:
import beacon_aug as BA
import skimage.io as io
import matplotlib.pyplot as plt›
import numpy as np
image = io.imread("../data/example.png")
fig, axs = plt.subplots(1,4)
for i in range(4):
auto_pipeline = BA.Collections(tag="imagenet_c", n =i+1, severity=[1,5])
image_auged = auto_pipeline(image=image)["image"]
axs[i].set_title("n="+str(i+1))
axs[i].imshow(image_auged)
axs[i].axis("off")
3. Run 2 layers of “benign” transformations¶
[15]:
import beacon_aug as BA
import skimage.io as io
import matplotlib.pyplot as plt
import numpy as np
image = io.imread("../data/example.png")
aug = BA.Benign(in_place=True, out_place=True )
image_auged = aug(image=image)["image"]
plt.imshow(image_auged)
/Users/xiaoli/miniconda3/envs/aug/lib/python3.7/site-packages/albumentations-1.0.3-py3.7.egg/albumentations/augmentations/transforms.py:915: FutureWarning: This class has been deprecated. Please use ImageCompression
FutureWarning,
[15]:
<matplotlib.image.AxesImage at 0x7f97e7352150>