| 28 | |
| 29 | |
| 30 | def parse_args(): |
| 31 | parser = argparse.ArgumentParser() |
| 32 | parser.add_argument( |
| 33 | 'candidates_json', |
| 34 | type=str, |
| 35 | help='Candidates json mapping from image_id --> candidate.') |
| 36 | |
| 37 | parser.add_argument( |
| 38 | 'image_dir', |
| 39 | type=str, |
| 40 | help='Directory of images, with the filenames as image ids.') |
| 41 | |
| 42 | parser.add_argument( |
| 43 | '--references_json', |
| 44 | default=None, |
| 45 | help='Optional references json mapping from image_id --> [list of references]') |
| 46 | |
| 47 | parser.add_argument( |
| 48 | '--compute_other_ref_metrics', |
| 49 | default=1, |
| 50 | type=int, |
| 51 | help='If references is specified, should we compute standard reference-based metrics?') |
| 52 | |
| 53 | parser.add_argument( |
| 54 | '--save_per_instance', |
| 55 | default=None, |
| 56 | help='if set, we will save per instance clipscores to this file') |
| 57 | |
| 58 | args = parser.parse_args() |
| 59 | |
| 60 | if isinstance(args.save_per_instance, str) and not args.save_per_instance.endswith('.json'): |
| 61 | print('if you\'re saving per-instance, please make sure the filepath ends in json.') |
| 62 | quit() |
| 63 | return args |
| 64 | |
| 65 | |
| 66 | class CLIPCapDataset(torch.utils.data.Dataset): |