| 15 | |
| 16 | |
| 17 | def main(argv): |
| 18 | pycaffe_dir = os.path.dirname(__file__) |
| 19 | |
| 20 | parser = argparse.ArgumentParser() |
| 21 | # Required arguments: input and output files. |
| 22 | parser.add_argument( |
| 23 | "input_file", |
| 24 | help="Input image, directory, or npy." |
| 25 | ) |
| 26 | parser.add_argument( |
| 27 | "output_file", |
| 28 | help="Output npy filename." |
| 29 | ) |
| 30 | # Optional arguments. |
| 31 | parser.add_argument( |
| 32 | "--model_def", |
| 33 | default=os.path.join(pycaffe_dir, |
| 34 | "../models/bvlc_reference_caffenet/deploy.prototxt"), |
| 35 | help="Model definition file." |
| 36 | ) |
| 37 | parser.add_argument( |
| 38 | "--pretrained_model", |
| 39 | default=os.path.join(pycaffe_dir, |
| 40 | "../models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel"), |
| 41 | help="Trained model weights file." |
| 42 | ) |
| 43 | parser.add_argument( |
| 44 | "--gpu", |
| 45 | action='store_true', |
| 46 | help="Switch for gpu computation." |
| 47 | ) |
| 48 | parser.add_argument( |
| 49 | "--center_only", |
| 50 | action='store_true', |
| 51 | help="Switch for prediction from center crop alone instead of " + |
| 52 | "averaging predictions across crops (default)." |
| 53 | ) |
| 54 | parser.add_argument( |
| 55 | "--images_dim", |
| 56 | default='256,256', |
| 57 | help="Canonical 'height,width' dimensions of input images." |
| 58 | ) |
| 59 | parser.add_argument( |
| 60 | "--mean_file", |
| 61 | default=os.path.join(pycaffe_dir, |
| 62 | 'caffe/imagenet/ilsvrc_2012_mean.npy'), |
| 63 | help="Data set image mean of [Channels x Height x Width] dimensions " + |
| 64 | "(numpy array). Set to '' for no mean subtraction." |
| 65 | ) |
| 66 | parser.add_argument( |
| 67 | "--input_scale", |
| 68 | type=float, |
| 69 | help="Multiply input features by this scale to finish preprocessing." |
| 70 | ) |
| 71 | parser.add_argument( |
| 72 | "--raw_scale", |
| 73 | type=float, |
| 74 | default=255.0, |