Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .github/workflows/sync_to_huggingface_hub.yml +20 -0
- README.md +5 -5
- app.py +47 -0
- requirements.txt +5 -0
.github/workflows/sync_to_huggingface_hub.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Sync to Hugging Face hub
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches: [main]
|
6 |
+
|
7 |
+
# to run this workflow manually from the Actions tab
|
8 |
+
workflow_dispatch:
|
9 |
+
|
10 |
+
jobs:
|
11 |
+
sync-to-hub:
|
12 |
+
runs-on: ubuntu-latest
|
13 |
+
steps:
|
14 |
+
- uses: actions/checkout@v2
|
15 |
+
with:
|
16 |
+
fetch-depth: 0
|
17 |
+
- name: Push to hub
|
18 |
+
env:
|
19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
20 |
+
run: git push --force https://Amrrs:$HF_TOKEN@huggingface.co/spaces/Amrrs/image-to-text-app main
|
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
title: Image To Text
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: red
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.28.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
1 |
---
|
2 |
+
title: Image To Text App
|
3 |
+
emoji: πΉ
|
4 |
+
colorFrom: blue
|
5 |
colorTo: red
|
6 |
sdk: streamlit
|
|
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
10 |
|
11 |
+
# image2textapp
|
12 |
+
demo of π€ spaces deployment of a streamlit python app
|
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("Easy OCR - Extract Text from Images")
|
8 |
+
|
9 |
+
#subtitle
|
10 |
+
st.markdown("## Optical Character Recognition - Using `easyocr`, `streamlit` - hosted on π€ Spaces")
|
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 |
+
#image uploader
|
15 |
+
image = st.file_uploader(label = "Upload your image here",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("π€ AI is at Work! "):
|
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 an Image")
|
46 |
+
|
47 |
+
st.caption("Made with β€οΈ by @1littlecoder. Credits to π€ Spaces for Hosting this ")
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
opencv-python-headless
|
3 |
+
numpy
|
4 |
+
easyocr
|
5 |
+
Pillow
|