You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.py 2.7 kB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # !/usr/bin/env python
  2. # -*- coding:utf-8 -*-
  3. """
  4. Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================
  15. """
  16. from __future__ import absolute_import
  17. from __future__ import division
  18. from __future__ import print_function
  19. import argparse
  20. from datetime import datetime
  21. def get_parser(parser=None):
  22. def str_list(x):
  23. return x.split(',')
  24. def int_list(x):
  25. return list(map(int, x.split(',')))
  26. def float_list(x):
  27. return list(map(float, x.split(',')))
  28. if parser is None:
  29. parser = argparse.ArgumentParser("flags for cnn benchmark")
  30. parser.add_argument(
  31. "--image_path",
  32. type=str,
  33. default='tiger.jpg',
  34. help="image path")
  35. parser.add_argument(
  36. "--model_load_dir",
  37. type=str,
  38. default=None,
  39. help="model load directory")
  40. # for data process
  41. parser.add_argument(
  42. "--num_classes",
  43. type=int,
  44. default=1000,
  45. help="num of pic classes")
  46. parser.add_argument(
  47. '--rgb-mean',
  48. type=float_list,
  49. default=[
  50. 123.68,
  51. 116.779,
  52. 103.939],
  53. help='a tuple of size 3 for the mean rgb')
  54. parser.add_argument(
  55. '--rgb-std',
  56. type=float_list,
  57. default=[
  58. 58.393,
  59. 57.12,
  60. 57.375],
  61. help='a tuple of size 3 for the std rgb')
  62. parser.add_argument(
  63. "--log_dir",
  64. type=str,
  65. default="./output",
  66. help="log info save directory")
  67. return parser
  68. def print_args(args):
  69. print("=".ljust(66, "="))
  70. print(
  71. "Running {}: num_gpu_per_node = {}, num_nodes = {}.".format(
  72. 'ResNet50 V1.5',
  73. 1,
  74. 1))
  75. print("=".ljust(66, "="))
  76. for arg in vars(args):
  77. print("{} = {}".format(arg, getattr(args, arg)))
  78. print("-".ljust(66, "-"))
  79. print("Time stamp: {}".format(
  80. str(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))))
  81. if __name__ == '__main__':
  82. parser = get_parser()
  83. args = parser.parse_args()
  84. print_args(args)

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能