parser.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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=[
  12. "GT", "GT2", "NAC", "UNI", "L1_pred", "L1_full",
  13. "CARS_UNI"
  14. ]),
  15. Arg("--feature_model", "-fm",
  16. choices=["inception", "inception_tf", "resnet"]),
  17. Arg("--subset", "-sub",
  18. help="Possible subsets: train, test",
  19. choices=["train", "test"],
  20. default="train", type=str),
  21. Arg("--start", "-s",
  22. help="Image id to start with",
  23. type=int, default=0),
  24. Arg("--n_images", "-n",
  25. help="Number of images to display",
  26. type=int, default=10),
  27. Arg("--rnd",
  28. help="select random subset of present parts",
  29. action="store_true"),
  30. Arg("--crop_to_bb",
  31. help="Crop image to the bounding box",
  32. 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()