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, save_best_only=True, period=5, ) reduce_lr = ReduceLROnPlateau(monitor="val_loss", factor=0.1, patience=3,
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, save_best_only=True, period=5) reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.1, patience=3, verbose=1) early_stopping = EarlyStopping(monitor='val_loss',
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', factor=0.98, patience=3, verbose=1) val_split = FLAGS.val_split with open(FLAGS.annotation_file) as f: lines = f.readlines()