Observed since 20 Oct, 20:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A library for Attack & Defence on Video Task
ADVT (Attack Defence on Video Tasks) is an adversarial attack/defence toolbox open source library based on Pytorch. This repository mainly implements some adversarial attack & defence algorithms and provides some video processing apis.

The ADVT library has five functional features, which cover the whole process:
This module implements attack methods. All attack methods are from top computer conferences in recent 5 years:
This module implements defence methods.
ADVT provides some useful evaluation & visualization tools.
Evaluation Metric:
Visualization:
Before installation, make sure you install fellow requirements.
numpy==1.18.5
opencv-python==4.4.0.42
torch==1.7.0
urllib==1.26.4
You can install advt through pypi or build from source code.
1. from pypi
pip install advt
2. from source code
git clone https://github.com/WindFantasy98/ADVT.git
pip install -e .
# python3.7 torch1.7
import torch
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from torch.utils.data import DataLoader
from advt.model.cnn import CNN
from advt.attack import FGSM
PATH_PARAMETERS = 'tests/cnn_model.pth'
def main():
transform = transforms.Compose([transforms.ToTensor()])
t = transforms.Compose([transforms.ToPILImage()])
test_dataset = datasets.CIFAR10(root='/data', train=False, transform=transform, download=True)
test_loader = DataLoader(dataset=test_dataset, batch_size=1, shuffle=False)
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
net = CNN()
net.load_state_dict(torch.load(PATH_PARAMETERS))
net = net.to(device)
fgsm = FGSM(net, device)
attack_succ = 0
total_num = 0
for i, (img, lbl) in enumerate(test_loader):
img, lbl = img.to(device), lbl.to(device)
adv_img = fgsm.attack(img, lbl)
output = net(adv_img)
_, pred_indice = output.max(1)
total_num += len(lbl)
attack_succ += (pred_indice == lbl).sum().item()
if (i + 1) % 20 == 0:
print('batch {}:'.format((i + 1) // 20),
'total tested number: {}, correct number: {}'.format(total_num, attack_succ))
if __name__ == '__main__':
main()
# python3.7 torch1.7
import torch
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from torch.utils.data import DataLoader
from advt.model.cnn import CNN
from advt.attack import DeepFool
from advt.defence import Randomization
PATH_PARAMETERS = 'tests/cnn_model.pth'
def main():
# initialize dataset
transform = transforms.Compose([transforms.ToTensor()])
t = transforms.Compose([transforms.ToPILImage()])
test_dataset = datasets.CIFAR10(root='/data', train=False, transform=transform, download=True)
test_loader = DataLoader(dataset=test_dataset, batch_size=1, shuffle=False)
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# load victim model
net = CNN()
net.load_state_dict(torch.load(PATH_PARAMETERS))
net = net.to(device)
# initialize attack method
df = DeepFool(net, device)
# initialize defend method
rand_defend = Randomization(net, device)
# initialize indicator
attack_succ = 0
total_num = 0
# start attack
for i, (img, lbl) in enumerate(test_loader):
img, lbl = img.to(device), lbl.to(device)
adv_img = df.attack(img, lbl) # get adv sample
output = rand_defend.defend(adv_img) # get processed sample
_, pred_indice = output.max(1)
total_num += len(lbl)
attack_succ += (pred_indice == lbl).sum().item()
if (i + 1) % 20 == 0:
print('batch {}:'.format((i + 1) // 20),
'total tested number: {}, correct number: {}'.format(total_num, attack_succ))
if __name__ == '__main__':
main()
This repo is still under maintenance. For more information, please contact with me.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.3 | 15 Jun 2021 | 0 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 20:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:0396544309fe212db700cf754b771cffa6c2993e881ed5ebeefd5e2489f2c460