Adversarial Attacks on Images
How images can fool AI models
How images can fool AI models
An adversarial example is an input that has been subtly modified to fool an AI model. The changes are so small that humans cannot see them, but they completely change what the AI predicts.
Think of it as whispering a secret message that only the AI can "hear." You see a normal photo. The AI sees something completely different.
Take a photo of a panda that the AI correctly identifies with 99.3% confidence. Add a tiny amount of carefully computed noise โ invisible to your eyes. Now the AI is 99.7% confident it is a gibbon.
How Adversarial Examples Work
Fast Gradient Sign Methodis the most basic adversarial attack. It works by computing the gradient of the model's loss with respect to the input image, then nudging every pixel by a tiny amount in the direction that increases the loss the most.
One step. One direction. That is all it takes to fool a state-of-the-art neural network.
FGSM โ Fast Gradient Sign Method
Input image
Feed image to model
Compute loss
How wrong is the model?
Get gradient
Which direction to push pixels
Sign of gradient
Just the direction (+/-)
Add tiny step
Shift all pixels slightly
AI models rely on statistical patterns in pixel values that humans do not perceive. While we see shapes, edges, and objects, the model sees high-dimensional mathematical patterns. Small changes in the right direction can push the model's decision boundary dramatically.
The goal is just to make the model wrong. It does not matter what the model predicts, as long as it is not the correct answer. Easier to achieve.
The goal is to make the model predict a specific wrong answer. For example, making a stop sign be classified as a speed limit sign. Harder but more dangerous.
AI "sees" differently than humans. Tiny pixel changes that are completely invisible to us can totally fool AI models. This is not a bug in a specific model โ it is a fundamental property of how neural networks process information.
For hands-on practice, check out the AI Security course on GitHub.