single_run.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/03/27
  11. @Last Modified: 2024/03/27
  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. import log
  20. if __name__ == "__main__":
  21. # if len(sys.argv) >= 6:
  22. # configPath = sys.argv[1]
  23. # dataPath = sys.argv[2]
  24. # reportPath = sys.argv[3]
  25. # csvPath = sys.argv[4]
  26. # customMetricPath = sys.argv[5]
  27. # customScorePath = sys.argv[6]
  28. #
  29. # case_name = os.path.basename(os.path.dirname(dataPath))
  30. #
  31. # if not os.path.exists(configPath):
  32. # print('Invalid configPath!')
  33. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid configPath!")
  34. # sys.exit(-1)
  35. # elif not os.path.exists(dataPath):
  36. # print('Invalid dataPath!')
  37. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  38. # sys.exit(-1)
  39. # elif not os.path.exists(customMetricPath):
  40. # print('Invalid customMetricPath!')
  41. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid customMetricPath!")
  42. # sys.exit(-1)
  43. # elif not os.path.exists(customScorePath):
  44. # print('Invalid customScorePath!')
  45. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid customScorePath!")
  46. # sys.exit(-1)
  47. # else:
  48. # try:
  49. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  50. # print("SINGLE_CASE_EVAL程序开始运行:")
  51. # print(f" configPath: {configPath},\n dataPath: {dataPath},\n reportPath: {reportPath},\n "
  52. # f"csvPath: {csvPath},\n customMetricPath: {customMetricPath}\n customScorePath: {customScorePath}")
  53. # t1 = time.time()
  54. # single_case_eval(configPath, dataPath, reportPath, csvPath, customMetricPath, customScorePath)
  55. # t2 = time.time()
  56. # print(f"程序结束,执行时间:{int(t2 - t1)} s")
  57. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  58. # sys.exit(0)
  59. # except Exception as e:
  60. # print("异常,退出...")
  61. # print(repr(e))
  62. # sys.exit(-1)
  63. # else:
  64. # print('No enough arguments!')
  65. # logger.error(f"SINGLE_CASE_EVAL: No enough arguments!")
  66. # sys.exit(-1)
  67. task_path = r"./task_0416"
  68. cases = get_subfolders_name(task_path)
  69. for case in cases:
  70. dataPath = os.path.join(task_path, case)
  71. # dataPath = r"./task/pjibot_pjibot-P1YNYD1M228000127_data_merge_2024-04-07-02-01-35_obstacledetection_9"
  72. configPath = r"./config.json"
  73. # case_name = os.path.basename(os.path.dirname(dataPath))
  74. case_name = dataPath.split('/')[-1]
  75. casePath = os.path.join("./result", case_name)
  76. if not os.path.exists(casePath):
  77. os.makedirs(casePath)
  78. reportPath = rf"{casePath}/report.json"
  79. logFileName = './result/log.txt'
  80. log.setup_logger(logFileName)
  81. logger = log.get_logger()
  82. if not os.path.exists(dataPath):
  83. print('Invalid dataPath!')
  84. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  85. else:
  86. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  87. print("SINGLE_CASE_EVAL程序开始运行:")
  88. print(f" dataPath: {dataPath}, \n reportPath: {reportPath}")
  89. t1 = time.time()
  90. single_case_eval(configPath, dataPath, reportPath, casePath)
  91. t2 = time.time()
  92. print(f"程序结束,执行时间:{int(t2 - t1)} s")
  93. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")