Closed rathorology closed 3 years ago
from kraken.lib.models import load_any from kraken import rpred, binarization from PIL import Image
img = Image.open("path_of_image")
## ---Binarization of image--- genrator_image = Image.fromarray(img) genrator_image = binarization.nlbin(genrator_image)
## ---Loading Kraken Model---download model and provide path here) model = load_any("en-default.mlmodel")
cord = [x, y, x + w, y + h] bound = {'boxes': [tuple(cord)], 'text_direction': 'horizontal-lr'}
## Using Kraken API generator = rpred.rpred(network=model, im=genrator_image, bounds=bound) nxt_gen = next(generator) text = nxt_gen.prediction
I think this should be written in README.md
The API docs now include a tutorial style documentation for the 3.0 release.
$ kraken -i image.tif image.txt binarize segment ocr
How can I do this in python script using Kraken API