Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import pytesseract
|
4 |
+
|
5 |
+
st.set_page_config(page_title="Image to Text OCR", layout="centered")
|
6 |
+
|
7 |
+
st.title("🖼️ Image to Text Converter (OCR)")
|
8 |
+
st.write("Upload an image and extract text using Optical Character Recognition (OCR).")
|
9 |
+
|
10 |
+
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
|
11 |
+
|
12 |
+
if uploaded_file is not None:
|
13 |
+
image = Image.open(uploaded_file)
|
14 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
15 |
+
|
16 |
+
if st.button("Extract Text"):
|
17 |
+
with st.spinner("Extracting text..."):
|
18 |
+
text = pytesseract.image_to_string(image)
|
19 |
+
st.subheader("Extracted Text")
|
20 |
+
st.text_area("Text Output", value=text, height=300)
|
21 |
+
else:
|
22 |
+
st.info("Please upload an image to get started.")
|