Spaces:
Runtime error
Runtime error
[email protected]
commited on
Commit
·
0810a02
1
Parent(s):
a98aff0
bare minimum
Browse files- README.md +2 -0
- language_models_project/app.py +1 -36
- requirements.txt +0 -0
README.md
CHANGED
|
@@ -5,9 +5,11 @@ colorFrom: blue
|
|
| 5 |
colorTo: red
|
| 6 |
sdk: streamlit
|
| 7 |
app_file: language_models_project/app.py
|
|
|
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
|
|
|
| 11 |
# image2textapp
|
| 12 |
demo of 🤗 spaces deployment of a streamlit python app
|
| 13 |
|
|
|
|
| 5 |
colorTo: red
|
| 6 |
sdk: streamlit
|
| 7 |
app_file: language_models_project/app.py
|
| 8 |
+
python_version: 3.10.4
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
+
|
| 13 |
# image2textapp
|
| 14 |
demo of 🤗 spaces deployment of a streamlit python app
|
| 15 |
|
language_models_project/app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
#from main import classify
|
| 2 |
-
import easyocr as ocr #OCR
|
| 3 |
import streamlit as st #Web App
|
| 4 |
-
from PIL import Image #Image Processing
|
| 5 |
-
import numpy as np #Image Processing
|
| 6 |
|
| 7 |
|
| 8 |
#title
|
|
@@ -13,37 +11,4 @@ st.markdown("## Optical Character Recognition - Using `easyocr`, `streamlit` -
|
|
| 13 |
|
| 14 |
st.markdown("Link to the app - [image-to-text-app on 🤗 Spaces](https://huggingface.co/spaces/Amrrs/image-to-text-app)")
|
| 15 |
|
| 16 |
-
#image uploader
|
| 17 |
-
image = st.file_uploader(label = "Upload your image here",type=['png','jpg','jpeg'])
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
@st.cache
|
| 21 |
-
def load_model():
|
| 22 |
-
reader = ocr.Reader(['en'],model_storage_directory='.')
|
| 23 |
-
return reader
|
| 24 |
-
|
| 25 |
-
reader = load_model() #load model
|
| 26 |
-
|
| 27 |
-
if image is not None:
|
| 28 |
-
|
| 29 |
-
input_image = Image.open(image) #read image
|
| 30 |
-
st.image(input_image) #display image
|
| 31 |
-
|
| 32 |
-
with st.spinner("🤖 AI is at Work! "):
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
result = reader.readtext(np.array(input_image))
|
| 36 |
-
|
| 37 |
-
result_text = [] #empty list for results
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
for text in result:
|
| 41 |
-
result_text.append(text[1])
|
| 42 |
-
|
| 43 |
-
st.write(result_text)
|
| 44 |
-
#st.success("Here you go!")
|
| 45 |
-
st.balloons()
|
| 46 |
-
else:
|
| 47 |
-
st.write("Upload an Image")
|
| 48 |
-
|
| 49 |
st.caption("Made with ❤️ by @1littlecoder. Credits to 🤗 Spaces for Hosting this ")
|
|
|
|
| 1 |
#from main import classify
|
| 2 |
+
#import easyocr as ocr #OCR
|
| 3 |
import streamlit as st #Web App
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
#title
|
|
|
|
| 11 |
|
| 12 |
st.markdown("Link to the app - [image-to-text-app on 🤗 Spaces](https://huggingface.co/spaces/Amrrs/image-to-text-app)")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
st.caption("Made with ❤️ by @1littlecoder. Credits to 🤗 Spaces for Hosting this ")
|
requirements.txt
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|