parser.py 1.8 KB

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