Spaces:
Sleeping
Sleeping
File size: 858 Bytes
67c0b77 |
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 |
import streamlit as st
from PIL import Image
import pytesseract
import shutil
# Streamlit app title
st.title("Image to Text Extraction App ๐ผ๏ธ๐")
# Prompt for image upload
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
# Check if tesseract is installed and in PATH
pytesseract.pytesseract.tesseract_cmd = shutil.which("tesseract") or None
# If an image is uploaded, perform OCR
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Perform OCR using Tesseract
with st.spinner("Extracting text..."):
text = pytesseract.image_to_string(image)
# Display the extracted text
st.subheader("Extracted Text:")
st.write(text)
else:
st.warning("Please upload an image file to extract text.")
|