Spaces:
Runtime error
Runtime error
File size: 754 Bytes
d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 d1278a0 70ac413 |
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 31 |
import streamlit as st
import paddlehub as hub
# Load the PaddleOCR module
module = hub.Module(name='paddleocr')
# Set the OCR detection language to English
module.set_encode('utf-8')
module.set_decode('utf-8')
# Create a function to perform OCR on an image
def ocr(image):
# Use the PaddleOCR module to detect text in the image
result = module.detection(images=[image])
# Extract the text from the OCR result
text = result[0]['data'][0]['text']
return text
# Set up the Streamlit app
st.title('Image OCR with PaddleOCR')
# Allow the user to upload an image
image = st.file_uploader('Choose an image to OCR:')
# Perform OCR on the image and display the result
if image is not None:
text = ocr(image)
st.write(f'OCR result: {text}')
|