Robustness library for binary image classification tasks
Project description
Robust-AI
Robust-ai is a library of training methods designed to improve the robustness of computer vision models. Warning : This library requires to have a GPU, CPU-only mode is not supported.
Getting started
To install and use the library, it is recommended to create a Python virtual environment. You can do that with virtualenv, as follows:
Setting environement
pip install virtualenv
virtualenv -p <path/to/python3.10> myenv
source myenv/bin/activate
Installation
Once your virtual environment is activated, you can install the uqmodels library directly from Pypi by typing :
pip install robust-ai
This command will install the robust-ai package and all required dependencies.
Input/Output
Input
Advertrain takes a torch dataloader as input.
Ouput
As output, the library returns a model saved as a local .pth file.
Usage pattern
You have to generate a dataloader in pytorch.
trainer = AdversarialTraining(model=your_architecture, optimizer=your_optimizer, loss_func=your_criterion, device=your_device, epsilon=your_epsilon)
trainer.fit(epochs=2, train_dataloader=your_train_dataloader, val_dataloader=your_val_dataloader, patience=2, checkpoint=your_path)
For more informations, you can follow the notebook example here : Notebook
How to run the provided example
-
Download the example dataset here and unzip it in the
examples/folder. Once done, you should have subfolder named/examples/dataset/c00 -
Launch the jupyter notebook
examples/training.ipynb
Architectures
The library provides six neural network architectures. More specifically, two main architectures are implemented, as well as two derived architectures for each of them :
- ConvNet
- ConvNet with DropBlock regularization
- ResNet
- ResNet with DropBlock regularization
ConvNet
A Convolutional Neural Network (ConvNet or CNN) is a type of deep learning algorithm primarily used for processing data with a grid-like topology, such as images, using convolutional layers to automatically and adaptively learn spatial hierarchies of features.
ResNet
ResNet, short for Residual Network, is a type of convolutional neural network (CNN) that introduces residual connections or "shortcuts" to jump over some layers, helping to solve the vanishing gradient problem and enabling the training of much deeper networks.
Dropout
Dropout is a regularization technique for reducing overfitting in neural networks by preventing complex co-adaptations on training data.
DropBlock
"DropBlock is a structured form of dropout directed at regularizing convolutional networks. In DropBlock, units in a contiguous region of a feature map are dropped together. As DropBlock discards features in a correlated area, the networks must look elsewhere for evidence to fit the data."
Training methods
Acutally two training methods are available. They take the form of three classes :
- ClassicalTraining
- AdversarialTraining
- AutoAttackTraining
- FireTraining
- TradesTraining
ClassicalTraining
This is the class to train a model without considering improved robustness.
All other training methods inherit from this class.
AdversarialTraining
This is the class to train model against adversarial attack. This method is based on an external : cleverhans
AutoAttackTraining
"Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks" Francesco Croce, Matthias Hein ICML 2020 AutoAttack
FireTraining
"Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks" Francesco Croce, Matthias Hein ICML 2020 Fire
TradesTraining
TRADES minimizes a regularized surrogate loss L(.,.) (e.g., the cross-entropy loss) for adversarial training Trades
Contributors and Support
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
File details
Details for the file robust_ai-0.1.1.tar.gz.
File metadata
- Download URL: robust_ai-0.1.1.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95520f3d0fe1fca3c600241dfaecfb3feffb504b80bd7364341e952db8cf5d0a
|
|
| MD5 |
6dba8ad608cf015fa400ac883ebf61f6
|
|
| BLAKE2b-256 |
e2ce60ee8993d6970288f30b13172c49fa38230e6a999a5068ea7e6ac1047d2f
|
Provenance
The following attestation bundles were made for robust_ai-0.1.1.tar.gz:
Publisher:
python_lib_publish.yml on IRT-SystemX/robust-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robust_ai-0.1.1.tar.gz -
Subject digest:
95520f3d0fe1fca3c600241dfaecfb3feffb504b80bd7364341e952db8cf5d0a - Sigstore transparency entry: 550823257
- Sigstore integration time:
-
Permalink:
IRT-SystemX/robust-ai@e2cf85d689ac5ddbd17f10af58f89ddd33b0a9a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IRT-SystemX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python_lib_publish.yml@e2cf85d689ac5ddbd17f10af58f89ddd33b0a9a0 -
Trigger Event:
workflow_dispatch
-
Statement type: