Image Adversaries 101 in Python





Deep learning has brought us tremendous achievements in many fields such as computer vision, natural language processing. In spite of the impeccable success, modern deep learning systems are still prone to adversaries. Let's talk in terms of computer vision. Consider an image of a hog (X1). A Deep learning-based image classifier is able to successfully X1 as a hog. Now consider another instance of the same image X2 which is a slightly perturbed version of X1. To the human eyes, it would still be a hog but for that same image classifier, it can be presented as a wombat. These perturbations are referred to as adversaries.

This talk is going to discuss adversaries with the following main sections:

  • Fundamental premise of adversaries (5 minutes)
  • Importance of dealing with adversaries (2 minutes)
  • Types of adversaries (10 minutes)
    • Natural
    • Synthetic
  • Adversarial training with neural_structured_learning and metrics (10 minutes)
    • Adversarial regularization loss with empirical risk minimization
    • Comparison between normal and adversarial training
    • Adversarial training as a way to combat overfitting
  • Conclusion and final thoughts (3 minutes)


The audience should be thorough with the fundamentals of machine learning and should have experience working with image classification models (preferably using custom loops).

Video URL:

Content URLs:

I have a GitHub repository with supporting code examples:

Speaker Info:

I am currently with PyImageSearch where I apply deep learning to solve real-world problems in computer vision and bring some of the solutions to edge devices. I am also responsible for providing Q&A support to PyImageSearch readers.

Previously at DataCamp, I developed projects (here and here), and practice pools (here) for DataCamp. Prior to DataCamp, I have worked at TCS Research and Innovation (TRDDC) on Data Privacy. There, I was a part of TCS’s critically acclaimed GDPR solution called Crystal Ball.

Off the work, I enjoy writing technical articles and talking at developer meetups and conferences. My subject of interest broadly lies in areas like Machine Learning Interpretability, Full-Stack Data Science.

Section: Data Science, Machine Learning and AI
Type: Talks
Target Audience: Intermediate
Last Updated: