Image Recognition Bypass for Machine Learning
Last modified: 2023-08-18
We can trick image recognizer or classifier by adding filters or obfuscating an image.
The following techniques include those that are ineffective currently or in the future..
Blurring
from PIL import Image
from PIL import ImageFilter
img = Image.open("example.png")
# Box blur
img1 = img.filter(ImageFilter.BoxBlur(5))
# Gaussian blur
img2 = img.filter(ImageFilter.GaussianBlur(5))
# Median filter
img3 = img.filter(ImageFilter.MedianFilter(size=5))
# Rank filter
img4 = img.filter(ImageFilter.RankFilter(size=13, rank=5))
Cropping/Rotating
from PIL import Image
from PIL import ImageFilter
img = Image.open("example.png")
img = img.resize((512, 512))
img1 = img.crop((0, 0, 300, 280)).rotate(-60)