| 10 | |
| 11 | |
| 12 | def config() -> argparse.Namespace: |
| 13 | parser = argparse.ArgumentParser(description="Run adversarial attack for captions") |
| 14 | |
| 15 | parser.add_argument( |
| 16 | "--data_from_hub", |
| 17 | action="store_true", |
| 18 | help="Whether to load the dataset from the hub", |
| 19 | ) |
| 20 | |
| 21 | parser.add_argument( |
| 22 | "--attack", |
| 23 | type=str, |
| 24 | default="bim", |
| 25 | choices=["pgd", "bim"], |
| 26 | help="Adversarial attack method", |
| 27 | ) |
| 28 | parser.add_argument( |
| 29 | "--captioning_model", |
| 30 | type=str, |
| 31 | default="liuhaotian/llava-v1.5-7b", |
| 32 | choices=["liuhaotian/llava-v1.5-7b", "Salesforce/instructblip-vicuna-7b"], |
| 33 | help="Captioning backbone.", |
| 34 | ) |
| 35 | parser.add_argument( |
| 36 | "--index", |
| 37 | type=int, |
| 38 | required=False, |
| 39 | default=None, |
| 40 | help="Index of the example to attack", |
| 41 | ) |
| 42 | parser.add_argument( |
| 43 | "--batch_size", |
| 44 | type=int, |
| 45 | default=14, |
| 46 | help="Batch size for the attack", |
| 47 | ) |
| 48 | |
| 49 | # logging related |
| 50 | parser.add_argument("--result_dir", type=str, default="") |
| 51 | args = parser.parse_args() |
| 52 | |
| 53 | return args |
| 54 | |
| 55 | |
| 56 | @beartype |