Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import easyocr as ocr #OCR
|
| 2 |
+
import streamlit as st #Web App
|
| 3 |
+
from PIL import Image #Image Processing
|
| 4 |
+
import numpy as np #Image Processing
|
| 5 |
+
|
| 6 |
+
#title
|
| 7 |
+
st.title("Automatización en la Carga de Datos")
|
| 8 |
+
|
| 9 |
+
#subtitle
|
| 10 |
+
st.markdown("## Sube una Imagen, puede tener tanto texto como números ")
|
| 11 |
+
|
| 12 |
+
st.markdown("Link para mas Info - [@cesarriat 🤓 ](https://linktr.ee/cesarriat)")
|
| 13 |
+
|
| 14 |
+
#image uploader
|
| 15 |
+
image = st.file_uploader(label = "Upload(sube) tu imagen Aqui",type=['png','jpg','jpeg'])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@st.cache
|
| 19 |
+
def load_model():
|
| 20 |
+
reader = ocr.Reader(['en'],model_storage_directory='.')
|
| 21 |
+
return reader
|
| 22 |
+
|
| 23 |
+
reader = load_model() #load model
|
| 24 |
+
|
| 25 |
+
if image is not None:
|
| 26 |
+
|
| 27 |
+
input_image = Image.open(image) #read image
|
| 28 |
+
st.image(input_image) #display image
|
| 29 |
+
|
| 30 |
+
with st.spinner("🤖 La Inteligencia Artificial esta Funcionando, espere unos segundos! "):
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
result = reader.readtext(np.array(input_image))
|
| 34 |
+
|
| 35 |
+
result_text = [] #empty list for results
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
for text in result:
|
| 39 |
+
result_text.append(text[1])
|
| 40 |
+
|
| 41 |
+
st.write(result_text)
|
| 42 |
+
#st.success("Here you go!")
|
| 43 |
+
st.balloons()
|
| 44 |
+
else:
|
| 45 |
+
st.write("Upload( sube) una Imagen")
|
| 46 |
+
|
| 47 |
+
st.caption("Made with ❤️ ")
|