|
import easyocr as ocr |
|
import streamlit as st |
|
from PIL import Image |
|
import numpy as np |
|
|
|
|
|
st.title("DiSSCo OCR - Extract Data from Images") |
|
|
|
|
|
st.markdown("## Optical Character Recognition - Using `easyocr`, `streamlit` - hosted on π€ Spaces") |
|
|
|
st.markdown("Link to the app - [image-to-text-app on π€ Spaces](https://huggingface.co/spaces/Amrrs/image-to-text-app)") |
|
|
|
|
|
image = st.file_uploader(label = "Upload your image here",type=['png','jpg','jpeg']) |
|
|
|
|
|
@st.cache |
|
def load_model(): |
|
reader = ocr.Reader(['en'],model_storage_directory='.') |
|
return reader |
|
|
|
reader = load_model() |
|
|
|
if image is not None: |
|
|
|
input_image = Image.open(image) |
|
st.image(input_image) |
|
|
|
with st.spinner("AI is working...! "): |
|
|
|
|
|
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") |
|
|
|
st.caption("Made with β€οΈ by @1littlecoder. Credits to π€ Spaces for Hosting this ") |