Spaces:
Runtime error
Runtime error
Dinh Minh
commited on
Commit
·
f5143fd
1
Parent(s):
d743aa7
Upload 12 files
Browse files- Home.py +17 -0
- img_demo_1.jpg +0 -0
- img_demo_2.jpg +0 -0
- multipage.py +68 -0
- ocr.png +0 -0
- packages.txt +4 -0
- requirements.txt +19 -0
- tmp_311715319_2060358020840543_6779133249018943291_n.jpg +0 -0
- tmp_I3.jpg +0 -0
- tmp_img_demo_1.jpg +0 -0
- tmp_img_demo_2.jpg +0 -0
Home.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from multipage import MultiPage
|
3 |
+
from app_pages import home, about, ocr_comparator
|
4 |
+
|
5 |
+
app = MultiPage()
|
6 |
+
st.set_page_config(
|
7 |
+
page_title='OCR Comparator', layout ="wide",
|
8 |
+
initial_sidebar_state="expanded",
|
9 |
+
)
|
10 |
+
|
11 |
+
# Add all your application here
|
12 |
+
app.add_page("Home", "house", home.app)
|
13 |
+
app.add_page("About", "info-circle", about.app)
|
14 |
+
app.add_page("App", "cast", ocr_comparator.app)
|
15 |
+
|
16 |
+
# The main app
|
17 |
+
app.run()
|
img_demo_1.jpg
ADDED
![]() |
img_demo_2.jpg
ADDED
![]() |
multipage.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This file is the framework for generating multiple Streamlit applications
|
3 |
+
through an object oriented framework.
|
4 |
+
|
5 |
+
Source: https://huggingface.co/spaces/deepset/wikipedia-assistant/tree/main
|
6 |
+
"""
|
7 |
+
|
8 |
+
# Import necessary libraries
|
9 |
+
import streamlit as st
|
10 |
+
from streamlit_option_menu import option_menu
|
11 |
+
|
12 |
+
|
13 |
+
# Define the multipage class to manage the multiple apps in our program
|
14 |
+
class MultiPage:
|
15 |
+
"""Framework for combining multiple streamlit applications."""
|
16 |
+
|
17 |
+
def __init__(self) -> None:
|
18 |
+
"""Constructor class to generate a list which will store all our applications as an instance variable."""
|
19 |
+
self.pages = []
|
20 |
+
|
21 |
+
def add_page(self, title, icon, func) -> None:
|
22 |
+
"""Class Method to Add pages to the project
|
23 |
+
|
24 |
+
Args:
|
25 |
+
title ([str]): The title of page which we are adding to the list of apps
|
26 |
+
|
27 |
+
func: Python function to render this page in Streamlit
|
28 |
+
"""
|
29 |
+
|
30 |
+
self.pages.append(
|
31 |
+
{
|
32 |
+
"title": title,
|
33 |
+
"icon": icon,
|
34 |
+
"function": func
|
35 |
+
}
|
36 |
+
)
|
37 |
+
|
38 |
+
def run(self):
|
39 |
+
# Drodown to select the page to run
|
40 |
+
st.markdown("""
|
41 |
+
<style>
|
42 |
+
section[data-testid="stSidebar"] > div:first-of-type {
|
43 |
+
background-color: var(--secondary-background-color);
|
44 |
+
background: var(--secondary-background-color);
|
45 |
+
width: 250px;
|
46 |
+
padding: 0rem 0;
|
47 |
+
box-shadow: -2rem 0px 2rem 2rem rgba(0,0,0,0.16);
|
48 |
+
}
|
49 |
+
section[aria-expanded="true"] > div:nth-of-type(2) {
|
50 |
+
display: none;
|
51 |
+
}
|
52 |
+
.main > div:first-of-type {
|
53 |
+
padding: 1rem 0;
|
54 |
+
}
|
55 |
+
</style>
|
56 |
+
""", unsafe_allow_html=True)
|
57 |
+
|
58 |
+
with st.sidebar:
|
59 |
+
selected = option_menu("OCR Demo",
|
60 |
+
[page["title"] for page in self.pages],
|
61 |
+
icons=[page["icon"] for page in self.pages],
|
62 |
+
menu_icon="app-indicator", default_index=0)
|
63 |
+
|
64 |
+
# Run the selected page
|
65 |
+
for index, item in enumerate(self.pages):
|
66 |
+
if item["title"] == selected:
|
67 |
+
self.pages[index]["function"]()
|
68 |
+
break
|
ocr.png
ADDED
![]() |
packages.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
libgl1
|
2 |
+
cmake
|
3 |
+
libssl-dev
|
4 |
+
tesseract-ocr-all
|
requirements.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://github.com/streamlit/streamlit/issues/5315
|
2 |
+
easyocr
|
3 |
+
streamlit
|
4 |
+
altair<5
|
5 |
+
opencv-python-headless==4.5.5.64
|
6 |
+
torch==1.12.1
|
7 |
+
torchvision==0.13.1
|
8 |
+
Pillow
|
9 |
+
mmcv-full --no-binary mmcv-full
|
10 |
+
mmdet==2.28.2
|
11 |
+
mmocr==0.6.3
|
12 |
+
paddleocr==2.6
|
13 |
+
paddlepaddle==2.4.0rc0
|
14 |
+
numpy==1.23.4
|
15 |
+
mycolorpy==1.5.1
|
16 |
+
plotly==5.10.0
|
17 |
+
plotly-express==0.4.1
|
18 |
+
pytesseract==0.3.10
|
19 |
+
streamlit_option_menu
|
tmp_311715319_2060358020840543_6779133249018943291_n.jpg
ADDED
![]() |
tmp_I3.jpg
ADDED
![]() |
tmp_img_demo_1.jpg
ADDED
![]() |
tmp_img_demo_2.jpg
ADDED
![]() |