carisackc commited on
Commit
feef57e
·
1 Parent(s): 7a7a355

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -106
app.py DELETED
@@ -1,106 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import numpy as np
4
- from math import ceil
5
- from collections import Counter
6
- from string import punctuation
7
-
8
- import spacy
9
- from spacy import displacy
10
- import en_ner_bc5cdr_md
11
-
12
- nlp = spacy.load("en_ner_bc5cdr_md")
13
- #nlp = en_core_web_lg.load()
14
-
15
- st.set_page_config(layout='wide')
16
- st.title('Clinical Note Summarization')
17
- st.sidebar.markdown('Using transformer model')
18
-
19
- ## Loading in dataset
20
- #df = pd.read_csv('mtsamples_small.csv',index_col=0)
21
- df = pd.read_csv('shpi_w_rouge21Nov.csv')
22
- df['HADM_ID'] = df['HADM_ID'].astype(str).apply(lambda x: x.replace('.0',''))
23
-
24
- #Renaming column
25
- df.rename(columns={'SUBJECT_ID':'Patient_ID',
26
- 'HADM_ID':'Admission_ID',
27
- 'hpi_input_text':'Original_Text',
28
- 'hpi_reference_summary':'Reference_text'}, inplace = True)
29
-
30
- #data.rename(columns={'gdp':'log(gdp)'}, inplace=True)
31
-
32
- #Filter selection
33
- st.sidebar.header("Search for Patient:")
34
-
35
- patientid = df['Patient_ID']
36
- patient = st.sidebar.selectbox('Select Patient ID:', patientid)
37
- admissionid = df['Admission_ID'].loc[df['Patient_ID'] == patient]
38
- HospitalAdmission = st.sidebar.selectbox('', admissionid)
39
-
40
- # List of Model available
41
- model = st.sidebar.selectbox('Select Model', ('BertSummarizer','BertGPT2','t5seq2eq','t5','gensim','pysummarizer'))
42
-
43
- col3,col4 = st.columns(2)
44
- patientid = col3.write(f"Patient ID: {patient} ")
45
- admissionid =col4.write(f"Admission ID: {HospitalAdmission} ")
46
-
47
- #text = st.text_area('Input Clinical Note here')
48
-
49
- # Query out relevant Clinical notes
50
- original_text = df.query(
51
- "Patient_ID == @patient & Admission_ID == @HospitalAdmission"
52
- )
53
-
54
- original_text2 = original_text['Original_Text'].values
55
-
56
- runtext =st.text_area('Input Clinical Note here:', str(original_text2), height=300)
57
-
58
- reference_text = original_text['Reference_text'].values
59
-
60
- def run_model(input_text):
61
-
62
- if model == "BertSummarizer":
63
- output = original_text['BertSummarizer'].values
64
- st.write('Summary')
65
- st.success(output[0])
66
-
67
- elif model == "BertGPT2":
68
- output = original_text['BertGPT2'].values
69
- st.write('Summary')
70
- st.success(output[0])
71
-
72
-
73
- elif model == "t5seq2eq":
74
- output = original_text['t5seq2eq'].values
75
- st.write('Summary')
76
- st.success(output)
77
-
78
- elif model == "t5":
79
- output = original_text['t5'].values
80
- st.write('Summary')
81
- st.success(output)
82
-
83
- elif model == "gensim":
84
- output = original_text['gensim'].values
85
- st.write('Summary')
86
- st.success(output)
87
-
88
- elif model == "pysummarizer":
89
- output = original_text['pysummarizer'].values
90
- st.write('Summary')
91
- st.success(output)
92
-
93
- if st.button('Summarize'):
94
- run_model(runtext)
95
-
96
- sentences=runtext.split('.')
97
-
98
-
99
- st.text_area('Reference text', str(reference_text))
100
-
101
- if st.button('NER'):
102
- doc = nlp(str(original_text2))
103
- colors = { "DISEASE": "pink","CHEMICAL": "orange"}
104
- options = {"ents": [ "DISEASE", "CHEMICAL"],"colors": colors}
105
- ent_html = displacy.render(doc, style="ent", options=options)
106
- st.markdown(ent_html, unsafe_allow_html=True)