A PyTorch package for adversarial attacks (FGSM, PGD, CW, MIFGSM, AutoAttack) with visualization.
Project description
📦 Installation
Install the package via pip:
pip install adversarialpytorchattack
## 📦 Or installation using Github
Or install from source
```sh
git clone https://github.com/santhoshatwork17@gmail.com/adversarialpytorchattackers.git
cd adversarial_pytorch_attack
## 🛠️ Usage
```python
import torch
import torchvision.models as models
from adversarialpytorchattack.attacks import FGSM, PGD, CW
from adversarialpytorchattack.utils import visualize_perturbation, save_image
# pre-trained model
model = models.resnet18(pretrained=True).eval()
# input image
image = torch.rand((1, 3, 224, 224)) # Example input
label = torch.tensor([0]) # Example label
# Apply attack
fgsm_attack = FGSM(model, epsilon=0.03)
adv_image = fgsm_attack(image, label)
# Save the adversarial image
save_image(adv_image, "adv_fgsm.jpg")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adversarialtorchattacks-1.0.0.tar.gz.
File metadata
- Download URL: adversarialtorchattacks-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d374b7bbd791db1de5ab4ca6af7c11a61087725c0fca817cd55f053072da6f61
|
|
| MD5 |
1939f8274f0e2ec8d3ed256e6e852423
|
|
| BLAKE2b-256 |
b14912aaa8b8f456490497a0a8d8b5bc980c0ab90c9ce1e2bcb6988306f3965b
|
File details
Details for the file adversarialtorchattacks-1.0.0-py3-none-any.whl.
File metadata
- Download URL: adversarialtorchattacks-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fda17b8d1dc052fe212802a297beca883cb43c1b7cf2ccaea5a29f3edb1f72e8
|
|
| MD5 |
cc9c34c85ddba6a8d6b79c57e2d16eb2
|
|
| BLAKE2b-256 |
2b2dbc48ffe573e04cc010da174709d029a849002fe8a950589eea1b91a21123
|