Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,31 +2,43 @@ import streamlit as st
|
|
2 |
from annotated_text import annotated_text
|
3 |
from io import StringIO
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
uploaded_file = st.file_uploader("Choose a file")
|
28 |
|
|
|
|
|
|
|
|
|
29 |
if uploaded_file is not None:
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
2 |
from annotated_text import annotated_text
|
3 |
from io import StringIO
|
4 |
|
5 |
+
import os
|
6 |
+
os.environ['KMP_DUPLICATE_LIB_OK']='True'
|
7 |
+
|
8 |
+
import plotly.express as px
|
9 |
+
from streamlit_option_menu import option_menu
|
10 |
+
|
11 |
+
st. set_page_config(layout="wide")
|
12 |
+
|
13 |
+
from transformers import pipeline
|
14 |
+
import pandas as pd
|
15 |
+
|
16 |
+
@st.cache(allow_output_mutation = True)
|
17 |
+
def init_text_summarization_model():
|
18 |
+
MODEL = 'facebook/bart-large-cnn'
|
19 |
+
pipe = pipeline("summarization", model=MODEL)
|
20 |
+
return pipe
|
21 |
+
|
22 |
+
@st.cache(allow_output_mutation = True)
|
23 |
+
def init_zsl_topic_classification():
|
24 |
+
MODEL = 'facebook/bart-large-mnli'
|
25 |
+
pipe = pipeline("zero-shot-classification", model=MODEL)
|
26 |
+
template = "This text is about {}."
|
27 |
+
return pipe, template
|
28 |
+
|
29 |
+
# Model initialization
|
30 |
+
pipeline_summarization = init_text_summarization_model()
|
31 |
+
pipeline_zsl, template = init_zsl_topic_classification()
|
32 |
+
|
33 |
+
st.header("Intelligent Document Automation")
|
34 |
+
|
35 |
uploaded_file = st.file_uploader("Choose a file")
|
36 |
|
37 |
+
def get_text_from_ocr_engine(uploaded_file):
|
38 |
+
return "This is a sample text for named entity recognition and other tasks"
|
39 |
+
|
40 |
+
|
41 |
if uploaded_file is not None:
|
42 |
+
ocr_text = get_text_from_ocr_engine(uploaded_file)
|
43 |
+
st.write(ocr_text)
|
44 |
+
|