torchadv


Nametorchadv JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/hupe1980/torchadv
SummaryTiny package designed to support red teams and penetration testers in creating and analyzing adversarial attacks on PyTorch models.
upload_time2024-06-23 22:26:08
maintainerNone
docs_urlNone
authorhupe1980
requires_python<4.0,>=3.12
licenseMIT
keywords security ai pentest red-team responsible-ai red-team-tools ai-red-team adversarial-attacks pytorch deep-learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🔥🛡️⚔️ 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:

```bash
pip install torchadv
```

## Usage

Here is a simple example of how to use TorchAdv to perform an FGSM attack on a PyTorch model:

```python
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](LICENSE) file for details.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hupe1980/torchadv",
    "name": "torchadv",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": "security, ai, pentest, red-team, responsible-ai, red-team-tools, ai-red-team, adversarial-attacks, pytorch, deep-learning",
    "author": "hupe1980",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ab/6b/26195eec8e538ea36c789b016f7b2ebf50ad7bae10e96174265ec90b8329/torchadv-0.0.3.tar.gz",
    "platform": null,
    "description": "# \ud83d\udd25\ud83d\udee1\ufe0f\u2694\ufe0f TorchAdv\n\nTorchAdv 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.\n\n## Features\n\n- **Adversarial Attacks**: Implementations of popular adversarial attacks such as FGSM, PGD, and more.\n- **Compatibility**: Designed to work seamlessly with PyTorch models.\n- **Customizable**: Easily extendable to include new attack methods or custom functionality.\n\n## Installation\n\nInstall the package via pip:\n\n```bash\npip install torchadv\n```\n\n## Usage\n\nHere is a simple example of how to use TorchAdv to perform an FGSM attack on a PyTorch model:\n\n```python\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torchvision import models, transforms\nfrom PIL import Image\n\nfrom torchadv.attacks import PGD\n\n# Load a pre-trained model\nmodel = models.resnet18(pretrained=True)\nmodel.eval()\n\n# Load an image and preprocess it\ntransform = transforms.Compose([\n    transforms.Resize((224, 224)),\n    transforms.ToTensor(),\n])\nimage = Image.open('path_to_image.jpg')\norig = transform(image).unsqueeze(0)\n\n# Define the target label\ntarget_label = torch.tensor([your_target_label])\n\n# Perform the attack\nattack = PGD(model)\nadv = attack(orig, target_label)\n```\n\n## Contributing\n\nContributions 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.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tiny package designed to support red teams and penetration testers in creating and analyzing adversarial attacks on PyTorch models.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/hupe1980/torchadv",
        "Repository": "https://github.com/hupe1980/torchadv"
    },
    "split_keywords": [
        "security",
        " ai",
        " pentest",
        " red-team",
        " responsible-ai",
        " red-team-tools",
        " ai-red-team",
        " adversarial-attacks",
        " pytorch",
        " deep-learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "966486f2aa50247c79d33392ed5545fb7ef2154dd87e7d2e376b3069cf077685",
                "md5": "e206bfeb8a93fe9802460b1723c4cab1",
                "sha256": "66608a2de171b04c552e1da901a3da6d54b332d0d2ae3bdb24e5d7370f381cf5"
            },
            "downloads": -1,
            "filename": "torchadv-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e206bfeb8a93fe9802460b1723c4cab1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 9634,
            "upload_time": "2024-06-23T22:26:06",
            "upload_time_iso_8601": "2024-06-23T22:26:06.544873Z",
            "url": "https://files.pythonhosted.org/packages/96/64/86f2aa50247c79d33392ed5545fb7ef2154dd87e7d2e376b3069cf077685/torchadv-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab6b26195eec8e538ea36c789b016f7b2ebf50ad7bae10e96174265ec90b8329",
                "md5": "bd94dbba7eb0c69a96c841c062772acb",
                "sha256": "d76547731d98eda30f53429bfba9a0a8dd73f45f9abd4afd56e013c940d3acb3"
            },
            "downloads": -1,
            "filename": "torchadv-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "bd94dbba7eb0c69a96c841c062772acb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 7499,
            "upload_time": "2024-06-23T22:26:08",
            "upload_time_iso_8601": "2024-06-23T22:26:08.181541Z",
            "url": "https://files.pythonhosted.org/packages/ab/6b/26195eec8e538ea36c789b016f7b2ebf50ad7bae10e96174265ec90b8329/torchadv-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-23 22:26:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hupe1980",
    "github_project": "torchadv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "torchadv"
}
        
Elapsed time: 5.03188s