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 robust-ai 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 four 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.
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.
The implementation for this part is based on this Paper and use a copy of this Code
Training methods
Acutally five training methods are available. They take the form of five 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
Metadata
Release files for robust-ai 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| robust_ai-0.1.2.tar.gz | 31.9 kB | Details |
Release files / robust_ai-0.1.2.tar.gz
| Download URL | robust_ai-0.1.2.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99bcedf48799cb9a807bf2a731fee0e7488d877b41c78789a5cc492b50146cb5
|
|
BLAKE2b-256 checksum How to use checksums |
3285bd9a0f71c4800b32a04d258fa883ed20bfccd398cc908d61b9f53326e6b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2025.
Transparency log