Beispiel #1
0
def main(args=None):
    # parse arguments

    args = parse_args()
    args = load_setting_cfg(args)

    # optionally choose specific GPU
    if args.gpu:
        os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu)
        set_gpu()

    # make save path if it doesn't exist
    if args.save_path is not None and not os.path.exists(args.save_path):
        os.makedirs(args.save_path)

    # create the generator
    generator = create_generator(args)

    # load the model
    print('Loading model, this may take a second...')

    model = create_models(num_classes=generator.num_classes())
    # print(predict_model.summary())

    # model.load_weights(filepath=args.weight_path, by_name=True)
    if os.path.exists(args.weight_path):
        model.load_weights(filepath=args.weight_path)
        print(args.weight_path)

    # predict_model.load_weights(filepath=args.weight_path, by_name=True)

    print('loading weight : {} , this may take a second...'.format(
        args.weight_path))

    # start evaluation
    print('start evaluate')
    average_precisions = evaluate(generator,
                                  model,
                                  iou_threshold=args.iou_threshold,
                                  score_threshold=args.score_threshold,
                                  max_detections=args.max_detections,
                                  save_path=args.save_path)

    # print evaluation
    for label, average_precision in average_precisions.items():
        print(generator.label_to_name(label),
              '{:.4f}'.format(average_precision))
    print('mAP: {:.4f}'.format(
        sum(average_precisions.values()) / len(average_precisions)))
Beispiel #2
0
def check_args(parsed_args):
    # TODO check the args
    # reload parse arguments
    args = load_setting_cfg(parsed_args)

    return args