Skip to content

Instantly share code, notes, and snippets.

@Paulescu
Created March 14, 2022 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paulescu/c0eadc09283805c93e97f2c773912311 to your computer and use it in GitHub Desktop.
Save Paulescu/c0eadc09283805c93e97f2c773912311 to your computer and use it in GitHub Desktop.
# function 1
# load image from the given url
response = requests.get(url)
img = Image.open(io.BytesIO(response.content))
# function 2
# load model. This is a time-consuming operation
model = load_model()
# function 3
# returns a pair (x_adv, grad) after each FGSM step.
iterator = iterative_fast_gradient_sign_(
model,
preprocess(img),
epsilon,
n_steps=n_steps,
alpha=alpha
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment