Ejemplo n.º 1
0
def gen(df):
    """
    Wrapper around generator. Keras fit_generator requires looping generator.
    :param df: dataflow instance
    """
    while True:
        for i in df.get_data():
            yield i


if __name__ == '__main__':

    # get the model

    model = get_training_model(weight_decay)

    # restore weights

    last_epoch = restore_weights(weights_best_file, model)

    # prepare generators

    curr_dir = os.path.dirname(__file__)
    annot_path_train = os.path.join(curr_dir, '../dataset/annotations/person_keypoints_train2017.json')
    img_dir_train = os.path.abspath(os.path.join(curr_dir, '../dataset/train2017/'))
    annot_path_val = os.path.join(curr_dir, '../dataset/annotations/person_keypoints_val2017.json')
    img_dir_val = os.path.abspath(os.path.join(curr_dir, '../dataset/val2017/'))

    # get dataflow of samples from training set and validation set (we use validation set for training as well)
Ejemplo n.º 2
0
    :param df: dataflow instance
    """
    while True:
        for i in df.get_data():
            yield i


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Training codes for Keras Pose Estimation')
    parser.add_argument('--model', default='cmu', help='model name')
    args = parser.parse_args()
    # get the model

    if args.model == 'cmu':
        model = cmu_model.get_training_model(weight_decay)
    elif args.model == 'squeeze':
        model = squeeze_model.get_training_model(weight_decay)
    elif args.model == 'mobile':
        model = mobile_model.get_training_model(weight_decay)
    elif args.model == 'cmu-thin':
        model = cmu_thin_model.get_training_model(weight_decay)

    # restore weights
    last_epoch = restore_weights(weights_best_file, model)
    #last_epoch = restore_weights("../model/squeeze_imagenet.h5", model)
    print(model.summary())

    # prepare generators

    curr_dir = os.path.dirname(__file__)