Skip to main content

Python toolbox to create adversarial examples that fool neural networks

Project description

https://readthedocs.org/projects/foolbox/badge/?version=latest https://travis-ci.org/bethgelab/foolbox.svg?branch=master https://coveralls.io/repos/github/bethgelab/foolbox/badge.svg

Foolbox

Foolbox is a Python toolbox to create adversarial examples that fool neural networks. It requires Python 3, NumPy and SciPy.

Installation

pip install foolbox

Documentation

Documentation is available on readthedocs: http://foolbox.readthedocs.io/

Example

import foolbox
import keras
from keras.applications.resnet50 import ResNet50, preprocess_input

# instantiate model
keras.backend.set_learning_phase(0)
kmodel = ResNet50(weights='imagenet')
fmodel = foolbox.models.KerasModel(kmodel, bounds=(0, 255), preprocess_fn=preprocess_input)

# get source image and label
image, label = foolbox.utils.imagenet_example()

# apply attack on source image
attack  = foolbox.attacks.FGSM(fmodel)
adv_img = attack(image=image, label=label)

Interfaces for a range of other deeplearning packages such as TensorFlow, PyTorch and Lasagne are available, e.g.

model = foolbox.models.PyTorchModel(torchmodel)

Different adversarial criteria such as Top-k, specific target classes or target probability levels can be passed to the attack, e.g.

criterion = foolbox.criteria.TargetClass(22)
attack    = foolbox.attacks.FGSM(fmodel, criterion)

Development

Foolbox is a work in progress and any input is welcome.

Citation

If you find Foolbox useful for your scientific work, please consider citing it in resulting publications. We will soon publish a technical paper and will provide the citation here.

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foolbox-0.4.1.tar.gz (199.8 kB view details)

Uploaded Source

File details

Details for the file foolbox-0.4.1.tar.gz.

File metadata

  • Download URL: foolbox-0.4.1.tar.gz
  • Upload date:
  • Size: 199.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for foolbox-0.4.1.tar.gz
Algorithm Hash digest
SHA256 a894ed379098a662e4e58c2c5f954c8ad96b14c90a3cf5f7daccd1c1306bc769
MD5 59e465d90d67e9a799665a97906780a5
BLAKE2b-256 70a386064ab716a3609d47a5fe8d2877b0a92b79f3cefa1a146e12017b4d9e50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page