Spaces:
Build error
Build error
File size: 1,127 Bytes
926f00c cdd5617 926f00c cdd5617 926f00c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import gradio as gr
import os
#from googletrans import Translator
import easyocr
#import PIL
from PIL import Image
from PIL import ImageDraw
def Get_OCR_demo(image):
reader = easyocr.Reader(['en']) #IMP 'hi'
translator = Translator()
#image_file =Image.open(image,mode = 'r')
im = Image.open(image,mode = 'r')
#im =Image.open(image,mode = 'r')
text_list = reader.readtext(im,add_margin = 0.55,width_ths=0.7, link_threshold=0.8,decoder='beamsearch', blocklist='=-',detail = 0 )
#text_list = reader.readtext(image_file,add_margin = 0.55,width_ths=0.7, link_threshold=0.8,decoder='beamsearch', blocklist='=-',detail = 0 )
text_comb =' '.join(text_list) #changed into a single line
return text_comb
title = "Upload an image and extract Text from it"
description = "OCR tool for text extraction"
examples=[["english.png"],["Upload Parag_Letter_j.jpg"]]
get_OCR_demo = gr.Interface(fn=Get_OCR_demo, inputs="image",outputs=['text'],title = title,description=description,examples=[["english.png","Parag_Letter.jfif"]],cache_examples=False)
# if __name__ == "__main__":
# demo.launch() |