ProgramerSalar commited on
Commit
b4a89a6
·
1 Parent(s): a983ddb
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import pytesseract
4
+
5
+ custom_css = """
6
+ .big-font textarea {
7
+ font-size: 20px !important;
8
+ }
9
+ """
10
+
11
+ def extract_text(image):
12
+ # Convert the image to text using pytesseract
13
+ text = pytesseract.image_to_string(image)
14
+ return text
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=extract_text,
19
+ inputs=gr.Image(type="pil"), # Accept PIL images directly
20
+ outputs=gr.Textbox(lines=20,
21
+ max_lines=10,
22
+ label='Extracted Text',
23
+ elem_classes=["big-font"]
24
+ ),
25
+ title="Text Extraction",
26
+ description="Upload an image to extract text",
27
+ allow_flagging='never',
28
+ css=custom_css
29
+ )
30
+
31
+ # Launch the app
32
+ iface.launch()