<jupyter_start><jupyter_text>Easy OCR<jupyter_code>!pip install easyocr
# import library
import easyocr


#specify shortform of language you want to extract,
# I am using Hindi(hi) and English(en) here by list of language ids
reader = easyocr.Reader(['hi','en'])
!wget -O 'image.jpg' "https://miro.medium.com/max/391/1*zvN3oQiI6YFtV7hBPz4ATA.png"
from PIL import Image, ImageDraw
# Read Image
im = Image.open("image.jpg")
im
# Doing OCR. Get bounding boxes.
bounds = reader.readtext('image.jpg', detail=0) #detail=0 argument will only give text in array
print("Output:")
print(bounds)
# Doing OCR. Get bounding boxes. bounds = reader.readtext('Hindi_fonts.png', detail=1) #detail=1 
bounds = reader.readtext('image.jpg', detail=1)
print("Output:")
print(bounds)
# Draw bounding boxes
def draw_boxes(image, bounds, color='yellow', width=2):
    draw = ImageDraw.Draw(image)
    for bound in bounds: # iterate though all the tuples of output
        p0, p1, p2, p3 = bound[0] # get coordinates 
        draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
    return image

draw_boxes(im, bounds)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13415710503089143, 'fraction_numerical': 0.02118270079435128, 'mean_word_length': 5.031914893617022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '130901', 'license': 'Apache-2.0', 'n_tokens_mistral': 415, 'n_tokens_neox': 396, 'n_words': 115, 'path': '_notebooks/2022-01-06-easyocr.ipynb', 'repo_name': 'recohut/notebook', 'size': '1133'}