| 16 | |
| 17 | |
| 18 | def config() -> argparse.Namespace: |
| 19 | parser = argparse.ArgumentParser(description="Run adversarial attack for captions") |
| 20 | |
| 21 | parser.add_argument( |
| 22 | "--data_from_hub", |
| 23 | action="store_true", |
| 24 | help="Whether to load the dataset from the hub", |
| 25 | ) |
| 26 | parser.add_argument( |
| 27 | "--model", |
| 28 | type=str, |
| 29 | default="gpt-4-vision-preview", |
| 30 | help="Model to use for evaluation", |
| 31 | ) |
| 32 | |
| 33 | parser.add_argument( |
| 34 | "--attack", |
| 35 | type=str, |
| 36 | default="clip_attack", |
| 37 | choices=["clip_attack"], |
| 38 | help="Adversarial attack method", |
| 39 | ) |
| 40 | parser.add_argument( |
| 41 | "--captioning_model", |
| 42 | type=str, |
| 43 | default="liuhaotian/llava-v1.5-7b", |
| 44 | choices=["liuhaotian/llava-v1.5-7b", "Salesforce/instructblip-vicuna-7b"], |
| 45 | help="Captioning backbone.", |
| 46 | ) |
| 47 | parser.add_argument( |
| 48 | "--index", |
| 49 | type=int, |
| 50 | required=False, |
| 51 | default=None, |
| 52 | help="Index of the example to attack", |
| 53 | ) |
| 54 | parser.add_argument( |
| 55 | "--batch_size", |
| 56 | type=int, |
| 57 | default=15, |
| 58 | help="Batch size for the attack", |
| 59 | ) |
| 60 | |
| 61 | # logging related |
| 62 | parser.add_argument("--result_dir", type=str, default="") |
| 63 | args = parser.parse_args() |
| 64 | |
| 65 | return args |
| 66 | |
| 67 | |
| 68 | TEMPLATE = """ |