车位角点检测代码
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

config.py 4.2KB

hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
hace 6 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. """Configurate arguments."""
  2. import argparse
  3. INPUT_IMAGE_SIZE = 512
  4. # 0: confidence, 1: point_shape, 2: offset_x, 3: offset_y, 4: cos(direction),
  5. # 5: sin(direction)
  6. NUM_FEATURE_MAP_CHANNEL = 6
  7. # image_size / 2^5 = 512 / 32 = 16
  8. FEATURE_MAP_SIZE = 16
  9. # Threshold used to filter marking points too close to image boundary
  10. BOUNDARY_THRESH = 0.066666667
  11. # Thresholds to determine whether an detected point match ground truth.
  12. SQUARED_DISTANCE_THRESH = 0.000277778
  13. DIRECTION_ANGLE_THRESH = 0.5
  14. VSLOT_MIN_DISTANCE = 0.044771278151623496
  15. VSLOT_MAX_DISTANCE = 0.1099427457599304
  16. HSLOT_MIN_DISTANCE = 0.15057789144568634
  17. HSLOT_MAX_DISTANCE = 0.44449496544202816
  18. BRIDGE_ANGLE_DIFF = 0.25
  19. SEPARATOR_ANGLE_DIFF = 0.5
  20. SLOT_SUPPRESSION_DOT_PRODUCT_THRESH = 0.8
  21. def add_common_arguments(parser):
  22. """Add common arguments for training and inference."""
  23. parser.add_argument('--detector_weights',
  24. help="The weights of pretrained detector.")
  25. parser.add_argument('--depth_factor', type=int, default=32,
  26. help="Depth factor.")
  27. parser.add_argument('--disable_cuda', action='store_true',
  28. help="Disable CUDA.")
  29. parser.add_argument('--gpu_id', type=int, default=0,
  30. help="Select which gpu to use.")
  31. def get_parser_for_training():
  32. """Return argument parser for training."""
  33. parser = argparse.ArgumentParser()
  34. parser.add_argument('--dataset_directory', required=True,
  35. help="The location of dataset.")
  36. parser.add_argument('--optimizer_weights',
  37. help="The weights of optimizer.")
  38. parser.add_argument('--batch_size', type=int, default=24,
  39. help="Batch size.")
  40. parser.add_argument('--data_loading_workers', type=int, default=32,
  41. help="Number of workers for data loading.")
  42. parser.add_argument('--num_epochs', type=int, default=10,
  43. help="Number of epochs to train for.")
  44. parser.add_argument('--lr', type=float, default=1e-4,
  45. help="The learning rate of back propagation.")
  46. parser.add_argument('--enable_visdom', action='store_true',
  47. help="Enable Visdom to visualize training progress")
  48. add_common_arguments(parser)
  49. return parser
  50. def get_parser_for_evaluation():
  51. """Return argument parser for testing."""
  52. parser = argparse.ArgumentParser()
  53. parser.add_argument('--dataset_directory', required=True,
  54. help="The location of dataset.")
  55. parser.add_argument('--batch_size', type=int, default=32,
  56. help="Batch size.")
  57. parser.add_argument('--data_loading_workers', type=int, default=64,
  58. help="Number of workers for data loading.")
  59. parser.add_argument('--enable_visdom', action='store_true',
  60. help="Enable Visdom to visualize training progress")
  61. add_common_arguments(parser)
  62. return parser
  63. def get_parser_for_ps_evaluation():
  64. """Return argument parser for testing."""
  65. parser = argparse.ArgumentParser()
  66. parser.add_argument('--label_directory', required=True,
  67. help="The location of dataset.")
  68. parser.add_argument('--image_directory', required=True,
  69. help="The location of dataset.")
  70. parser.add_argument('--enable_visdom', action='store_true',
  71. help="Enable Visdom to visualize training progress")
  72. add_common_arguments(parser)
  73. return parser
  74. def get_parser_for_inference():
  75. """Return argument parser for inference."""
  76. parser = argparse.ArgumentParser()
  77. parser.add_argument('--mode', required=True, choices=['image', 'video'],
  78. help="Inference image or video.")
  79. parser.add_argument('--video',
  80. help="Video path if you choose to inference video.")
  81. parser.add_argument('--inference_slot', action='store_true',
  82. help="Perform slot inference.")
  83. parser.add_argument('--thresh', type=float, default=0.5,
  84. help="Detection threshold.")
  85. parser.add_argument('--save', action='store_true',
  86. help="Save detection result to file.")
  87. add_common_arguments(parser)
  88. return parser