parser.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. from cvargparse import BaseParser, Arg
  2. from cvdatasets.annotations import AnnotationType
  3. from cvdatasets.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("--only_class",
  24. help="display only the given class",
  25. type=int, default=-1),
  26. Arg("--rnd",
  27. help="select random subset of present parts",
  28. action="store_true"),
  29. Arg("--no_bboxes",
  30. help="Do not display bounding boxes",
  31. action="store_true"),
  32. Arg("--no_parts",
  33. help="Do not display parts",
  34. action="store_true"),
  35. Arg("--crop_to_bb",
  36. help="Crop image to the bounding box",
  37. action="store_true"),
  38. Arg("--no_center_crop", action="store_true"),
  39. Arg("--crop_uniform",
  40. help="Try to extend the bounding box to same height and width",
  41. action="store_true"),
  42. Arg("--parts_in_bb",
  43. help="Only display parts, that are inside the bounding box",
  44. action="store_true"),
  45. Arg("--features",
  46. help="pre-extracted train and test features",
  47. default=[None, None],
  48. nargs=2, type=str),
  49. Arg("--ratio",
  50. help="Part extraction ratio",
  51. type=float, default=.2),
  52. Arg("--rescale_size",
  53. help="rescales the part positions from this size to original image size",
  54. type=int, default=-1),
  55. Arg("--uniform_parts", "-u",
  56. help="Do not use GT parts, but sample parts uniformly from the image",
  57. action="store_true"),
  58. Arg('--seed', type=int, default=12311123,
  59. help='random seed'),
  60. ])
  61. parser.init_logger()
  62. return parser.parse_args()