Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,25 +2,18 @@ import numpy as np
|
|
| 2 |
import gradio as gr
|
| 3 |
import MOD_V_TCOND_Z4_008C
|
| 4 |
|
| 5 |
-
# Adicionando um tema leve para deixar mais elegante
|
| 6 |
-
#with gr.Blocks(theme=gr.themes.Soft()) as bloco:
|
| 7 |
with gr.Blocks() as bloco:
|
| 8 |
with gr.Tabs():
|
| 9 |
with gr.TabItem(MOD_V_TCOND_Z4_008C.title):
|
| 10 |
-
|
| 11 |
-
# 1. Renderiza apenas o cabeçalho no topo
|
| 12 |
gr.Markdown(MOD_V_TCOND_Z4_008C.header_text)
|
| 13 |
|
| 14 |
-
# 2. A MÁGICA AQUI: O Accordion esconde a tabela gigante por padrão
|
| 15 |
with gr.Accordion("📋 Consultar Tabela de Infraestrutura (Clique para expandir)", open=False):
|
| 16 |
gr.Markdown(MOD_V_TCOND_Z4_008C.tabela_infra)
|
| 17 |
|
| 18 |
-
gr.HTML("<br>")
|
| 19 |
|
| 20 |
-
# 3. Organizando em DUAS COLUNAS: Esquerda (Inputs) e Direita (Outputs)
|
| 21 |
with gr.Row():
|
| 22 |
-
|
| 23 |
-
# --- COLUNA DA ESQUERDA: INPUTS ---
|
| 24 |
with gr.Column(scale=1, variant="panel"):
|
| 25 |
gr.Markdown("### ⚙️ Parâmetros de Entrada")
|
| 26 |
ATPRIV = gr.Number(value=168., label='Área de Terreno Privativa')
|
|
@@ -28,7 +21,6 @@ with gr.Blocks() as bloco:
|
|
| 28 |
INFRA = gr.Number(value=5, label='Infraestrutura')
|
| 29 |
|
| 30 |
gr.Markdown("#### Anos de Referência (Carga Geral)")
|
| 31 |
-
# Dividindo os anos em duas colunas internas para economizar altura
|
| 32 |
with gr.Row():
|
| 33 |
with gr.Column():
|
| 34 |
ANO_2020 = gr.Checkbox(value=False, label='Ano 2020 (Carga 2021)')
|
|
@@ -41,14 +33,11 @@ with gr.Blocks() as bloco:
|
|
| 41 |
|
| 42 |
text_button = gr.Button("🚀 Calcular Valor", variant="primary")
|
| 43 |
|
| 44 |
-
# --- COLUNA
|
| 45 |
with gr.Column(scale=1):
|
| 46 |
gr.Markdown("### 📊 Resultados da Inferência")
|
| 47 |
-
|
| 48 |
-
# Usando Textbox no lugar de TextArea pois são resultados curtos (1 linha)
|
| 49 |
out_valor = gr.Textbox(label="Valor do imóvel (R$/m²)", text_align="center")
|
| 50 |
|
| 51 |
-
# Colocando os limites lado a lado
|
| 52 |
with gr.Row():
|
| 53 |
out_lim_inf = gr.Textbox(label="Limite Inferior do IC")
|
| 54 |
out_perc_inf = gr.Textbox(label="% Limite Inferior")
|
|
@@ -57,12 +46,21 @@ with gr.Blocks() as bloco:
|
|
| 57 |
out_lim_sup = gr.Textbox(label="Limite Superior do IC")
|
| 58 |
out_perc_sup = gr.Textbox(label="% Limite Superior")
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
# Ação
|
| 63 |
inputs_list =[ANO_2020, ANO_2021, ANO_2022, ANO_2023, ANO_2024, ANO_2025, RH, INFRA, ATPRIV]
|
| 64 |
outputs_list =[out_valor, out_lim_inf, out_perc_inf, out_lim_sup, out_perc_sup, out_grafico]
|
| 65 |
-
|
| 66 |
text_button.click(MOD_V_TCOND_Z4_008C.execute, inputs=inputs_list, outputs=outputs_list)
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
bloco.launch()
|
|
|
|
| 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 |
|
|
|
|
| 10 |
with gr.Accordion("📋 Consultar Tabela de Infraestrutura (Clique para expandir)", open=False):
|
| 11 |
gr.Markdown(MOD_V_TCOND_Z4_008C.tabela_infra)
|
| 12 |
|
| 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')
|
|
|
|
| 21 |
INFRA = gr.Number(value=5, label='Infraestrutura')
|
| 22 |
|
| 23 |
gr.Markdown("#### Anos de Referência (Carga Geral)")
|
|
|
|
| 24 |
with gr.Row():
|
| 25 |
with gr.Column():
|
| 26 |
ANO_2020 = gr.Checkbox(value=False, label='Ano 2020 (Carga 2021)')
|
|
|
|
| 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 da Inferência")
|
|
|
|
|
|
|
| 39 |
out_valor = gr.Textbox(label="Valor do imóvel (R$/m²)", text_align="center")
|
| 40 |
|
|
|
|
| 41 |
with gr.Row():
|
| 42 |
out_lim_inf = gr.Textbox(label="Limite Inferior do IC")
|
| 43 |
out_perc_inf = gr.Textbox(label="% Limite Inferior")
|
|
|
|
| 46 |
out_lim_sup = gr.Textbox(label="Limite Superior do IC")
|
| 47 |
out_perc_sup = gr.Textbox(label="% Limite Superior")
|
| 48 |
|
| 49 |
+
# Importante: type="filepath" garante que o caminho da imagem vá pro gerador de PDF
|
| 50 |
+
out_grafico = gr.Image(label="Gráfico de Dispersão", type="filepath")
|
| 51 |
+
|
| 52 |
+
# ---- SESSÃO DE PDF AQUI ----
|
| 53 |
+
gr.Markdown("### 🖨️ Exportação")
|
| 54 |
+
btn_pdf = gr.Button("📄 Gerar Relatório em PDF", variant="secondary")
|
| 55 |
+
out_pdf = gr.File(label="Clique para Baixar o Relatório", visible=False)
|
| 56 |
|
| 57 |
+
# Ação 1: Calcular os valores
|
| 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 |
+
# Ação 2: Gerar PDF a partir das entradas e saídas preenchidas
|
| 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()
|