Spaces:
Sleeping
Sleeping
File size: 1,005 Bytes
832f690 9bed501 f0aa330 832f690 9bed501 f0aa330 9bed501 832f690 f0aa330 9bed501 832f690 9bed501 f0aa330 9bed501 f0aa330 9bed501 |
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 streamlit as st
from PIL import Image
import pytesseract
import io
# Set Tesseract binary path for Hugging Face
pytesseract.pytesseract.tesseract_cmd = "/usr/bin/tesseract"
st.set_page_config(page_title="OCR β Image to Text", layout="centered")
st.title("πΌοΈ OCR β Image to Text")
st.write("Upload an image to extract text using Tesseract OCR.")
uploaded_file = st.file_uploader("Choose an image", type=["png", "jpg", "jpeg"])
if uploaded_file:
try:
image = Image.open(io.BytesIO(uploaded_file.read()))
st.image(image, caption="Uploaded Image", use_column_width=True)
if st.button("Extract Text"):
with st.spinner("Extracting text..."):
extracted_text = pytesseract.image_to_string(image)
st.success("Text extracted!")
st.text_area("Extracted Text", extracted_text, height=300)
except Exception as e:
st.error(f"β Failed to process image: {e}")
else:
st.info("Please upload an image.")
|