Spaces:
Sleeping
Sleeping
Eachan Johnson
commited on
Commit
·
11292cd
1
Parent(s):
4d2787c
Add plotting on load
Browse files
app.py
CHANGED
@@ -298,32 +298,32 @@ with gr.Blocks() as demo:
|
|
298 |
|
299 |
"""
|
300 |
)
|
|
|
301 |
with gr.Row():
|
302 |
param_sliders = [
|
303 |
gr.Slider(label="Pool size", info="Effective number of antibiotic classes being sampled by drug discovery",
|
304 |
-
value=
|
305 |
gr.Slider(label="Maximal discovery rate", info="Effective number of samples from the pool per year",
|
306 |
-
value=1., minimum=0., maximum=10., scale=10),
|
307 |
gr.Slider(label="Discovery lag", info="Time to maximum discovery rate",
|
308 |
-
value=25., minimum=0., maximum=100., scale=10),
|
309 |
gr.Slider(label="Resistance-free half-life", info="Relative to start of clinical use",
|
310 |
-
value=30., minimum=0., maximum=50., scale=10),
|
311 |
]
|
312 |
refresh_button = gr.Button("Update plot", scale=6)
|
313 |
fit_button = gr.Button("Fit parameters!", scale=6)
|
314 |
|
315 |
-
|
316 |
fit_message = gr.Markdown(parameter_msg, inputs=param_sliders)
|
317 |
plot = gr.Plot(
|
318 |
label="Model fit",
|
319 |
scale=4,
|
320 |
)
|
321 |
gr.on(
|
322 |
-
triggers=[s.
|
323 |
fn=lambda *x: plot_data_altair(df=data, params=x),
|
324 |
inputs=param_sliders,
|
325 |
outputs=plot,
|
326 |
-
trigger_mode="once",
|
327 |
)
|
328 |
|
329 |
with gr.Tab("Forecasting the future!"):
|
@@ -365,7 +365,6 @@ with gr.Blocks() as demo:
|
|
365 |
fn=lambda *x: plot_data_forecast_altair(df=data, params=x),
|
366 |
inputs=param_and_forecast_sliders,
|
367 |
outputs=forecast,
|
368 |
-
trigger_mode="once",
|
369 |
)
|
370 |
|
371 |
(fit_button
|
@@ -373,4 +372,6 @@ with gr.Blocks() as demo:
|
|
373 |
.then(lambda *x: plot_data_altair(df=data, params=x),inputs=param_sliders, outputs=plot)
|
374 |
.then(lambda *x: plot_data_forecast_altair(df=data, params=x),inputs=param_and_forecast_sliders, outputs=forecast))
|
375 |
|
|
|
|
|
376 |
demo.launch(share=True)
|
|
|
298 |
|
299 |
"""
|
300 |
)
|
301 |
+
|
302 |
with gr.Row():
|
303 |
param_sliders = [
|
304 |
gr.Slider(label="Pool size", info="Effective number of antibiotic classes being sampled by drug discovery",
|
305 |
+
value=30., minimum=0., maximum=100., step=.5, scale=10),
|
306 |
gr.Slider(label="Maximal discovery rate", info="Effective number of samples from the pool per year",
|
307 |
+
value=1., minimum=0., maximum=10., step=.1, scale=10),
|
308 |
gr.Slider(label="Discovery lag", info="Time to maximum discovery rate",
|
309 |
+
value=25., minimum=0., maximum=100., step=.5, scale=10),
|
310 |
gr.Slider(label="Resistance-free half-life", info="Relative to start of clinical use",
|
311 |
+
value=30., minimum=0., maximum=50., step=.2, scale=10),
|
312 |
]
|
313 |
refresh_button = gr.Button("Update plot", scale=6)
|
314 |
fit_button = gr.Button("Fit parameters!", scale=6)
|
315 |
|
316 |
+
|
317 |
fit_message = gr.Markdown(parameter_msg, inputs=param_sliders)
|
318 |
plot = gr.Plot(
|
319 |
label="Model fit",
|
320 |
scale=4,
|
321 |
)
|
322 |
gr.on(
|
323 |
+
triggers=[s.change for s in param_sliders] + [refresh_button.click],
|
324 |
fn=lambda *x: plot_data_altair(df=data, params=x),
|
325 |
inputs=param_sliders,
|
326 |
outputs=plot,
|
|
|
327 |
)
|
328 |
|
329 |
with gr.Tab("Forecasting the future!"):
|
|
|
365 |
fn=lambda *x: plot_data_forecast_altair(df=data, params=x),
|
366 |
inputs=param_and_forecast_sliders,
|
367 |
outputs=forecast,
|
|
|
368 |
)
|
369 |
|
370 |
(fit_button
|
|
|
372 |
.then(lambda *x: plot_data_altair(df=data, params=x),inputs=param_sliders, outputs=plot)
|
373 |
.then(lambda *x: plot_data_forecast_altair(df=data, params=x),inputs=param_and_forecast_sliders, outputs=forecast))
|
374 |
|
375 |
+
(demo.load(lambda *x: plot_data_altair(df=data, params=x),inputs=param_sliders, outputs=plot).then(lambda *x: plot_data_forecast_altair(df=data, params=x),inputs=param_and_forecast_sliders, outputs=forecast))
|
376 |
+
|
377 |
demo.launch(share=True)
|