File size: 694 Bytes
58146ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import easyocr
from PIL import Image

# Initialize the EasyOCR Reader
reader = easyocr.Reader(['en'])

# Streamlit interface
st.title("OCR with EasyOCR")

# Upload image
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])

if uploaded_file:
    # Open image file
    image = Image.open(uploaded_file)
    st.image(image, caption='Uploaded Image', use_column_width=True)

    # Run OCR
    result = reader.readtext(image)

    # Display OCR results
    st.subheader("OCR Results:")
    for detection in result:
        text = detection[1]
        bbox = detection[0]
        st.write(f"Text: {text}")
        st.write(f"Bounding Box: {bbox}")