Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,12 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
#title
|
7 |
st.title("Image to Text Toy Application")
|
8 |
|
9 |
-
#subtitle
|
10 |
-
st.markdown("Link to the app - [image-to-text-app on 🤗 Spaces](https://huggingface.co/spaces/Amrrs/image-to-text-app)")
|
11 |
-
|
12 |
-
#image uploader
|
13 |
image = st.file_uploader(label = "Upload your image here", type=['png','jpg','jpeg'])
|
14 |
|
15 |
-
|
16 |
@st.cache_data
|
17 |
def load_model():
|
18 |
reader = ocr.Reader(['en'],model_storage_directory='.')
|
@@ -21,9 +15,9 @@ def load_model():
|
|
21 |
reader = load_model()
|
22 |
|
23 |
if image is not None:
|
24 |
-
input_image = Image.open(image)
|
25 |
st.image(input_image)
|
26 |
-
with st.spinner("AI is
|
27 |
result = reader.readtext(np.array(input_image))
|
28 |
result_text = []
|
29 |
for text in result:
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import easyocr as ocr
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
|
|
|
6 |
st.title("Image to Text Toy Application")
|
7 |
|
|
|
|
|
|
|
|
|
8 |
image = st.file_uploader(label = "Upload your image here", type=['png','jpg','jpeg'])
|
9 |
|
|
|
10 |
@st.cache_data
|
11 |
def load_model():
|
12 |
reader = ocr.Reader(['en'],model_storage_directory='.')
|
|
|
15 |
reader = load_model()
|
16 |
|
17 |
if image is not None:
|
18 |
+
input_image = Image.open(image)
|
19 |
st.image(input_image)
|
20 |
+
with st.spinner("AI is processing your request."):
|
21 |
result = reader.readtext(np.array(input_image))
|
22 |
result_text = []
|
23 |
for text in result:
|