OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Security & Safety

Adversarial Examples Pytorch

Adversarial Examples Pytorch is a Python/PyTorch research repository containing implementations of methods for generating adversarial examples, including FGSM, iterative attacks, One Pixel Attack and AdvGAN, with visualizations and parameter controls.

Independent OpenViST project profile, based on linked sources.

Adversarial Examples Pytorch — Interactive FGSM and iterative-attack demonstrations
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when you need code-based demonstrations of image adversarial-example methods and want to vary parameters or inspect saved perturbations.

Who it is for

  • Researchers studying adversarial examples and image-classifier behavior
  • Students and educators demonstrating attack methods
  • Developers inspecting research implementations of image perturbation techniques

Documented uses

  • Generate adversarial examples from image inputs using documented attack scripts
  • Adjust attack parameters and observe resulting perturbations and classifier predictions
  • Compare random perturbations with directed attacks such as FGSM
  • Explore targeted and untargeted iterative attacks
Before you choose

Requirements & limits

  • The repository lists Python 3, PyTorch built from source, OpenCV, NumPy, SciPy and TensorBoard as dependencies.
  • The README documents both a custom MNIST model example and pretrained ImageNet model choices for FGSM.
  • The iterative example accepts an optional target class to select targeted rather than untargeted behavior.
  • The README provides script-level usage examples but not a general installation procedure.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Run the documented random-perturbation example

Explore random perturbations around an input image using the repository's example script.

Before you start

  • Python 3
  • PyTorch built from source
  • OpenCV, NumPy, SciPy and TensorBoard
  • An image file to pass as input

Steps

  1. Run the command below from the project context.

    Documented command
    python3 explore_space.py --img images/horse.png
  2. Use the e and r keys to generate new perturbations.

Expected outcome

The example displays an image with random perturbations constrained by `eps` and `rad`.

Guide limitations

  • The README does not provide a general installation procedure.
  • The documented command uses the repository's example image path.
Source-based practical guide

Adjust an iterative attack on an image

Use the documented Basic Iterative Method example with a selected model and target class.

Before you start

  • Python 3 and the repository's listed dependencies
  • An input image
  • A model choice, such as resnet18

Steps

  1. Run the command below.

    Documented command
    python3 iterative.py --img images/goldfish.jpg --model resnet18 --target 4
  2. Adjust epsilon and the iteration count with the trackbars.

  3. Press s to save the perturbation and adversarial image; press space to pause or esc to close.

Expected outcome

The example generates a targeted adversarial-image demonstration and can save the perturbation and resulting image.

Guide limitations

  • Omitting --target selects an untargeted attack.
  • The README does not provide a general installation procedure.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 November 2026
Original website title
sarathknv/adversarial-examples-pytorch · Official homepage title · retained in its source language