Spaces:
Runtime error
Runtime error
debu das
commited on
Commit
·
d1278a0
1
Parent(s):
dec1b52
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import paddleocr
|
| 3 |
+
|
| 4 |
+
# Initialize the OCR engine
|
| 5 |
+
engine = paddleocr.create_engine()
|
| 6 |
+
|
| 7 |
+
def ocr(image):
|
| 8 |
+
# Perform OCR on the image
|
| 9 |
+
text = engine.run(image)
|
| 10 |
+
|
| 11 |
+
# Display the OCR results
|
| 12 |
+
st.markdown(f'**OCR Output:**\n{text}')
|
| 13 |
+
|
| 14 |
+
# Set up the Streamlit app
|
| 15 |
+
st.title('Image OCR')
|
| 16 |
+
|
| 17 |
+
# Add a file uploader to the app
|
| 18 |
+
image = st.file_uploader('Choose an image')
|
| 19 |
+
|
| 20 |
+
# If an image is uploaded, display it and perform OCR on it
|
| 21 |
+
if image is not None:
|
| 22 |
+
st.image(image, caption='Input Image')
|
| 23 |
+
ocr(image)
|