Spaces:
No application file
No application file
Download vlm_eval/attacks/attack.py from KC123hello/RobustMMFM2: direct link, hf CLI and curl.
- Browser
- Download file 440 Bytes
-
https://huggingface.co/spaces/KC123hello/RobustMMFM2/resolve/main/vlm_eval/attacks/attack.py
- Command line
-
hf download hf://spaces/KC123hello/RobustMMFM2/vlm_eval/attacks/attack.py
-
curl -L -o attack.py https://huggingface.co/spaces/KC123hello/RobustMMFM2/resolve/main/vlm_eval/attacks/attack.py
440 Bytes
| import torch | |
| class Attack(object): | |
| ''' | |
| Root class for all adversarial attack classes. | |
| ''' | |
| def __init__(self, model, targeted=False, img_range=(0, 1)): | |
| self.model = model | |
| self.device = 'cuda:0' | |
| self.targeted = targeted | |
| self.img_range = img_range | |
| def __repr__(self): | |
| return str(self.__dict__) | |
| def to(self, device): | |
| self.model.to(device) | |
| self.device = device |