示例#1
0
    )
    parser.add_argument(
        "--epochs",
        type=float,
        default=51,
        help=
        "Number of epochs for training last layers and number of epochs for fine-tuning layers. Default is 51."
    )

    FLAGS = parser.parse_args()

    np.random.seed(FLAGS.random_seed)

    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:
示例#2
0
        default=300,
        help=
        "Number of epochs for training last layers and number of epochs for fine-tuning layers. Default is 51."
    )
    parser.add_argument(
        "--pre_trained_path",
        type=str,
        dest='pre_trained_weights_path',
        default=None,
        help="Absolute path for pre trained weights. default is None.")

    FLAGS = parser.parse_args()
    np.random.seed(None)

    weights_folder = FLAGS.weights_folder_path
    class_names = get_classes(classname_file)
    num_classes = len(class_names)
    anchors = get_anchors(anchors_path)
    input_shape = (416, 416)
    epoch1, epoch2 = FLAGS.epochs, FLAGS.epochs
    model = create_model(input_shape,
                         anchors,
                         num_classes,
                         freeze_body=2,
                         weights_path=weights_path)

    if FLAGS.pre_trained_weights_path != None:
        print('load pre trained weights: ' + FLAGS.pre_trained_weights_path)
        model.load_weights(FLAGS.pre_trained_weights_path)

    reduce_lr = ReduceLROnPlateau(monitor='val_loss',