Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from ocr import extract_text
|
| 3 |
+
|
| 4 |
+
st.title("OCR Application")
|
| 5 |
+
|
| 6 |
+
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 7 |
+
|
| 8 |
+
if uploaded_file is not None:
|
| 9 |
+
with open("temp_image.jpg", "wb") as f:
|
| 10 |
+
f.write(uploaded_file.getbuffer())
|
| 11 |
+
|
| 12 |
+
extracted_text = extract_text("temp_image.jpg")
|
| 13 |
+
|
| 14 |
+
st.subheader("Extracted Text:")
|
| 15 |
+
st.write(extracted_text)
|
| 16 |
+
|
| 17 |
+
keyword = st.text_input("Enter a keyword to search:")
|
| 18 |
+
|
| 19 |
+
if keyword:
|
| 20 |
+
if keyword.lower() in extracted_text.lower():
|
| 21 |
+
st.success(f"Keyword '{keyword}' found in the text!")
|
| 22 |
+
else:
|
| 23 |
+
st.error(f"Keyword '{keyword}' not found.")
|