车位角点检测代码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

79 行
3.3KB

  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. # Thresholds to determine whether an detected point match ground truth.
  10. SQUARED_DISTANCE_THRESH = 0.000277778
  11. DIRECTION_ANGLE_THRESH = 0.5
  12. def add_common_arguments(parser):
  13. """Add common arguments for training and inference."""
  14. parser.add_argument('--detector_weights',
  15. help="The weights of pretrained detector.")
  16. parser.add_argument('--depth_factor', type=int, default=32,
  17. help="Depth factor.")
  18. parser.add_argument('--disable_cuda', action='store_true',
  19. help="Disable CUDA.")
  20. parser.add_argument('--gpu_id', type=int, default=0,
  21. help="Select which gpu to use.")
  22. def get_parser_for_training():
  23. """Return argument parser for training."""
  24. parser = argparse.ArgumentParser()
  25. parser.add_argument('--dataset_directory', required=True,
  26. help="The location of dataset.")
  27. parser.add_argument('--optimizer_weights',
  28. help="The weights of optimizer.")
  29. parser.add_argument('--batch_size', type=int, default=24,
  30. help="Batch size.")
  31. parser.add_argument('--data_loading_workers', type=int, default=48,
  32. help="Number of workers for data loading.")
  33. parser.add_argument('--num_epochs', type=int, default=100,
  34. help="Number of epochs to train for.")
  35. parser.add_argument('--lr', type=float, default=1e-4,
  36. help="The learning rate of back propagation.")
  37. parser.add_argument('--enable_visdom', action='store_true',
  38. help="Enable Visdom to visualize training progress")
  39. add_common_arguments(parser)
  40. return parser
  41. def get_parser_for_evaluation():
  42. """Return argument parser for testing."""
  43. parser = argparse.ArgumentParser()
  44. parser.add_argument('--dataset_directory', required=True,
  45. help="The location of dataset.")
  46. parser.add_argument('--batch_size', type=int, default=32,
  47. help="Batch size.")
  48. parser.add_argument('--data_loading_workers', type=int, default=64,
  49. help="Number of workers for data loading.")
  50. parser.add_argument('--enable_visdom', action='store_true',
  51. help="Enable Visdom to visualize training progress")
  52. add_common_arguments(parser)
  53. return parser
  54. def get_parser_for_inference():
  55. """Return argument parser for inference."""
  56. parser = argparse.ArgumentParser()
  57. parser.add_argument('--mode', required=True, choices=['image', 'video'],
  58. help="Inference image or video.")
  59. parser.add_argument('--video',
  60. help="Video path if you choose to inference video.")
  61. parser.add_argument('--thresh', type=float, default=0.5,
  62. help="Detection threshold.")
  63. parser.add_argument('--timing', action='store_true',
  64. help="Perform timing during reference.")
  65. parser.add_argument('--save', action='store_true',
  66. help="Save detection result to file.")
  67. add_common_arguments(parser)
  68. return parser