pji_run.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ##################################################################
  4. #
  5. # Copyright (c) 2023 CICV, Inc. All Rights Reserved
  6. #
  7. ##################################################################
  8. """
  9. @Authors: yangzihao(yangzihao@china-icv.cn)
  10. @Data: 2024/04/21
  11. @Last Modified: 2024/04/21
  12. @Summary: Evaluation entrance
  13. """
  14. import os
  15. import sys
  16. import time
  17. from single_case_eval import single_case_eval
  18. from common import get_subfolders_name
  19. from pjirebot_evaluate_csv import parsebag
  20. import log
  21. if __name__ == "__main__":
  22. from warnings import simplefilter
  23. # simplefilter(action="ignore", category=FutureWarning)
  24. simplefilter(action="ignore")
  25. if len(sys.argv) >= 3:
  26. dataPath = sys.argv[1]
  27. resultPath = sys.argv[2]
  28. trackPath = sys.argv[3]
  29. if len(sys.argv) > 4:
  30. case_name = sys.argv[4]
  31. else:
  32. case_name = dataPath.split('/')[-1] # .split('.')[0]
  33. # logFileName = f'{resultPath}/log.txt'
  34. logFileName = os.path.join(resultPath, 'log.txt')
  35. log.setup_logger(logFileName)
  36. logger = log.get_logger()
  37. if not os.path.exists(dataPath):
  38. print('Invalid dataPath!')
  39. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  40. sys.exit(-1)
  41. else:
  42. try:
  43. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  44. print("SINGLE_CASE_EVAL程序开始运行:")
  45. configPath = r"./config.json"
  46. print(
  47. f" configPath: {configPath},\n dataPath: {dataPath},\n resultPath: {resultPath},\n trackPath: {trackPath}")
  48. t1 = time.time()
  49. parsebag(dataPath, resultPath) # EgoState_pji.csv存放resultPath下
  50. single_case_eval(configPath, resultPath, resultPath, trackPath, case_name)
  51. t2 = time.time()
  52. print(f"程序结束,执行时间:{int(t2 - t1)} s")
  53. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  54. sys.exit(0)
  55. except Exception as e:
  56. print("异常,退出...")
  57. print(repr(e))
  58. sys.exit(-1)
  59. else:
  60. print('No enough arguments!')
  61. sys.exit(-1)
  62. # dataPath = './bag/2024-04-22-08-48-30_obstacledetection_30.bag'
  63. # resultPath = './result/integration'
  64. #
  65. # logFileName = f'{resultPath}/log.txt'
  66. # log.setup_logger(logFileName)
  67. # logger = log.get_logger()
  68. #
  69. # case_name = dataPath.split('/')[-1].split('.')[0]
  70. # # case_name = os.path.basename(os.path.dirname(dataPath))
  71. #
  72. # if not os.path.exists(dataPath):
  73. # print('Invalid dataPath!')
  74. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  75. # sys.exit(-1)
  76. # else:
  77. # try:
  78. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  79. # print("SINGLE_CASE_EVAL程序开始运行:")
  80. # configPath = r"./config.json"
  81. # print(f" configPath: {configPath},\n resultPath: {resultPath}")
  82. # t1 = time.time()
  83. # parsebag(dataPath, resultPath)
  84. # single_case_eval(configPath, resultPath, case_name)
  85. # t2 = time.time()
  86. # print(f"程序结束,执行时间:{int(t2 - t1)} s")
  87. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  88. # sys.exit(0)
  89. # except Exception as e:
  90. # print("异常,退出...")
  91. # print(repr(e))
  92. # sys.exit(-1)