File size: 759 Bytes
a363201
 
 
 
84440db
a67a7d0
84440db
a67a7d0
84440db
a67a7d0
84440db
3d1653f
84440db
 
a67a7d0
84440db
 
a363201
a67a7d0
a363201
84440db
a67a7d0
84440db
 
 
 
 
a67a7d0
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
import streamlit as st  
import easyocr as ocr 
import numpy as np 
from PIL import Image 

st.title("Image to Text Toy Application")

image = st.file_uploader(label = "Upload your image here", type=['png','jpg','jpeg'])

@st.cache_data
def load_model(): 
    reader = ocr.Reader(['en'],model_storage_directory='stabilityai/stable-code-3b')
    return reader 

reader = load_model() 

if image is not None:
    input_image = Image.open(image) 
    st.image(input_image)
    with st.spinner("AI is processing your request."):
        result = reader.readtext(np.array(input_image))
        result_text = []
        for text in result:
            result_text.append(text[1])
        st.write(result_text)
    st.balloons()
else:
    st.write("Upload an Image")