wzkariampuzha commited on
Commit
31ca6c1
1 Parent(s): 33ca54e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -61,7 +61,11 @@ def load_models():
61
  NER_pipeline, entity_classes = extract_abs.init_NER_pipeline()
62
  GARD_dict, max_length = extract_abs.load_GARD_diseases()
63
  return classify_tokenizer, classify_model, NER_pipeline, entity_classes, GARD_dict, max_length
64
-
 
 
 
 
65
  with st.spinner('Loading Epidemiology Models and Dependencies...'):
66
  classify_model_vars, NER_pipeline, entity_classes, GARD_dict, max_length = load_models_experimental()
67
  #classify_tokenizer, classify_model, NER_pipeline, entity_classes, GARD_dict, max_length = load_models()
@@ -81,6 +85,13 @@ if disease_or_gard_id:
81
  extract_diseases,GARD_dict, max_length,
82
  classify_model_vars)
83
  st.dataframe(df)
 
 
 
 
 
 
 
84
  #st.dataframe(data=None, width=None, height=None)
85
 
86
  # st.code(body, language="python")
 
61
  NER_pipeline, entity_classes = extract_abs.init_NER_pipeline()
62
  GARD_dict, max_length = extract_abs.load_GARD_diseases()
63
  return classify_tokenizer, classify_model, NER_pipeline, entity_classes, GARD_dict, max_length
64
+
65
+ def convert_df(df):
66
+ # IMPORTANT: Cache the conversion to prevent computation on every rerun
67
+ return df.to_csv().encode('utf-8')
68
+
69
  with st.spinner('Loading Epidemiology Models and Dependencies...'):
70
  classify_model_vars, NER_pipeline, entity_classes, GARD_dict, max_length = load_models_experimental()
71
  #classify_tokenizer, classify_model, NER_pipeline, entity_classes, GARD_dict, max_length = load_models()
 
85
  extract_diseases,GARD_dict, max_length,
86
  classify_model_vars)
87
  st.dataframe(df)
88
+ csv = convert_df(df)
89
+ st.download_button(
90
+ label="Download epidemiology results for "+disease_or_gard_id+" as CSV",
91
+ data=csv,
92
+ file_name=disease_or_gard_id+'.csv',
93
+ mime='text/csv',
94
+ )
95
  #st.dataframe(data=None, width=None, height=None)
96
 
97
  # st.code(body, language="python")