flowers_data.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright 2016 Google Inc. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ==============================================================================
  15. """Small library that points to the flowers data set.
  16. """
  17. from __future__ import absolute_import
  18. from __future__ import division
  19. from __future__ import print_function
  20. from inception.dataset import Dataset
  21. class FlowersData(Dataset):
  22. """Flowers data set."""
  23. def __init__(self, subset):
  24. super(FlowersData, self).__init__('Flowers', subset)
  25. def num_classes(self):
  26. """Returns the number of classes in the data set."""
  27. return 5
  28. def num_examples_per_epoch(self):
  29. """Returns the number of examples in the data subset."""
  30. if self.subset == 'train':
  31. return 3170
  32. if self.subset == 'validation':
  33. return 500
  34. def download_message(self):
  35. """Instruction to download and extract the tarball from Flowers website."""
  36. print('Failed to find any Flowers %s files'% self.subset)
  37. print('')
  38. print('If you have already downloaded and processed the data, then make '
  39. 'sure to set --data_dir to point to the directory containing the '
  40. 'location of the sharded TFRecords.\n')
  41. print('Please see README.md for instructions on how to build '
  42. 'the flowers dataset using download_and_preprocess_flowers.\n')