3v324v23 commited on
Commit
809e7c9
·
1 Parent(s): 2c7bdeb
Files changed (1) hide show
  1. app.py +8 -22
app.py CHANGED
@@ -17,26 +17,10 @@ import torch
17
  import random
18
 
19
  ### Streamlit utitlity functions
20
- def show_pdf(file_path):
21
- with open(file_path, "rb") as f:
22
- base64_pdf = base64.b64encode(f.read()).decode('utf-8')
23
- pdf_display = f"""
24
- <div style="
25
- display: flex;
26
- justify-content: center;
27
- align-items: center;
28
- background-color: white;
29
- ">
30
- <iframe src="data:application/pdf;base64,{base64_pdf}"
31
- width="800"
32
- height="425"
33
- type="application/pdf"
34
- style="background-color: white;"
35
- ></iframe>
36
- </div>
37
- """
38
- st.markdown(pdf_display, unsafe_allow_html=True)
39
-
40
 
41
  def update_multiselect_style():
42
  st.markdown(
@@ -88,7 +72,7 @@ def main():
88
  """)
89
 
90
  # Load the picture of the architecture from the assets folder and disply it (is a pdf file)
91
- show_pdf('assets/main_figure_arxiv.pdf')
92
 
93
  st.markdown("### Setup")
94
  st.markdown("\n Please fill the following fields with the path to the NSRwH and NSR models. Instruction on how to get or \
@@ -250,12 +234,13 @@ def main():
250
  #conditioning = {"symbolic_conditioning": torch.tensor([1,2],device="cuda").long(), "numerical_conditioning": torch.tensor([],device="cuda").float()}
251
 
252
  st.markdown("#### NSR")
253
- do_inference_with_also_nsr = st.checkbox("Tick this if you want to also run the NSR model", True)
254
  if do_inference_with_also_nsr:
255
  nsr = st.text_input("Path to the NSR model", "ControllableNeuralSymbolicRegressionWeights/nsr_200000000_epoch=149.ckpt")
256
 
257
  fit = st.button("Run the model")
258
  if fit:
 
259
  if is_cuda:
260
  fitfunc = return_fitfunc(cfg, metadata, nsrwh, device="cuda")
261
  else:
@@ -282,6 +267,7 @@ def main():
282
 
283
 
284
  if do_inference_with_also_nsr:
 
285
  cfg_nsr = omegaconf.OmegaConf.load(Path("configs/nsr_network_config.yaml"))
286
  cfg_nsr.inference.bfgs.activated = True
287
  cfg_nsr.inference.bfgs.n_restarts=10
 
17
  import random
18
 
19
  ### Streamlit utitlity functions
20
+ def show_png(file):
21
+ with open(file, "rb") as f:
22
+ img = f.read()
23
+ st.image(img, width=700)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  def update_multiselect_style():
26
  st.markdown(
 
72
  """)
73
 
74
  # Load the picture of the architecture from the assets folder and disply it (is a pdf file)
75
+ show_png('assets/main_figure_arxiv.png')
76
 
77
  st.markdown("### Setup")
78
  st.markdown("\n Please fill the following fields with the path to the NSRwH and NSR models. Instruction on how to get or \
 
234
  #conditioning = {"symbolic_conditioning": torch.tensor([1,2],device="cuda").long(), "numerical_conditioning": torch.tensor([],device="cuda").float()}
235
 
236
  st.markdown("#### NSR")
237
+ do_inference_with_also_nsr = st.checkbox("Tick this if you want to also run the NSR model", False)
238
  if do_inference_with_also_nsr:
239
  nsr = st.text_input("Path to the NSR model", "ControllableNeuralSymbolicRegressionWeights/nsr_200000000_epoch=149.ckpt")
240
 
241
  fit = st.button("Run the model")
242
  if fit:
243
+ st.write("Results are being computed, please wait...")
244
  if is_cuda:
245
  fitfunc = return_fitfunc(cfg, metadata, nsrwh, device="cuda")
246
  else:
 
267
 
268
 
269
  if do_inference_with_also_nsr:
270
+ st.write("Results for nsr are being computed, please wait...")
271
  cfg_nsr = omegaconf.OmegaConf.load(Path("configs/nsr_network_config.yaml"))
272
  cfg_nsr.inference.bfgs.activated = True
273
  cfg_nsr.inference.bfgs.n_restarts=10