-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (52 loc) · 2.11 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import streamlit as st
import tensorflow as tf
from utils import example_input, make_prediction, make_skimlit_predictions
st.set_page_config(page_title="SkimLit",
page_icon="📄",
layout="wide",
initial_sidebar_state="expanded")
model = tf.keras.models.load_model("/home/aayushranjan/Codes/SkimLit/skimlit_tribrid_model_10percent_20k_pubmed20k_rct/content/skimlit_tribrid_model_10percent_20k_pubmed20k_rct")
col1, col2 = st.columns(2)
with col1:
st.write('#### Enter Abstract Here !!')
abstract=st.text_area(label='', height=50)
if not abstract:
st.warning("Kindly input the abstract in the provided text area or refer to the example below for a sample abstract summary.")
predict= st.button('Extract !')
agree = st.checkbox('Show Example Abstract')
if agree:
st.info(example_input)
def model_prediction():
objective = ''
background = ''
method = ''
conclusion = ''
result = ''
pred, lines = make_prediction(model, abstract)
# lines,pred = make_skimlit_predictions(model, abstract)
for i, line in enumerate(lines):
if pred[i] == 'OBJECTIVE':
objective = objective + line
elif pred[i] == 'BACKGROUND':
background = background + line
elif pred[i] == 'METHODS':
method = method + line
elif pred[i] == 'RESULTS':
result = result + line
elif pred[i] == 'CONCLUSIONS':
conclusion = conclusion + line
return objective, background, method, conclusion, result
if predict:
with st.spinner('Wait for prediction....'):
objective, background, method, conclusion, result = model_prediction()
with col2:
st.markdown(f'### Objective : ')
st.write(f'{objective}')
st.markdown(f'### Background : ')
st.write(f'{background}')
st.markdown(f'### Methods : ')
st.write(f'{method}')
st.markdown(f'### Result : ')
st.write(f'{result}')
st.markdown(f'### Conclusion : ')
st.write(f'{conclusion}')