示例#1
0
    log_dir = FLAGS.log_dir

    class_names = get_classes(FLAGS.classes_file)
    num_classes = len(class_names)
    anchors = get_anchors(FLAGS.anchors_path)
    weights_path = FLAGS.weights_path

    input_shape = (416, 416)  # multiple of 32, height, width
    epoch1, epoch2 = FLAGS.epochs, FLAGS.epochs

    is_tiny_version = (len(anchors) == 6)  # default setting
    if FLAGS.is_tiny:
        model = create_tiny_model(input_shape,
                                  anchors,
                                  num_classes,
                                  freeze_body=2,
                                  weights_path=weights_path)
    else:
        model = create_model(
            input_shape,
            anchors,
            num_classes,
            freeze_body=2,
            weights_path=weights_path)  # make sure you know what you freeze

    log_dir_time = os.path.join(log_dir, '{}'.format(int(time())))
    logging = TensorBoard(log_dir=log_dir_time)
    checkpoint = ModelCheckpoint(os.path.join(log_dir, 'checkpoint.h5'),
                                 monitor='val_loss',
                                 save_weights_only=True,
示例#2
0
            weights_path = FLAGS.weights_path

        if FLAGS.is_tiny and FLAGS.anchors_path == anchors_path:
            anchors_path = os.path.join(os.path.dirname(FLAGS.anchors_path),
                                        "yolo-tiny_anchors.txt")
        else:
            anchors_path = FLAGS.anchors_path

        anchors = get_anchors(anchors_path)
        epoch1, epoch2 = FLAGS.epochs, FLAGS.epochs

        is_tiny_version = len(anchors) == 6  # default setting
        if FLAGS.is_tiny:
            model = create_tiny_model(INPUT_SHAPE,
                                      anchors,
                                      num_classes,
                                      freeze_body=2,
                                      weights_path=weights_path)
        else:
            model = create_model(INPUT_SHAPE,
                                 anchors,
                                 num_classes,
                                 freeze_body=2,
                                 weights_path=weights_path)

        log_dir_time = os.path.join(log_dir, "{}".format(int(time())))
        logging = TensorBoard(log_dir=log_dir_time)
        checkpoint = ModelCheckpoint(
            os.path.join(log_dir, "checkpoint.h5"),
            monitor="val_loss",
            save_weights_only=True,