rajsecrets0 commited on
Commit
67c0b77
โ€ข
1 Parent(s): 3bb3f69

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import pytesseract
4
+ import shutil
5
+
6
+ # Streamlit app title
7
+ st.title("Image to Text Extraction App ๐Ÿ–ผ๏ธ๐Ÿ“")
8
+
9
+ # Prompt for image upload
10
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
11
+
12
+ # Check if tesseract is installed and in PATH
13
+ pytesseract.pytesseract.tesseract_cmd = shutil.which("tesseract") or None
14
+
15
+ # If an image is uploaded, perform OCR
16
+ if uploaded_file is not None:
17
+ image = Image.open(uploaded_file)
18
+ st.image(image, caption="Uploaded Image", use_column_width=True)
19
+
20
+ # Perform OCR using Tesseract
21
+ with st.spinner("Extracting text..."):
22
+ text = pytesseract.image_to_string(image)
23
+
24
+ # Display the extracted text
25
+ st.subheader("Extracted Text:")
26
+ st.write(text)
27
+ else:
28
+ st.warning("Please upload an image file to extract text.")