Lion Cipher Lab

Fool an image classifier with FGSM (adversarial examples)

Why it matters

Everyone has been told that AI 'sees' images. In this lab you will personally break that claim: you will take a photo a well-known model classifies correctly with high confidence, add a change so small that your own eyes cannot detect it, and watch the same model report a completely different object with equal confidence. This is not a bug in one model — it is a general property of the neural networks now sitting inside content moderation, malware classification, medical triage, fraud scoring and self-driving perception. Once you have made it happen with your own hands, two things become…

What you'll learn

Steps in this lab

  1. What you are about to do, in plain language
  2. The ethics line — read this before you run anything
  3. Open a terminal and install Python
  4. Make a project folder and a virtual environment
  5. Install PyTorch — the CPU build, no graphics card required
  6. Make the model name your photo
  7. Three words you need: logit, loss, gradient
  8. The FGSM formula — English first, then symbols
  9. Craft your first adversarial example
  10. Now look at the two pictures
  11. If it did not work: the four things that go wrong
  12. Sweep epsilon — see the trade-off with your own eyes
  13. Measure it: attack success rate across your whole folder
  14. Why does such a tiny change work at all?
  15. Defence 1: squeeze the input before the model ever sees it
  16. Defence 2, and the honest caveat that matters most
  17. Where this bites in the real world
  18. What you just did

Open the full interactive lab →