weightedhuman commited on
Commit
8a6c5b2
1 Parent(s): d33549e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -0
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import streamlit as st
3
+
4
+ col_left, col_middle, col_right= st.columns(3)
5
+ col_middle.title("MedBotDash")
6
+ st.divider()
7
+
8
+ @st.cache_resource()
9
+ def load_model():
10
+ model = pipeline("token-classification",
11
+ model="Clinical-AI-Apollo/Medical-NER",
12
+ aggregation_strategy='simple')
13
+ return model
14
+
15
+ pipe = load_model()
16
+
17
+ st.subheader("Enter Detailed Description of your condition")
18
+ condition = st.text_input("enter the condition")
19
+
20
+ data = pipe(condition)
21
+
22
+ #st.write(data)
23
+
24
+ severity = []
25
+ sign_symptom = []
26
+ biological_structure = []
27
+ age = []
28
+ sex = []
29
+ lab_value = []
30
+
31
+ # Iterate through the data and append words to their respective lists based on entity_group
32
+ for entity in data:
33
+ if entity['entity_group'] == 'SEVERITY':
34
+ severity.append(entity['word'])
35
+ elif entity['entity_group'] == 'SIGN_SYMPTOM':
36
+ sign_symptom.append(entity['word'])
37
+ elif entity['entity_group'] == 'BIOLOGICAL_STRUCTURE':
38
+ biological_structure.append(entity['word'])
39
+ elif entity['entity_group'] == 'AGE':
40
+ age.append(entity['word'])
41
+ elif entity['entity_group'] == 'SEX':
42
+ sex.append(entity['word'])
43
+ elif entity['entity_group'] == 'LAB_VALUE':
44
+ lab_value.append(entity['word'])
45
+
46
+ col1, col2= st.columns(2)
47
+ col1.metric("Age", age[0] if age else 'NA')
48
+ col2.metric("Sex", sex[0] if sex else 'NA')
49
+
50
+ st.divider()
51
+
52
+ sign_symptom = set(sign_symptom)
53
+ severity = set(severity)
54
+ biological_structure = set(biological_structure)
55
+ age = set(age)
56
+ sex = set(age)
57
+ lab_value = set(lab_value)
58
+
59
+ tab1, tab2, tab3 = st.tabs(["Signs", "Biological Structure", "Severity"])
60
+ #st.subheader("Signs")
61
+
62
+ with tab1:
63
+ for sign in sign_symptom:
64
+ st.text(sign)
65
+
66
+ #st.subheader("Severity")
67
+
68
+ with tab2:
69
+ for bio in biological_structure:
70
+ st.text(bio)
71
+
72
+ with tab3:
73
+ for severity in severity:
74
+ st.text(severity)
75
+
76
+ #st.subheader("Biological Structure")
77
+
78
+
79
+