parser.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. from cvargparse import BaseParser, Arg
  2. from nabirds.annotations import AnnotationType
  3. from nabirds.utils import read_info_file
  4. DEFAULT_INFO_FILE="/home/korsch/Data/info.yml"
  5. info_file = read_info_file(DEFAULT_INFO_FILE)
  6. def parse_args():
  7. parser = BaseParser([
  8. Arg("data", default=DEFAULT_INFO_FILE),
  9. Arg("dataset", choices=info_file.DATASETS.keys()),
  10. Arg("parts", default="GLOBAL", choices=info_file.PARTS.keys()),
  11. Arg("--feature_model", "-fm",
  12. choices=["inception", "inception_tf", "resnet"]),
  13. Arg("--subset", "-sub",
  14. help="Possible subsets: train, test",
  15. choices=["train", "test"],
  16. default="train", type=str),
  17. Arg("--start", "-s",
  18. help="Image id to start with",
  19. type=int, default=0),
  20. Arg("--n_images", "-n",
  21. help="Number of images to display",
  22. type=int, default=10),
  23. Arg("--rnd",
  24. help="select random subset of present parts",
  25. action="store_true"),
  26. Arg("--no_bboxes",
  27. help="Do not display bounding boxes",
  28. action="store_true"),
  29. Arg("--crop_to_bb",
  30. help="Crop image to the bounding box",
  31. action="store_true"),
  32. Arg("--no_center_crop", action="store_true"),
  33. Arg("--crop_uniform",
  34. help="Try to extend the bounding box to same height and width",
  35. action="store_true"),
  36. Arg("--parts_in_bb",
  37. help="Only display parts, that are inside the bounding box",
  38. action="store_true"),
  39. Arg("--features",
  40. help="pre-extracted train and test features",
  41. default=[None, None],
  42. nargs=2, type=str),
  43. Arg("--ratio",
  44. help="Part extraction ratio",
  45. type=float, default=.2),
  46. Arg("--rescale_size",
  47. help="rescales the part positions from this size to original image size",
  48. type=int, default=-1),
  49. Arg("--uniform_parts", "-u",
  50. help="Do not use GT parts, but sample parts uniformly from the image",
  51. action="store_true"),
  52. Arg('--seed', type=int, default=12311123,
  53. help='random seed'),
  54. ])
  55. parser.init_logger()
  56. return parser.parse_args()