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}')