🔥🛡️⚔️ TorchAdv
TorchAdv is a Python package designed to facilitate the creation and execution of adversarial attacks on PyTorch models. This library aims to provide easy-to-use tools for generating adversarial examples, evaluating model robustness, and implementing state-of-the-art adversarial attack methods.
Features
- Adversarial Attacks: Implementations of popular adversarial attacks such as FGSM, PGD, and more.
- Compatibility: Designed to work seamlessly with PyTorch models.
- Customizable: Easily extendable to include new attack methods or custom functionality.
Installation
Install the package via pip:
pip install torchadv
Usage
Here is a simple example of how to use TorchAdv to perform an FGSM attack on a PyTorch model:
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision import models, transforms
from PIL import Image
from torchadv.attacks import PGD
# Load a pre-trained model
model = models.resnet18(pretrained=True)
model.eval()
# Load an image and preprocess it
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
])
image = Image.open('path_to_image.jpg')
orig = transform(image).unsqueeze(0)
# Define the target label
target_label = torch.tensor([your_target_label])
# Perform the attack
attack = PGD(model)
adv = attack(orig, target_label)
Contributing
Contributions are welcome! If you have any ideas for new features, improvements, or bug fixes, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for torchadv 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchadv-0.0.3.tar.gz | 7.5 kB | Without provenance | Details for torchadv-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torchadv-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for torchadv-0.0.3-py3-none-any.whl |
Total release size: 17.1 kB
Release files / torchadv-0.0.3.tar.gz
| Download URL | torchadv-0.0.3.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d76547731d98eda30f53429bfba9a0a8dd73f45f9abd4afd56e013c940d3acb3
|
|
BLAKE2b-256 checksum How to use checksums |
ab6b26195eec8e538ea36c789b016f7b2ebf50ad7bae10e96174265ec90b8329
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Darwin/22.6.0
|
Release files / torchadv-0.0.3-py3-none-any.whl
| Download URL | torchadv-0.0.3-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66608a2de171b04c552e1da901a3da6d54b332d0d2ae3bdb24e5d7370f381cf5
|
|
BLAKE2b-256 checksum How to use checksums |
966486f2aa50247c79d33392ed5545fb7ef2154dd87e7d2e376b3069cf077685
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Darwin/22.6.0
|
Security for torchadv 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.