saidivyesh commited on
Commit
4eef487
·
verified ·
1 Parent(s): 6e66555

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -1,11 +1,14 @@
1
  import gradio as gr
2
- from PIL import Image
3
- import pytesseract
4
  import re
5
 
6
- # Step 1: Function to extract text using OCR for both Hindi and English
 
 
 
7
  def extract_text(image):
8
- extracted_text = pytesseract.image_to_string(image, lang='hin+eng')
 
9
  return extracted_text
10
 
11
  # Step 2: Function to search and highlight the keyword in the extracted text
 
1
  import gradio as gr
2
+ import easyocr
 
3
  import re
4
 
5
+ # Initialize the EasyOCR reader for Hindi and English
6
+ reader = easyocr.Reader(['hi', 'en'])
7
+
8
+ # Step 1: Function to extract text using EasyOCR for both Hindi and English
9
  def extract_text(image):
10
+ results = reader.readtext(image, detail=0) # 'detail=0' to get only the text output
11
+ extracted_text = " ".join(results) # Join all text results into a single string
12
  return extracted_text
13
 
14
  # Step 2: Function to search and highlight the keyword in the extracted text