Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import numpy as np
|
| 2 |
import gradio as gr
|
| 3 |
import MOD_V_TCOND_Z4_008C
|
|
|
|
| 4 |
|
| 5 |
-
with gr.Blocks() as bloco:
|
| 6 |
with gr.Tabs():
|
|
|
|
| 7 |
with gr.TabItem(MOD_V_TCOND_Z4_008C.title):
|
| 8 |
gr.Markdown(MOD_V_TCOND_Z4_008C.header_text)
|
| 9 |
|
|
@@ -13,7 +15,6 @@ with gr.Blocks() as bloco:
|
|
| 13 |
gr.HTML("<br>")
|
| 14 |
|
| 15 |
with gr.Row():
|
| 16 |
-
# --- COLUNA ESQUERDA: INPUTS ---
|
| 17 |
with gr.Column(scale=1, variant="panel"):
|
| 18 |
gr.Markdown("### ⚙️ Parâmetros de Entrada")
|
| 19 |
ATPRIV = gr.Number(value=168., label='Área de Terreno Privativa')
|
|
@@ -23,44 +24,42 @@ with gr.Blocks() as bloco:
|
|
| 23 |
gr.Markdown("#### Anos de Referência")
|
| 24 |
with gr.Row():
|
| 25 |
with gr.Column():
|
| 26 |
-
ANO_2020 = gr.Checkbox(value=False, label='
|
| 27 |
-
ANO_2021 = gr.Checkbox(value=False, label='
|
| 28 |
-
ANO_2022 = gr.Checkbox(value=False, label='
|
| 29 |
with gr.Column():
|
| 30 |
-
ANO_2023 = gr.Checkbox(value=False, label='
|
| 31 |
-
ANO_2024 = gr.Checkbox(value=False, label='
|
| 32 |
-
ANO_2025 = gr.Checkbox(value=True, label='
|
| 33 |
|
| 34 |
text_button = gr.Button("🚀 Calcular Valor", variant="primary")
|
| 35 |
|
| 36 |
-
# --- COLUNA DIREITA: OUTPUTS E EXPORTAÇÃO ---
|
| 37 |
with gr.Column(scale=1):
|
| 38 |
-
gr.Markdown("### 📊 Resultados
|
| 39 |
-
out_valor = gr.Textbox(label="Valor
|
| 40 |
-
|
| 41 |
with gr.Row():
|
| 42 |
-
out_lim_inf = gr.Textbox(label="Limite Inferior
|
| 43 |
-
out_perc_inf = gr.Textbox(label="%
|
| 44 |
-
|
| 45 |
with gr.Row():
|
| 46 |
-
out_lim_sup = gr.Textbox(label="Limite Superior
|
| 47 |
-
out_perc_sup = gr.Textbox(label="%
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# ---- SESSÃO DE PDF AQUI ----
|
| 53 |
gr.Markdown("### 🖨️ Exportação")
|
| 54 |
-
btn_pdf = gr.Button("📄 Gerar
|
| 55 |
-
out_pdf = gr.File(label="
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
inputs_list =[ANO_2020, ANO_2021, ANO_2022, ANO_2023, ANO_2024, ANO_2025, RH, INFRA, ATPRIV]
|
| 59 |
-
outputs_list =[out_valor, out_lim_inf, out_perc_inf, out_lim_sup, out_perc_sup, out_grafico]
|
| 60 |
text_button.click(MOD_V_TCOND_Z4_008C.execute, inputs=inputs_list, outputs=outputs_list)
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
pdf_inputs = inputs_list + outputs_list # Junta as duas listas de componentes
|
| 64 |
btn_pdf.click(MOD_V_TCOND_Z4_008C.gerar_pdf_relatorio, inputs=pdf_inputs, outputs=out_pdf)
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
bloco.launch()
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import gradio as gr
|
| 3 |
import MOD_V_TCOND_Z4_008C
|
| 4 |
+
import terrenos_2026 # Importa o arquivo ajustado
|
| 5 |
|
| 6 |
+
with gr.Blocks(title="Modelos Territoriais") as bloco:
|
| 7 |
with gr.Tabs():
|
| 8 |
+
# --- ABA 1: MODELO EXISTENTE ---
|
| 9 |
with gr.TabItem(MOD_V_TCOND_Z4_008C.title):
|
| 10 |
gr.Markdown(MOD_V_TCOND_Z4_008C.header_text)
|
| 11 |
|
|
|
|
| 15 |
gr.HTML("<br>")
|
| 16 |
|
| 17 |
with gr.Row():
|
|
|
|
| 18 |
with gr.Column(scale=1, variant="panel"):
|
| 19 |
gr.Markdown("### ⚙️ Parâmetros de Entrada")
|
| 20 |
ATPRIV = gr.Number(value=168., label='Área de Terreno Privativa')
|
|
|
|
| 24 |
gr.Markdown("#### Anos de Referência")
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Column():
|
| 27 |
+
ANO_2020 = gr.Checkbox(value=False, label='2020')
|
| 28 |
+
ANO_2021 = gr.Checkbox(value=False, label='2021')
|
| 29 |
+
ANO_2022 = gr.Checkbox(value=False, label='2022')
|
| 30 |
with gr.Column():
|
| 31 |
+
ANO_2023 = gr.Checkbox(value=False, label='2023')
|
| 32 |
+
ANO_2024 = gr.Checkbox(value=False, label='2024')
|
| 33 |
+
ANO_2025 = gr.Checkbox(value=True, label='2025')
|
| 34 |
|
| 35 |
text_button = gr.Button("🚀 Calcular Valor", variant="primary")
|
| 36 |
|
|
|
|
| 37 |
with gr.Column(scale=1):
|
| 38 |
+
gr.Markdown("### 📊 Resultados")
|
| 39 |
+
out_valor = gr.Textbox(label="Valor (R$/m²)", text_align="center")
|
|
|
|
| 40 |
with gr.Row():
|
| 41 |
+
out_lim_inf = gr.Textbox(label="Limite Inferior")
|
| 42 |
+
out_perc_inf = gr.Textbox(label="% Inf")
|
|
|
|
| 43 |
with gr.Row():
|
| 44 |
+
out_lim_sup = gr.Textbox(label="Limite Superior")
|
| 45 |
+
out_perc_sup = gr.Textbox(label="% Sup")
|
| 46 |
+
|
| 47 |
+
out_grafico = gr.Image(label="Gráfico", type="filepath")
|
| 48 |
+
|
|
|
|
|
|
|
| 49 |
gr.Markdown("### 🖨️ Exportação")
|
| 50 |
+
btn_pdf = gr.Button("📄 Gerar PDF", variant="secondary")
|
| 51 |
+
out_pdf = gr.File(label="Download", visible=False)
|
| 52 |
|
| 53 |
+
# Lógica da Aba 1
|
| 54 |
+
inputs_list = [ANO_2020, ANO_2021, ANO_2022, ANO_2023, ANO_2024, ANO_2025, RH, INFRA, ATPRIV]
|
| 55 |
+
outputs_list = [out_valor, out_lim_inf, out_perc_inf, out_lim_sup, out_perc_sup, out_grafico]
|
| 56 |
text_button.click(MOD_V_TCOND_Z4_008C.execute, inputs=inputs_list, outputs=outputs_list)
|
| 57 |
+
|
| 58 |
+
pdf_inputs = inputs_list + outputs_list
|
|
|
|
| 59 |
btn_pdf.click(MOD_V_TCOND_Z4_008C.gerar_pdf_relatorio, inputs=pdf_inputs, outputs=out_pdf)
|
| 60 |
|
| 61 |
+
# --- ABA 2: MODELO TERRITORIAL 2026 ---
|
| 62 |
+
with gr.TabItem("Avaliação de Terrenos (XGBoost)"):
|
| 63 |
+
terrenos_2026.render_terrenos_interface()
|
| 64 |
+
|
| 65 |
bloco.launch()
|