Esempio n. 1
0
                      help='The number of classes for your data.')
  parser.add_argument('-img-width', dest='img_width', required=True, type=int,
                      help='The width your images will be resized to.')
  parser.add_argument('-img-height', dest='img_height', required=True, type=int,
                      help='The height your images will be resized to.')
  parser.add_argument('-img-channels', dest='img_channels', required=True,
                      type=int,
                      help=('The number of image channels ' +
                            '(1 = grayscale, 3 = RGB).'))
  parser.add_argument('-classnames-file', dest='classnames_file', required=True,
                      help='The location of the file containing classnames.')
  parser.add_argument('-train-file', dest='train_file', required=True,
                      help='The location of the file training data information.')
  parser.add_argument('-test-file', dest='test_file', required=True,
                      help='The location of the file test data information.')
  args = parser.parse_args()
  img_info = ImageInfo(num_classes=args.num_classes)
  img_info.set_image_dimensions(
      (args.img_width, args.img_height, args.img_channels))
  img_info.load_image_classnames(args.classnames_file)
  img_info.load_train_image_paths(args.train_file)
  img_info.load_test_image_paths(args.test_file)
  img_loader = ImageLoader(img_info)
  img_loader.load_all_images()
  # Subtract the mean from all images.
  img_loader.subtract_image_means()
  # Save with pickle.
  print 'Making a delicious pickle...'
  pickle.dump(img_loader, open(args.pickle_file, 'wb'))
  print 'Data saved to pickle file "{}".'.format(args.pickle_file)