Пример #1
0
  model_config = configparser.ConfigParser()
  model_config.read(args.model)
  model = ModelBuilder(model_config)
  model.build_graph()
  model.compile()
  model.summary_txt()
  model.print_png()
  model.save_graph()

  # Train Model
  if args.train:
    train_config = configparser.ConfigParser()
    train_config.read(args.train)
    trainer = ModelTrainer(train_config)
    trainer.get_hyperparameters()
    trainer.get_train_set()
    trainer.get_dev_set()
    trainer.get_callbacks()
    train_history = model.train(trainer.fit_options)
    model.save_weights(trainer.outputs_config['weights'])
    trainer.write_outputs(train_history)

  # Test Model
  if args.test:
    test_config = configparser.ConfigParser()
    test_config.read(args.test)    
    tester = ModelTester(test_config)
    tester.get_weights()
    model.load_weights(tester.weights)
    tester.get_test_set()
    tester.get_header_list()
Пример #2
0
    #parser.add_argument('--weights', type=str, default='./yolo_tf_weights/yolov3.weights.h5')
    parser.add_argument('--num_epochs', type=int, default=100)
    parser.add_argument('--batch_size', type=int, default=32)
    args = parser.parse_args()

    anchors = get_anchors(args.anchor_path)
    print('Anchors:', anchors)

    classes = get_classes(args.class_name_path)
    num_classes = len(classes)
    print('Number of Classes:', num_classes)

    print('Image Shape', args.image_shape)
    model = YoloV3(args.image_shape, anchors, num_classes)
    model.build_graph()
    #model.compile()

    # Dataset
    # Label: class, x, y, w, h (relative to image)
    anchors_mask = [[6, 7, 8], [3, 4, 5], [0, 1, 2]]

    trainer = ModelTrainer()
    trainer.get_input_options(args.image_shape, args.letterbox_resize, anchors,
                              num_classes, anchors_mask)
    trainer.get_hyperparameters(args.num_epochs, args.batch_size)
    trainer.get_train_set(args.train_input, args.train_target)
    #dev_set = get_train_set(args.dev_set)

    #model.load_weights(args.weights)
    # Train Model