Update UI.py
Browse files
UI.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
# UI.py
|
| 2 |
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
def create_interface(
|
| 6 |
with gr.Blocks() as demo:
|
| 7 |
-
gr.Markdown("#
|
| 8 |
|
| 9 |
-
file_input = gr.File(label="
|
| 10 |
|
| 11 |
MAX_EQUATIONS = 3
|
| 12 |
biomass_equations = []
|
|
@@ -21,60 +22,60 @@ def create_interface(process_and_plot):
|
|
| 21 |
|
| 22 |
def create_model_inputs(model_name, equations_list, params_list, bounds_list):
|
| 23 |
with gr.Column():
|
| 24 |
-
gr.Markdown(f"### {model_name}
|
| 25 |
for i in range(MAX_EQUATIONS):
|
| 26 |
with gr.Row(visible=(i == 0)) as row:
|
| 27 |
equation_input = gr.Textbox(
|
| 28 |
-
label=f"{model_name}
|
| 29 |
-
placeholder="
|
| 30 |
lines=1,
|
| 31 |
-
value="" if i > 0 else "
|
| 32 |
)
|
| 33 |
params_input = gr.Textbox(
|
| 34 |
-
label=f"{model_name}
|
| 35 |
-
placeholder="
|
| 36 |
lines=1,
|
| 37 |
-
value="" if i > 0 else "
|
| 38 |
)
|
| 39 |
bounds_input = gr.Textbox(
|
| 40 |
-
label=f"{model_name}
|
| 41 |
-
placeholder="(
|
| 42 |
lines=1
|
| 43 |
)
|
| 44 |
equations_list.append((row, equation_input))
|
| 45 |
params_list.append(params_input)
|
| 46 |
bounds_list.append(bounds_input)
|
| 47 |
-
add_btn = gr.Button(f"
|
| 48 |
-
remove_btn = gr.Button(f"
|
| 49 |
return add_btn, remove_btn
|
| 50 |
|
| 51 |
-
with gr.Accordion("
|
| 52 |
with gr.Row():
|
| 53 |
with gr.Column():
|
| 54 |
add_biomass_btn, remove_biomass_btn = create_model_inputs(
|
| 55 |
-
"
|
| 56 |
)
|
| 57 |
with gr.Column():
|
| 58 |
add_substrate_btn, remove_substrate_btn = create_model_inputs(
|
| 59 |
-
"
|
| 60 |
)
|
| 61 |
with gr.Column():
|
| 62 |
add_product_btn, remove_product_btn = create_model_inputs(
|
| 63 |
-
"
|
| 64 |
)
|
| 65 |
|
| 66 |
legend_position = gr.Radio(
|
| 67 |
choices=["upper left", "upper right", "lower left", "lower right", "best"],
|
| 68 |
-
label="
|
| 69 |
value="best"
|
| 70 |
)
|
| 71 |
-
show_legend = gr.Checkbox(label="
|
| 72 |
-
show_params = gr.Checkbox(label="
|
| 73 |
-
simulate_btn = gr.Button("
|
| 74 |
|
| 75 |
with gr.Row():
|
| 76 |
-
output_gallery = gr.Gallery(label="
|
| 77 |
-
analysis_output = gr.Textbox(label="Yi-Coder
|
| 78 |
|
| 79 |
biomass_eq_count = gr.Number(value=1, visible=False)
|
| 80 |
substrate_eq_count = gr.Number(value=1, visible=False)
|
|
@@ -150,4 +151,4 @@ def create_interface(process_and_plot):
|
|
| 150 |
outputs=[output_gallery, analysis_output]
|
| 151 |
)
|
| 152 |
|
| 153 |
-
return demo
|
|
|
|
| 1 |
# UI.py
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from interface import process_and_plot
|
| 5 |
|
| 6 |
+
def create_interface():
|
| 7 |
with gr.Blocks() as demo:
|
| 8 |
+
gr.Markdown("# Aplicaci贸n de Modelado de Bioprocesos con Integraci贸n de Yi-Coder")
|
| 9 |
|
| 10 |
+
file_input = gr.File(label="Subir Archivo Excel")
|
| 11 |
|
| 12 |
MAX_EQUATIONS = 3
|
| 13 |
biomass_equations = []
|
|
|
|
| 22 |
|
| 23 |
def create_model_inputs(model_name, equations_list, params_list, bounds_list):
|
| 24 |
with gr.Column():
|
| 25 |
+
gr.Markdown(f"### Modelos de {model_name}")
|
| 26 |
for i in range(MAX_EQUATIONS):
|
| 27 |
with gr.Row(visible=(i == 0)) as row:
|
| 28 |
equation_input = gr.Textbox(
|
| 29 |
+
label=f"Ecuaci贸n del Modelo {model_name} {i+1}",
|
| 30 |
+
placeholder="Introduce la ecuaci贸n en t茅rminos de t y par谩metros",
|
| 31 |
lines=1,
|
| 32 |
+
value="" if i > 0 else "Ecuaci贸n por defecto"
|
| 33 |
)
|
| 34 |
params_input = gr.Textbox(
|
| 35 |
+
label=f"Par谩metros del Modelo {model_name} {i+1}",
|
| 36 |
+
placeholder="Par谩metros separados por comas",
|
| 37 |
lines=1,
|
| 38 |
+
value="" if i > 0 else "Par谩metros"
|
| 39 |
)
|
| 40 |
bounds_input = gr.Textbox(
|
| 41 |
+
label=f"Limites del Modelo {model_name} {i+1}",
|
| 42 |
+
placeholder="(inferior, superior) para cada par谩metro",
|
| 43 |
lines=1
|
| 44 |
)
|
| 45 |
equations_list.append((row, equation_input))
|
| 46 |
params_list.append(params_input)
|
| 47 |
bounds_list.append(bounds_input)
|
| 48 |
+
add_btn = gr.Button(f"Agregar Ecuaci贸n de {model_name}")
|
| 49 |
+
remove_btn = gr.Button(f"Eliminar Ecuaci贸n de {model_name}")
|
| 50 |
return add_btn, remove_btn
|
| 51 |
|
| 52 |
+
with gr.Accordion("Definici贸n de Modelos", open=True):
|
| 53 |
with gr.Row():
|
| 54 |
with gr.Column():
|
| 55 |
add_biomass_btn, remove_biomass_btn = create_model_inputs(
|
| 56 |
+
"Biomasa", biomass_equations, biomass_params, biomass_bounds
|
| 57 |
)
|
| 58 |
with gr.Column():
|
| 59 |
add_substrate_btn, remove_substrate_btn = create_model_inputs(
|
| 60 |
+
"Sustrato", substrate_equations, substrate_params, substrate_bounds
|
| 61 |
)
|
| 62 |
with gr.Column():
|
| 63 |
add_product_btn, remove_product_btn = create_model_inputs(
|
| 64 |
+
"Producto", product_equations, product_params, product_bounds
|
| 65 |
)
|
| 66 |
|
| 67 |
legend_position = gr.Radio(
|
| 68 |
choices=["upper left", "upper right", "lower left", "lower right", "best"],
|
| 69 |
+
label="Posici贸n de la Leyenda",
|
| 70 |
value="best"
|
| 71 |
)
|
| 72 |
+
show_legend = gr.Checkbox(label="Mostrar Leyenda", value=True)
|
| 73 |
+
show_params = gr.Checkbox(label="Mostrar Par谩metros", value=True)
|
| 74 |
+
simulate_btn = gr.Button("Simular")
|
| 75 |
|
| 76 |
with gr.Row():
|
| 77 |
+
output_gallery = gr.Gallery(label="Resultados", columns=2, height='auto')
|
| 78 |
+
analysis_output = gr.Textbox(label="An谩lisis de Yi-Coder", lines=15)
|
| 79 |
|
| 80 |
biomass_eq_count = gr.Number(value=1, visible=False)
|
| 81 |
substrate_eq_count = gr.Number(value=1, visible=False)
|
|
|
|
| 151 |
outputs=[output_gallery, analysis_output]
|
| 152 |
)
|
| 153 |
|
| 154 |
+
return demo
|