A unified library for performing adversarial attacks on ML model to test their defense.
Project description
Adversarial Lab
Adversarial Lab is a unified Python library for launching adversarial attacks on any machine learning model. It is framework-agnostic, supporting both TensorFlow and PyTorch.
Key Features • Installation • Quick Start • Usage • Customization • Contributing • License
Key Features
- Framework Agnostic: Works seamlessly with both TensorFlow and PyTorch.
- Wide Range of Attacks: Includes both black-box and white-box attack implementations.
- Customizable Loss Functions and Optimizers: Easily extendable to custom loss functions and optimization techniques.
- Noise Generators: Supports various noise generation methods to craft adversarial examples.
- Defenses: Built-in methods to evaluate and defend against adversarial attacks.
Installation
To install Adversarial Lab, you can use pip. The pip installation does not install tensorflow and pytorch. Both these libraries must be installed for Adversarial Lab to work.
pip install adversarial-lab
Quick Start
Here's a basic example to get you started with a white-box attack on a PyTorch model:
from PIL import Image
import tensorflow as tf
from tensorflow.keras.applications import InceptionV3
from adversarial_lab.attacks.whitebox import WhiteBoxMisclassification
image = Image.open('data/panda.jpg')
model = InceptionV3(weights='imagenet')
attacker = WhiteBoxMisclassification(model, "cce", "adam")
noise = attacker.attack(image_array, epochs=20, strategy="random", verbose=3)
Usage
Attacks
Adversarial Lab supports a variety of adversarial attack techniques. Here's a brief overview:
- Black-Box Attacks: Located in
adversarial_lab/attacks/blackbox - White-Box Attacks: Located in
adversarial_lab/attacks/whitebox
Defenses
COMING SOON
Customization
Adversarial Lab is designed to be extensible. You can add your custom components in the following areas:
- Loss Functions: Create your own loss functions in
adversarial_lab/core/losses. - Optimizers: Extend or modify optimizers in
adversarial_lab/core/optimizers. - Noise Generators: Implement new noise generators under
adversarial_lab/core/noise_generators.
Contributing
We welcome contributions to Adversarial Lab! If you'd like to contribute, please follow these steps:
For detailed guidelines, see the CONTRIBUTING.md file.
License
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
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 adversarial_lab-0.0.3.tar.gz.
File metadata
- Download URL: adversarial_lab-0.0.3.tar.gz
- Upload date:
- Size: 59.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33367577003351d745228d5ae6ef2f43e12498f79938d87e4188ee5edaa8008d
|
|
| MD5 |
0681b34a8065867606b7b44a667a0015
|
|
| BLAKE2b-256 |
9dc70eb49ca37da127b152041ff52bbbe0faf46ed833dc8a5b1032f704cdd5ff
|
File details
Details for the file adversarial_lab-0.0.3-py3-none-any.whl.
File metadata
- Download URL: adversarial_lab-0.0.3-py3-none-any.whl
- Upload date:
- Size: 97.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c70fbabcadf6286c765bd63b9c593432b82ba3e0ebbd1d3239ddab05b9290b
|
|
| MD5 |
331bcf36bb4294dabdeb32788fd61e8c
|
|
| BLAKE2b-256 |
1a43aff2eb7ec4bfff13a261e9585f550b615f5a4b50e00931cd0ae0548e2d9f
|