Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

train_model_1.0.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import argparse
  2. import torch
  3. import torchvision.models
  4. import sys
  5. import pandas
  6. '''
  7. filename:train_model_1.0.py
  8. create date: 11/17/2020 Tue
  9. Author: Jeong Geol Kim
  10. Contact: atarib4816@gmail.com
  11. Description: This .py file will train, save weight and save Results with parameters. parameters will input by .txt file.
  12. eg) train_model_1.0.py -r train_parameter.lcfg
  13. guidelines for train_parameter.txt
  14. filename format: partofarchitecture_backbone_yymmdd.lcfg
  15. eg) shapesort_mobilenetv2_201118.txt
  16. '''
  17. def Params_Set():
  18. '''
  19. Description: read options from .lcfg and initialize learning options.
  20. You should write
  21. '''
  22. HELP_TEXT = "how to use .py" #TODO: write description more precisely
  23. N_OF_PARAMS = 3 #from now on, .txt file has 3 pramas(backbone Name, iterations, save period)
  24. parser = argparse.ArgumentParser(description = HELP_TEXT)
  25. parser.add_argument("-r", required = True, help = '.lcfg file contains with learning configures')
  26. args = parser.parse_args()
  27. f = open(args.r, 'r')
  28. p_string = f.readline()
  29. f.close()
  30. params = p_string.split()
  31. if str(args.r[-4:]) != 'lcfg':
  32. print ("Error: {} is wrong filename extension. Learning configures must written in .lcfg file")
  33. return
  34. elif len(params) != N_OF_PARAMS:
  35. print("Error: {} is broken. please check learning configures.".format(args.r))
  36. return
  37. else:
  38. print("---Learning Options---")
  39. print("Backbone Name: {}".format(params[0]))
  40. print("Number of iterations: {}".format(params[1]))
  41. print("Period of saving weight: {}".format(params[2]))
  42. return params, args.r
  43. def Preprocess():
  44. pass
  45. def Model_Construct():
  46. pass
  47. def Train():
  48. pass
  49. def Save_Weight():
  50. pass
  51. def Result():
  52. pass
  53. if __name__ == "__main__":
  54. #get all params from option files
  55. params, name_of_lcfg = Params_Set()
  56. Preprocess()
  57. Model_Construct()
  58. Train()
  59. Save_Weight()
  60. Result()