Spaces:
Sleeping

File size: 562 Bytes
8f08eae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pytesseract
from PIL import Image


st.write("## Tesseract OCR \n A simple Image to Text Application")

#TODO: Limit input to supported image files
file = st.file_uploader("Choose a file", type=['png', 'jpg'])

@st.cache_data
def transcribe(file):
    image = Image.open(file)
    ocr_text =  pytesseract.image_to_string(image)
    return ocr_text, image

if file is not None:
    st.write("Image uploaded succesfully!")

    ocr_text, image = transcribe(file)

    st.image(image)
    st.write("### Recognized Text")
    ocr_text