コード例 #1
0
def get_crnn_output(boxes):
    crnn = model.CRNN()()
    crnn.load_weights(config.crnn_weights_path)
    for i in range(len(boxes)):
        image = boxes[i]['img']
        image = utils_image.resizeNormalize(image, 32)
        image = image.astype(np.float32)
        image = np.array([[image]])
        preds = crnn.predict(image)
        preds = np.argmax(preds, axis=-1).reshape((-1,))
        boxes[i]['text'] = utils.strLabelConverter(preds, config.alphabet)
    return boxes
コード例 #2
0
        'print_word': train_dataset_print_word,
        'print_num': train_dataset_print_num,
        'symbol': train_dataset_symbol,
        'seal': train_dataset_seal,
        'catword': train_dataset_catword,
    }

    valid_datasets = {
        'hand_word': valid_dataset_hand_word,
        'hand_num': valid_dataset_hand_num,
        'print_word': valid_dataset_print_word,
        'print_num': valid_dataset_print_num,
        'symbol': valid_dataset_symbol,
        'seal': valid_dataset_seal,
        'catword': valid_dataset_catword,
    }

    alphabets = alphabets.alphabet_char
    n_class = len(alphabets) + 1

    converter = convert.strLabelConverter(alphabets)
    criterion = CTCLoss()
    model = model.CRNN(class_num=n_class, backbone='resnet', pretrain=False)
    train(model,
          criterion,
          converter,
          device,
          train_datasets,
          valid_datasets,
          pretrain=True)