Sasidhar commited on
Commit
d6bb012
·
1 Parent(s): 2d9a7bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -25
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
- # Annotated text example
7
-
8
- Below is an example of how to use the annotated_text function:
9
-
10
-
11
- with st.echo():
12
- annotated_text(
13
- "This ",
14
- ("is", "verb"),
15
- " some ",
16
- ("annotated", "adj"),
17
- ("text", "noun"),
18
- " for those of ",
19
- ("you", "pronoun"),
20
- " who ",
21
- ("like", "verb"),
22
- " this sort of ",
23
- ("thing", "noun"),
24
- "."
25
- )
26
- """
 
 
 
 
 
 
 
 
27
  uploaded_file = st.file_uploader("Choose a file")
28
 
 
 
 
 
29
  if uploaded_file is not None:
30
- # To convert to a string based IO:
31
- stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
32
- st.write(stringio)
 
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
+