Skip to content

Commit

Permalink
Merge branch 'dev_1.17.0' into composite-adversarial-attack
Browse files Browse the repository at this point in the history
  • Loading branch information
twweeb authored Dec 16, 2023
2 parents c8f5816 + dec5ddf commit d8f2a10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
6 changes: 6 additions & 0 deletions art/estimators/classification/hugging_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ def _make_model_wrapper(self, model: "torch.nn.Module") -> "torch.nn.Module":

input_shape = self._input_shape
input_for_hook = torch.rand(input_shape)
# self.device may not match the device the raw model was passed into ART.
# Check if the model is on cuda, if so set the hook input accordingly
if next(model.parameters()).is_cuda:
cuda_idx = torch.cuda.current_device()
input_for_hook = input_for_hook.to(torch.device(f"cuda:{cuda_idx}"))

input_for_hook = torch.unsqueeze(input_for_hook, dim=0)

if self.processor is not None:
Expand Down
36 changes: 19 additions & 17 deletions notebooks/huggingface_notebook.ipynb

Large diffs are not rendered by default.

0 comments on commit d8f2a10

Please sign in to comment.