Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1376,22 +1376,29 @@ def create_factor_inputs(num_factors, existing_factors=None):
|
|
| 1376 |
with gr.Column():
|
| 1377 |
for i in range(num_factors):
|
| 1378 |
factor_data = existing_factors[i] if i < len(existing_factors) else {'name': f'Factor_{i+1}', 'low': 0.0, 'high': 10.0}
|
| 1379 |
-
with gr.
|
| 1380 |
-
|
| 1381 |
-
|
| 1382 |
-
|
| 1383 |
-
|
| 1384 |
-
|
| 1385 |
-
|
| 1386 |
-
|
| 1387 |
-
|
| 1388 |
-
|
| 1389 |
-
|
| 1390 |
-
|
| 1391 |
-
|
| 1392 |
-
|
| 1393 |
-
|
| 1394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1395 |
factor_components.extend([factor_name, low_level, high_level])
|
| 1396 |
return factor_components
|
| 1397 |
def update_factor_ui(num_factors, existing_factors=None):
|
|
@@ -1680,11 +1687,13 @@ def create_gradio_interface():
|
|
| 1680 |
all_figures_state = gr.State([])
|
| 1681 |
diagnostic_figures_state = gr.State([])
|
| 1682 |
existing_factors_state = gr.State([])
|
|
|
|
| 1683 |
# Pesta帽as principales
|
| 1684 |
with gr.Tabs() as tabs:
|
| 1685 |
# Pesta帽a 1: Configuraci贸n y Carga de Datos
|
| 1686 |
with gr.Tab("1. Configuraci贸n y Carga de Datos", id="tab1"):
|
| 1687 |
gr.Markdown("### 馃摜 Configuraci贸n del Dise帽o Experimental")
|
|
|
|
| 1688 |
# Asistente de progreso
|
| 1689 |
with gr.Row():
|
| 1690 |
progress = gr.Markdown("""
|
|
@@ -1695,6 +1704,8 @@ def create_gradio_interface():
|
|
| 1695 |
<span style="min-width: 70px; text-align: right; color: #666;">20% Completado</span>
|
| 1696 |
</div>
|
| 1697 |
""")
|
|
|
|
|
|
|
| 1698 |
with gr.Row():
|
| 1699 |
num_factors_input = gr.Slider(
|
| 1700 |
minimum=3, maximum=16, value=3, step=1,
|
|
@@ -1783,12 +1794,12 @@ def create_gradio_interface():
|
|
| 1783 |
update_btn.click(
|
| 1784 |
fn=generate_factor_components,
|
| 1785 |
inputs=[num_factors_input, existing_factors_state],
|
| 1786 |
-
outputs=[
|
| 1787 |
)
|
| 1788 |
|
| 1789 |
load_button.click(
|
| 1790 |
fn=load_data,
|
| 1791 |
-
inputs=[num_factors_input,
|
| 1792 |
outputs=[data_output, status_output, data_loaded, existing_factors_state]
|
| 1793 |
).then(
|
| 1794 |
lambda data_loaded: gr.update(interactive=data_loaded),
|
|
@@ -2120,15 +2131,35 @@ def create_gradio_interface():
|
|
| 2120 |
)
|
| 2121 |
|
| 2122 |
# Configuraci贸n de eventos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2123 |
update_btn.click(
|
| 2124 |
fn=generate_factor_components,
|
| 2125 |
inputs=[num_factors_input, existing_factors_state],
|
| 2126 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2127 |
)
|
| 2128 |
|
|
|
|
| 2129 |
load_button.click(
|
| 2130 |
fn=load_data,
|
| 2131 |
-
inputs=[num_factors_input,
|
| 2132 |
outputs=[data_output, status_output, data_loaded, existing_factors_state]
|
| 2133 |
).then(
|
| 2134 |
lambda data_loaded: gr.update(interactive=data_loaded),
|
|
|
|
| 1376 |
with gr.Column():
|
| 1377 |
for i in range(num_factors):
|
| 1378 |
factor_data = existing_factors[i] if i < len(existing_factors) else {'name': f'Factor_{i+1}', 'low': 0.0, 'high': 10.0}
|
| 1379 |
+
with gr.Accordion(f"Factor {i+1}", open=True,
|
| 1380 |
+
elem_classes="factor-accordion") as accordion:
|
| 1381 |
+
with gr.Row(elem_classes="factor-row"):
|
| 1382 |
+
factor_name = gr.Textbox(
|
| 1383 |
+
label=f"Nombre del Factor {i+1}",
|
| 1384 |
+
value=factor_data['name'],
|
| 1385 |
+
interactive=True,
|
| 1386 |
+
elem_classes="factor-input"
|
| 1387 |
+
)
|
| 1388 |
+
with gr.Row(elem_classes="factor-row"):
|
| 1389 |
+
low_level = gr.Number(
|
| 1390 |
+
label=f"Nivel Bajo ({i+1})",
|
| 1391 |
+
value=factor_data['low'],
|
| 1392 |
+
interactive=True,
|
| 1393 |
+
elem_classes="factor-input"
|
| 1394 |
+
)
|
| 1395 |
+
high_level = gr.Number(
|
| 1396 |
+
label=f"Nivel Alto ({i+1})",
|
| 1397 |
+
value=factor_data['high'],
|
| 1398 |
+
interactive=True,
|
| 1399 |
+
elem_classes="factor-input"
|
| 1400 |
+
)
|
| 1401 |
+
|
| 1402 |
factor_components.extend([factor_name, low_level, high_level])
|
| 1403 |
return factor_components
|
| 1404 |
def update_factor_ui(num_factors, existing_factors=None):
|
|
|
|
| 1687 |
all_figures_state = gr.State([])
|
| 1688 |
diagnostic_figures_state = gr.State([])
|
| 1689 |
existing_factors_state = gr.State([])
|
| 1690 |
+
|
| 1691 |
# Pesta帽as principales
|
| 1692 |
with gr.Tabs() as tabs:
|
| 1693 |
# Pesta帽a 1: Configuraci贸n y Carga de Datos
|
| 1694 |
with gr.Tab("1. Configuraci贸n y Carga de Datos", id="tab1"):
|
| 1695 |
gr.Markdown("### 馃摜 Configuraci贸n del Dise帽o Experimental")
|
| 1696 |
+
|
| 1697 |
# Asistente de progreso
|
| 1698 |
with gr.Row():
|
| 1699 |
progress = gr.Markdown("""
|
|
|
|
| 1704 |
<span style="min-width: 70px; text-align: right; color: #666;">20% Completado</span>
|
| 1705 |
</div>
|
| 1706 |
""")
|
| 1707 |
+
|
| 1708 |
+
# N煤mero de factores
|
| 1709 |
with gr.Row():
|
| 1710 |
num_factors_input = gr.Slider(
|
| 1711 |
minimum=3, maximum=16, value=3, step=1,
|
|
|
|
| 1794 |
update_btn.click(
|
| 1795 |
fn=generate_factor_components,
|
| 1796 |
inputs=[num_factors_input, existing_factors_state],
|
| 1797 |
+
outputs=[*factor_components, existing_factors_state]
|
| 1798 |
)
|
| 1799 |
|
| 1800 |
load_button.click(
|
| 1801 |
fn=load_data,
|
| 1802 |
+
inputs=[num_factors_input, *factor_components, y_name_input, data_input, decimal_places],
|
| 1803 |
outputs=[data_output, status_output, data_loaded, existing_factors_state]
|
| 1804 |
).then(
|
| 1805 |
lambda data_loaded: gr.update(interactive=data_loaded),
|
|
|
|
| 2131 |
)
|
| 2132 |
|
| 2133 |
# Configuraci贸n de eventos
|
| 2134 |
+
# Primero, definir los placeholders para los componentes de factores
|
| 2135 |
+
factor_components = []
|
| 2136 |
+
for i in range(48): # 16 factores * 3 componentes = 48
|
| 2137 |
+
if i % 3 == 0:
|
| 2138 |
+
factor_components.append(gr.Textbox(visible=False, label=f"Nombre del Factor {i//3 + 1}"))
|
| 2139 |
+
else:
|
| 2140 |
+
factor_components.append(gr.Number(visible=False, label=f"Nivel {'Bajo' if i % 3 == 1 else 'Alto'} ({i//3 + 1})"))
|
| 2141 |
+
|
| 2142 |
+
# Evento para actualizar los componentes de factores
|
| 2143 |
update_btn.click(
|
| 2144 |
fn=generate_factor_components,
|
| 2145 |
inputs=[num_factors_input, existing_factors_state],
|
| 2146 |
+
outputs=[*factor_components, existing_factors_state]
|
| 2147 |
+
)
|
| 2148 |
+
|
| 2149 |
+
# Actualizar visibilidad de los checkboxes y niveles de factores fijos seg煤n el n煤mero de factores
|
| 2150 |
+
demo.load(
|
| 2151 |
+
fn=lambda num_factors: [
|
| 2152 |
+
gr.update(visible=(i < int(num_factors))) for i in range(16)
|
| 2153 |
+
for _ in range(2) # Para checkboxes y niveles
|
| 2154 |
+
],
|
| 2155 |
+
inputs=num_factors_input,
|
| 2156 |
+
outputs=fixed_factors_checkboxes + fixed_levels_inputs
|
| 2157 |
)
|
| 2158 |
|
| 2159 |
+
# Carga de datos
|
| 2160 |
load_button.click(
|
| 2161 |
fn=load_data,
|
| 2162 |
+
inputs=[num_factors_input, *factor_components, y_name_input, data_input, decimal_places],
|
| 2163 |
outputs=[data_output, status_output, data_loaded, existing_factors_state]
|
| 2164 |
).then(
|
| 2165 |
lambda data_loaded: gr.update(interactive=data_loaded),
|