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
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.
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
Run the command below from the project context.
python3 explore_space.py --img images/horse.pngUse the
eandrkeys 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.
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
Run the command below.
python3 iterative.py --img images/goldfish.jpg --model resnet18 --target 4Adjust
epsilonand the iteration count with the trackbars.Press
sto save the perturbation and adversarial image; pressspaceto pause orescto close.
Expected outcome
The example generates a targeted adversarial-image demonstration and can save the perturbation and resulting image.
Guide limitations
- Omitting
--targetselects an untargeted attack. - The README does not provide a general installation procedure.
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

