flowers.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import numpy as np
  2. from os.path import join
  3. from nabirds.utils import _MetaInfo
  4. from .base import BaseAnnotations, BBoxMixin
  5. class FLOWERS_Annotations(BaseAnnotations, BBoxMixin):
  6. name="FLOWERS"
  7. @property
  8. def meta(self):
  9. info = _MetaInfo(
  10. images_folder="images",
  11. images_file="images.txt",
  12. labels_file="labels.txt",
  13. split_file="tr_ID.txt",
  14. bounding_boxes="bounding_boxes.txt",
  15. bounding_box_dtype=np.dtype([(v, np.int32) for v in "xywh"]),
  16. # parts_file=join("parts", "part_locs.txt"),
  17. # part_names_file=join("parts", "parts.txt"),
  18. )
  19. info.structure = [
  20. [info.images_file, "_images"],
  21. [info.labels_file, "labels"],
  22. [info.split_file, "_split"],
  23. [info.bounding_boxes, "_bounding_boxes"],
  24. # [info.parts_file, "_part_locs"],
  25. # [info.part_names_file, "_part_names"],
  26. ]
  27. return info
  28. def _load_parts(self):
  29. self.part_names = {}
  30. # load only if present
  31. if self.has_parts:
  32. super(CARS_Annotations, self)._load_parts(idx_offset=1)
  33. self._load_bounding_boxes()
  34. def parts(self, *args, **kwargs):
  35. if self.has_parts:
  36. return super(CARS_Annotations, self).parts(*args, **kwargs)
  37. return None