diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b2cf27f..0820896 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,4 +1,4 @@
-name: CI
+name: ci
on:
pull_request:
diff --git a/README.md b/README.md
index b8da355..4333242 100644
--- a/README.md
+++ b/README.md
@@ -22,13 +22,13 @@
Install from GitHub source -
```shell
-python -m pip install git+https://github.com/spencerwooo/torchattack
+python -m pip install git+https://github.com/spencerwooo/torchattack@v1.0.1
```
Install from Gitee mirror -
```shell
-python -m pip install git+https://gitee.com/spencerwoo/torchattack
+python -m pip install git+https://gitee.com/spencerwoo/torchattack@v1.0.1
```
## Usage
@@ -36,13 +36,24 @@ python -m pip install git+https://gitee.com/spencerwoo/torchattack
```python
import torch
-from torchattack import AttackModel, FGSM, MIFGSM
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
+```
+
+Load a pretrained model to attack from either torchvision or timm.
+
+```python
+from torchattack import AttackModel
-# Load a model
+# Load a model with `AttackModel`
model = AttackModel.from_pretrained(model_name='resnet50', device=device)
+# `AttackModel` automatically attach the model's `transform` and `normalize` functions
transform, normalize = model.transform, model.normalize
+```
+
+Initialize an attack by importing its attack class.
+
+```python
+from torchattack import FGSM, MIFGSM
# Initialize an attack
attack = FGSM(model, normalize, device)
@@ -51,7 +62,23 @@ attack = FGSM(model, normalize, device)
attack = MIFGSM(model, normalize, device, eps=0.03, steps=10, decay=1.0)
```
-Check out [`torchattack.eval.runner`](torchattack/eval/runner.py) for a quick example.
+Initialize an attack by its name with `create_attack()`.
+
+```python
+from torchattack import create_attack
+
+# Initialize FGSM attack with create_attack
+attack = create_attack('FGSM', model, normalize, device)
+
+# Initialize PGD attack with specific eps with create_attack
+attack = create_attack('PGD', model, normalize, device, eps=0.03)
+
+# Initialize MI-FGSM attack with extra args with create_attack
+attack_cfg = {'steps': 10, 'decay': 1.0}
+attack = create_attack('MIFGSM', model, normalize, device, eps=0.03, attack_cfg=attack_cfg)
+```
+
+Check out [`torchattack.eval.runner`](torchattack/eval/runner.py) for a full example.
## Attacks
diff --git a/torchattack/__init__.py b/torchattack/__init__.py
index a8571b9..ea94263 100644
--- a/torchattack/__init__.py
+++ b/torchattack/__init__.py
@@ -21,7 +21,7 @@
from torchattack.vmifgsm import VMIFGSM
from torchattack.vnifgsm import VNIFGSM
-__version__ = '1.0.0'
+__version__ = '1.0.1'
__all__ = [
# Helper function to create an attack by its name