Update app.py
Browse files
app.py
CHANGED
@@ -52,8 +52,9 @@ import line_cor
|
|
52 |
import altair as alt
|
53 |
#pytesseract.pytesseract.tesseract_cmd = r"./Tesseract-OCR/tesseract.exe"
|
54 |
from PIL import Image
|
55 |
-
|
56 |
#@st.cache_resource(experimental_allow_widgets=True)
|
|
|
57 |
def read_pdf(file):
|
58 |
# images=pdf2image.convert_from_path(file)
|
59 |
# # print(type(images))
|
@@ -87,8 +88,9 @@ def read_pdf(file):
|
|
87 |
# all_page_text += text + " " #page.extractText()
|
88 |
# return all_page_text
|
89 |
st.title("NLP APPLICATION")
|
90 |
-
|
91 |
#@st.cache_resource(experimental_allow_widgets=True)
|
|
|
92 |
def text_analyzer(my_text):
|
93 |
nlp = spacy.load('en_core_web_sm')
|
94 |
docx = nlp(my_text)
|
@@ -102,8 +104,9 @@ def load_models():
|
|
102 |
model = GPT2LMHeadModel.from_pretrained('gpt2-large')
|
103 |
return tokenizer, model
|
104 |
# Function For Extracting Entities
|
105 |
-
|
106 |
#@st.cache_resource(experimental_allow_widgets=True)
|
|
|
107 |
def entity_analyzer(my_text):
|
108 |
nlp = spacy.load('en_core_web_sm')
|
109 |
docx = nlp(my_text)
|
@@ -125,8 +128,8 @@ def main():
|
|
125 |
st.session_state["photo"]="done"
|
126 |
st.subheader("Please, feed your image/text, features/services will appear automatically!")
|
127 |
message = st.text_input("Type your text here!")
|
128 |
-
camera_photo = st.camera_input("Take a photo, Containing English texts", on_change=change_photo_state)
|
129 |
uploaded_photo = st.file_uploader("Upload your PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
|
|
130 |
if "photo" not in st.session_state:
|
131 |
st.session_state["photo"]="not done"
|
132 |
if st.session_state["photo"]=="done" or message:
|
|
|
52 |
import altair as alt
|
53 |
#pytesseract.pytesseract.tesseract_cmd = r"./Tesseract-OCR/tesseract.exe"
|
54 |
from PIL import Image
|
55 |
+
#@st.experimental_singleton
|
56 |
#@st.cache_resource(experimental_allow_widgets=True)
|
57 |
+
@st.cache_data
|
58 |
def read_pdf(file):
|
59 |
# images=pdf2image.convert_from_path(file)
|
60 |
# # print(type(images))
|
|
|
88 |
# all_page_text += text + " " #page.extractText()
|
89 |
# return all_page_text
|
90 |
st.title("NLP APPLICATION")
|
91 |
+
#@st.experimental_singleton
|
92 |
#@st.cache_resource(experimental_allow_widgets=True)
|
93 |
+
@st.cache_data
|
94 |
def text_analyzer(my_text):
|
95 |
nlp = spacy.load('en_core_web_sm')
|
96 |
docx = nlp(my_text)
|
|
|
104 |
model = GPT2LMHeadModel.from_pretrained('gpt2-large')
|
105 |
return tokenizer, model
|
106 |
# Function For Extracting Entities
|
107 |
+
#@st.experimental_singleton
|
108 |
#@st.cache_resource(experimental_allow_widgets=True)
|
109 |
+
@st.chache_data
|
110 |
def entity_analyzer(my_text):
|
111 |
nlp = spacy.load('en_core_web_sm')
|
112 |
docx = nlp(my_text)
|
|
|
128 |
st.session_state["photo"]="done"
|
129 |
st.subheader("Please, feed your image/text, features/services will appear automatically!")
|
130 |
message = st.text_input("Type your text here!")
|
|
|
131 |
uploaded_photo = st.file_uploader("Upload your PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
132 |
+
camera_photo = st.camera_input("Take a photo, Containing English texts", on_change=change_photo_state)
|
133 |
if "photo" not in st.session_state:
|
134 |
st.session_state["photo"]="not done"
|
135 |
if st.session_state["photo"]=="done" or message:
|