Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from annotated_text import annotated_text
|
3 |
from io import StringIO
|
4 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
@@ -47,23 +48,23 @@ def init_qa_pipeline():
|
|
47 |
|
48 |
def get_formatted_text_for_annotation(output):
|
49 |
colour_map = {'Coreference': '#29D93B',
|
50 |
-
'Severity':'#
|
51 |
-
'Sex': '#
|
52 |
-
'Sign_symptom': '#
|
53 |
'Detailed_description': '#078E8B',
|
54 |
-
'Date': '#
|
55 |
-
'History': '#
|
56 |
-
'Medication': '#
|
57 |
-
'Therapeutic_procedure': '#
|
58 |
-
'Age': '#
|
59 |
-
'Subject': '#
|
60 |
-
'Biological_structure': '#
|
61 |
-
'Activity': '#
|
62 |
-
'Lab_value': '#
|
63 |
-
'Family_history': '#
|
64 |
-
'Diagnostic_procedure': '#
|
65 |
-
'Other_event': '#
|
66 |
-
'Occupation': '#
|
67 |
|
68 |
annotated_texts = []
|
69 |
next_index = 0
|
@@ -223,16 +224,25 @@ if selected_menu == "Upload Document":
|
|
223 |
if uploaded_file is not None:
|
224 |
ocr_text = get_text_from_ocr_engine()
|
225 |
st.write("Upload Successful")
|
|
|
226 |
elif selected_menu == "Extract Text":
|
227 |
-
st.
|
|
|
|
|
|
|
228 |
elif selected_menu == "Summarize Document":
|
229 |
paragraphs= get_paragraphs_for_summaries()
|
230 |
|
231 |
-
with st.spinner("
|
232 |
tags_found = ["Injury Details", "Past Medical Conditions", "Injury Management Plan", "GP Correspondence"]
|
|
|
233 |
st.write("This document is about:")
|
234 |
-
st.
|
235 |
st.markdown("""---""")
|
|
|
|
|
|
|
|
|
236 |
for text in paragraphs:
|
237 |
summary_text = pipeline_summarization(text, max_length=130, min_length=30, do_sample=False)
|
238 |
# Show output
|
|
|
1 |
import streamlit as st
|
2 |
+
import time
|
3 |
from annotated_text import annotated_text
|
4 |
from io import StringIO
|
5 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
|
|
48 |
|
49 |
def get_formatted_text_for_annotation(output):
|
50 |
colour_map = {'Coreference': '#29D93B',
|
51 |
+
'Severity':'#FCF3CF',
|
52 |
+
'Sex': '#E9F7EF',
|
53 |
+
'Sign_symptom': '#EAF2F8',
|
54 |
'Detailed_description': '#078E8B',
|
55 |
+
'Date': '#F5EEF8',
|
56 |
+
'History': '#FDEDEC',
|
57 |
+
'Medication': '#F4F6F6',
|
58 |
+
'Therapeutic_procedure': '#A3E4D7',
|
59 |
+
'Age': '#85C1E9',
|
60 |
+
'Subject': '#D7BDE2',
|
61 |
+
'Biological_structure': '#AF7AC5',
|
62 |
+
'Activity': '#B2BABB',
|
63 |
+
'Lab_value': '#E6B0AA',
|
64 |
+
'Family_history': '#2471A3',
|
65 |
+
'Diagnostic_procedure': '#CCD1D1',
|
66 |
+
'Other_event': '#239B56',
|
67 |
+
'Occupation': '#B3B6B7'}
|
68 |
|
69 |
annotated_texts = []
|
70 |
next_index = 0
|
|
|
224 |
if uploaded_file is not None:
|
225 |
ocr_text = get_text_from_ocr_engine()
|
226 |
st.write("Upload Successful")
|
227 |
+
|
228 |
elif selected_menu == "Extract Text":
|
229 |
+
with st.spinner("Extracting Text..."):
|
230 |
+
time.sleep(6)
|
231 |
+
st.write(get_text_from_ocr_engine())
|
232 |
+
|
233 |
elif selected_menu == "Summarize Document":
|
234 |
paragraphs= get_paragraphs_for_summaries()
|
235 |
|
236 |
+
with st.spinner("Finding Topics..."):
|
237 |
tags_found = ["Injury Details", "Past Medical Conditions", "Injury Management Plan", "GP Correspondence"]
|
238 |
+
time.sleep(5)
|
239 |
st.write("This document is about:")
|
240 |
+
st.markdown(";".join(["#" + tag + " " for tag in tags_found])**)
|
241 |
st.markdown("""---""")
|
242 |
+
|
243 |
+
with st.spinner("Summarizing Document..."):
|
244 |
+
|
245 |
+
|
246 |
for text in paragraphs:
|
247 |
summary_text = pipeline_summarization(text, max_length=130, min_length=30, do_sample=False)
|
248 |
# Show output
|