def infer(model, fnImg, correct):
    """ Recognize text in image provided by file path """
    img = preprocessor(cv2.imread(fnImg, cv2.IMREAD_GRAYSCALE),
                       imgSize=Model.imgSize)
    if img is None:
        print("Image not found")
        return

    recognized = model.predict(fnImg)
    print(recognized)
    recognized = model.decoderToText(recognized)

    print("Without Correction: ", recognized)
    print("With Correction: ", correct_sentence(recognized))
    if correct:
        return correct_sentence(recognized)
    else:
        return recognized
コード例 #2
0
def infer(model, fnImg):
    """ Recognize text in image provided by file path """
    img = preprocessor(cv2.imread(fnImg, cv2.IMREAD_GRAYSCALE), imgSize=Model.imgSize)
    if img is None:
        print("Image not found")

    imgs = load_different_image()
    imgs = [img] + imgs
    batch = Batch(None, imgs)
    recognized = model.inferBatch(batch)  # recognize text

    print("Without Correction", recognized[0])
    print("With Correction", correct_sentence(recognized[0]))
    return recognized[0]
コード例 #3
0
def infer(model, fnImg):
    """ Recognize text in image provided by file path """
    img = preprocess(cv2.imread(fnImg, cv2.IMREAD_GRAYSCALE),
                     imgSize=Model.imgSize)
    if img is None:
        print("Image not found")

    imgs = load_different_image()
    imgs = [img] + imgs
    batch = Batch(None, imgs)
    recognized = model.inferBatch(batch)  # recognize text

    print("\n\n\n\n\nWithout Correction: ", recognized[0])
    ans = correct_sentence(recognized[0])
    print("\nWith Correction: ", ans)
    print("\n\n\n\n\n")
    f = open(r'C:\\Users\\ISHIKA\\Desktop\\EAD Project\\NTNLine/output.txt',
             'w')
    f.write(ans)
    return ans