Update src/streamlit_app.py
Browse files- src/streamlit_app.py +182 -109
src/streamlit_app.py
CHANGED
|
@@ -1,76 +1,32 @@
|
|
| 1 |
# src/streamlit_app.py
|
| 2 |
|
| 3 |
import json
|
| 4 |
-
from pathlib import Path
|
| 5 |
import os
|
|
|
|
| 6 |
|
| 7 |
from openai import OpenAI
|
|
|
|
| 8 |
import numpy as np
|
| 9 |
from PIL import Image
|
| 10 |
import streamlit as st
|
| 11 |
import tensorflow as tf
|
| 12 |
|
| 13 |
-
|
| 14 |
# =====================================================================
|
| 15 |
-
# 0.
|
| 16 |
# =====================================================================
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
def consultar_especialista(pergunta: str, contexto: str = "") -> str:
|
| 22 |
-
"""
|
| 23 |
-
Envia a pergunta para o modelo da OpenAI e devolve a resposta em texto.
|
| 24 |
-
"""
|
| 25 |
-
if not OPENAI_API_KEY:
|
| 26 |
-
return (
|
| 27 |
-
"Erro: chave da OpenAI não encontrada nas variáveis de ambiente.\n\n"
|
| 28 |
-
"Verifique em *Settings → Repository secrets* se o secret OPENAI_API_KEY "
|
| 29 |
-
"foi criado corretamente."
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
try:
|
| 33 |
-
mensagens = [
|
| 34 |
-
{
|
| 35 |
-
"role": "system",
|
| 36 |
-
"content": (
|
| 37 |
-
"Você é um especialista em arqueologia e educação. "
|
| 38 |
-
"Explique sempre em linguagem simples, para estudantes do ensino "
|
| 39 |
-
"fundamental e médio. Use exemplos quando fizer sentido."
|
| 40 |
-
),
|
| 41 |
-
}
|
| 42 |
-
]
|
| 43 |
-
|
| 44 |
-
if contexto:
|
| 45 |
-
mensagens.append(
|
| 46 |
-
{
|
| 47 |
-
"role": "system",
|
| 48 |
-
"content": f"Contexto adicional sobre a imagem analisada: {contexto}",
|
| 49 |
-
}
|
| 50 |
-
)
|
| 51 |
-
|
| 52 |
-
mensagens.append({"role": "user", "content": pergunta})
|
| 53 |
-
|
| 54 |
-
resposta = client.chat.completions.create(
|
| 55 |
-
model="gpt-4.1-mini", # pode trocar por outro modelo da OpenAI
|
| 56 |
-
messages=mensagens,
|
| 57 |
-
temperature=0.4,
|
| 58 |
-
max_tokens=700,
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
return resposta.choices[0].message.content.strip()
|
| 62 |
-
|
| 63 |
-
except Exception as e:
|
| 64 |
-
return f"Ocorreu um erro ao consultar o especialista: {e}"
|
| 65 |
|
| 66 |
|
| 67 |
# =====================================================================
|
| 68 |
# 1. Caminhos dos arquivos (sempre relativos ao próprio arquivo)
|
| 69 |
# =====================================================================
|
| 70 |
SRC_DIR = Path(__file__).parent # .../src
|
| 71 |
-
MODEL_PATH = SRC_DIR / "model.tflite"
|
| 72 |
-
LABELS_PATH = SRC_DIR / "labels.txt"
|
| 73 |
-
META_PATH = SRC_DIR / "meta.json"
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
# =====================================================================
|
|
@@ -112,13 +68,8 @@ def load_meta():
|
|
| 112 |
try:
|
| 113 |
with META_PATH.open("r", encoding="utf-8") as f:
|
| 114 |
data = json.load(f)
|
| 115 |
-
|
| 116 |
-
shape = (
|
| 117 |
-
data.get("input_shape")
|
| 118 |
-
or data.get("expected_input_shape")
|
| 119 |
-
or {}
|
| 120 |
-
)
|
| 121 |
-
# exemplos: {"height": 224, "width": 224} ou {"1": 1, "2": 224, ...}
|
| 122 |
if isinstance(shape, dict):
|
| 123 |
h = shape.get("height") or shape.get("1") or 224
|
| 124 |
w = shape.get("width") or shape.get("2") or 224
|
|
@@ -175,7 +126,58 @@ def run_inference(pil_img: Image.Image):
|
|
| 175 |
|
| 176 |
|
| 177 |
# =====================================================================
|
| 178 |
-
# 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
# =====================================================================
|
| 180 |
st.set_page_config(
|
| 181 |
page_title="ArqueoIA",
|
|
@@ -183,10 +185,64 @@ st.set_page_config(
|
|
| 183 |
layout="centered",
|
| 184 |
)
|
| 185 |
|
| 186 |
-
|
| 187 |
-
st.
|
| 188 |
-
"
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
)
|
| 191 |
|
| 192 |
st.markdown("---")
|
|
@@ -200,9 +256,16 @@ else:
|
|
| 200 |
"Os nomes das classes serão mostrados como índices (0, 1, 2, ...)."
|
| 201 |
)
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
uploaded_file = st.file_uploader(
|
| 204 |
-
"
|
| 205 |
type=["jpg", "jpeg", "png"],
|
|
|
|
| 206 |
)
|
| 207 |
|
| 208 |
if uploaded_file is not None:
|
|
@@ -212,10 +275,9 @@ if uploaded_file is not None:
|
|
| 212 |
st.image(pil_img, caption="Imagem enviada", use_container_width=True)
|
| 213 |
st.write("")
|
| 214 |
|
| 215 |
-
with st.spinner("Analisando a imagem com o modelo ArqueoIA..."):
|
| 216 |
probs = run_inference(pil_img)
|
| 217 |
|
| 218 |
-
# garante array 1D
|
| 219 |
probs = np.array(probs).flatten()
|
| 220 |
num_classes = len(probs)
|
| 221 |
idx_max = int(np.argmax(probs))
|
|
@@ -226,63 +288,74 @@ if uploaded_file is not None:
|
|
| 226 |
else:
|
| 227 |
pred_label = f"classe {idx_max}"
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
f"**Classe prevista:** `{pred_label}` \n"
|
| 232 |
-
f"**Confiança aproximada:** `{conf_max * 100:.1f}%`"
|
| 233 |
-
)
|
| 234 |
-
|
| 235 |
-
st.markdown("### Detalhamento das classes")
|
| 236 |
for i in range(num_classes):
|
| 237 |
if labels and i < len(labels):
|
| 238 |
name = labels[i]
|
| 239 |
else:
|
| 240 |
name = f"classe {i}"
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
st.success("Análise concluída com sucesso! ✅")
|
| 244 |
|
| 245 |
-
#
|
| 246 |
-
# 5. Seção: Consultar especialista online (ChatGPT embutido)
|
| 247 |
-
# -------------------------------------------------------------
|
| 248 |
-
st.markdown("---")
|
| 249 |
-
with st.expander("4) Consultar especialista online", expanded=True):
|
| 250 |
-
st.markdown(
|
| 251 |
-
"Use esta área para tirar dúvidas com um especialista virtual em arqueologia. "
|
| 252 |
-
"Ele pode explicar melhor o resultado da análise ou responder perguntas gerais "
|
| 253 |
-
"sobre o tema."
|
| 254 |
-
)
|
| 255 |
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
"
|
| 266 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
)
|
| 268 |
|
| 269 |
-
|
| 270 |
-
"
|
| 271 |
-
value=
|
| 272 |
-
|
| 273 |
)
|
| 274 |
|
| 275 |
-
if st.button("Consultar especialista
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
|
| 282 |
-
|
| 283 |
-
st.write(resposta)
|
| 284 |
|
| 285 |
except Exception as e:
|
|
|
|
| 286 |
st.error(f"Ocorreu um erro ao processar a imagem: {e}")
|
| 287 |
else:
|
|
|
|
| 288 |
st.info("Envie uma imagem para iniciar a análise.")
|
|
|
|
| 1 |
# src/streamlit_app.py
|
| 2 |
|
| 3 |
import json
|
|
|
|
| 4 |
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
|
| 7 |
from openai import OpenAI
|
| 8 |
+
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
import streamlit as st
|
| 12 |
import tensorflow as tf
|
| 13 |
|
|
|
|
| 14 |
# =====================================================================
|
| 15 |
+
# 0. OpenAI client (para "Consultar especialista online")
|
| 16 |
# =====================================================================
|
| 17 |
+
# Lê a chave da OpenAI que está nos "Repository secrets"
|
| 18 |
+
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") # verifique se o nome do secret é esse
|
| 19 |
+
client = OpenAI(api_key=OPENAI_API_KEY) if OPENAI_API_KEY else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
# =====================================================================
|
| 23 |
# 1. Caminhos dos arquivos (sempre relativos ao próprio arquivo)
|
| 24 |
# =====================================================================
|
| 25 |
SRC_DIR = Path(__file__).parent # .../src
|
| 26 |
+
MODEL_PATH = SRC_DIR / "model.tflite" # .../src/model.tflite
|
| 27 |
+
LABELS_PATH = SRC_DIR / "labels.txt" # .../src/labels.txt
|
| 28 |
+
META_PATH = SRC_DIR / "meta.json" # .../src/meta.json
|
| 29 |
+
LOGO_PATH = SRC_DIR / "logo.png" # .../src/logo.png (opcional)
|
| 30 |
|
| 31 |
|
| 32 |
# =====================================================================
|
|
|
|
| 68 |
try:
|
| 69 |
with META_PATH.open("r", encoding="utf-8") as f:
|
| 70 |
data = json.load(f)
|
| 71 |
+
|
| 72 |
+
shape = data.get("input_shape") or data.get("expected_input_shape") or {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
if isinstance(shape, dict):
|
| 74 |
h = shape.get("height") or shape.get("1") or 224
|
| 75 |
w = shape.get("width") or shape.get("2") or 224
|
|
|
|
| 126 |
|
| 127 |
|
| 128 |
# =====================================================================
|
| 129 |
+
# 4. Função para consultar o "especialista online" (ChatGPT)
|
| 130 |
+
# =====================================================================
|
| 131 |
+
def consultar_especialista(pred_label, probs_dict, user_question):
|
| 132 |
+
"""
|
| 133 |
+
Usa o modelo de linguagem para explicar o resultado
|
| 134 |
+
e responder a pergunta do usuário.
|
| 135 |
+
"""
|
| 136 |
+
if client is None or not OPENAI_API_KEY:
|
| 137 |
+
return (
|
| 138 |
+
"A consulta online está desativada neste Space. "
|
| 139 |
+
"Verifique se o secret OPENAI_API_KEY foi configurado corretamente."
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# Monte um contexto simples com o resultado do modelo
|
| 143 |
+
resumo_prob = "\n".join(
|
| 144 |
+
f"- {nome}: {p * 100:.1f}%"
|
| 145 |
+
for nome, p in probs_dict.items()
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
system_prompt = (
|
| 149 |
+
"Você é um arqueólogo experiente ajudando professores e estudantes. "
|
| 150 |
+
"Explique de forma simples, com foco educativo, sem inventar informações."
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
user_prompt = f"""
|
| 154 |
+
Resultado de um classificador de imagens arqueológicas:
|
| 155 |
+
|
| 156 |
+
Classe prevista principal: {pred_label}
|
| 157 |
+
Confiâncias aproximadas:
|
| 158 |
+
{resumo_prob}
|
| 159 |
+
|
| 160 |
+
Pergunta do usuário:
|
| 161 |
+
{user_question}
|
| 162 |
+
"""
|
| 163 |
+
|
| 164 |
+
try:
|
| 165 |
+
response = client.responses.create(
|
| 166 |
+
model="gpt-4.1-mini",
|
| 167 |
+
input=[
|
| 168 |
+
{"role": "system", "content": system_prompt},
|
| 169 |
+
{"role": "user", "content": user_prompt},
|
| 170 |
+
],
|
| 171 |
+
)
|
| 172 |
+
# Resposta de texto
|
| 173 |
+
answer = response.output[0].content[0].text
|
| 174 |
+
return answer
|
| 175 |
+
except Exception as e:
|
| 176 |
+
return f"Ocorreu um erro ao consultar o especialista online: {e}"
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# =====================================================================
|
| 180 |
+
# 5. Interface Streamlit (layout e visual)
|
| 181 |
# =====================================================================
|
| 182 |
st.set_page_config(
|
| 183 |
page_title="ArqueoIA",
|
|
|
|
| 185 |
layout="centered",
|
| 186 |
)
|
| 187 |
|
| 188 |
+
# CSS para deixar o layout mais bonito / centralizado
|
| 189 |
+
st.markdown(
|
| 190 |
+
"""
|
| 191 |
+
<style>
|
| 192 |
+
/* Fundo mais suave */
|
| 193 |
+
.stApp {
|
| 194 |
+
background: radial-gradient(circle at top left, #f5f5ff 0, #ffffff 55%);
|
| 195 |
+
}
|
| 196 |
+
/* Título centralizado */
|
| 197 |
+
.arqueo-title {
|
| 198 |
+
text-align: center;
|
| 199 |
+
font-size: 2.6rem;
|
| 200 |
+
font-weight: 800;
|
| 201 |
+
margin-bottom: 0.2rem;
|
| 202 |
+
}
|
| 203 |
+
.arqueo-subtitle {
|
| 204 |
+
text-align: center;
|
| 205 |
+
font-size: 1.0rem;
|
| 206 |
+
color: #555;
|
| 207 |
+
max-width: 780px;
|
| 208 |
+
margin: 0 auto 1.5rem auto;
|
| 209 |
+
}
|
| 210 |
+
/* Card branco */
|
| 211 |
+
.card {
|
| 212 |
+
background-color: #ffffff;
|
| 213 |
+
border-radius: 18px;
|
| 214 |
+
padding: 1.5rem 1.8rem;
|
| 215 |
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
|
| 216 |
+
margin-bottom: 1.5rem;
|
| 217 |
+
}
|
| 218 |
+
.section-title {
|
| 219 |
+
font-size: 1.2rem;
|
| 220 |
+
font-weight: 700;
|
| 221 |
+
margin-bottom: 0.75rem;
|
| 222 |
+
}
|
| 223 |
+
</style>
|
| 224 |
+
""",
|
| 225 |
+
unsafe_allow_html=True,
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
# ------------------------ Cabeçalho ------------------------
|
| 229 |
+
logo_col, title_col, _ = st.columns([1, 3, 1])
|
| 230 |
+
|
| 231 |
+
with logo_col:
|
| 232 |
+
if LOGO_PATH.exists():
|
| 233 |
+
st.image(str(LOGO_PATH), use_container_width=True)
|
| 234 |
+
|
| 235 |
+
with title_col:
|
| 236 |
+
st.markdown('<div class="arqueo-title">ArqueoIA 🗿</div>', unsafe_allow_html=True)
|
| 237 |
+
|
| 238 |
+
st.markdown(
|
| 239 |
+
"""
|
| 240 |
+
<div class="arqueo-subtitle">
|
| 241 |
+
Sistema de IA para <b>identificar e classificar artefatos arqueológicos</b>
|
| 242 |
+
(osso, cerâmica, moeda, flecha, etc.), usando o modelo treinado no Colab.
|
| 243 |
+
</div>
|
| 244 |
+
""",
|
| 245 |
+
unsafe_allow_html=True,
|
| 246 |
)
|
| 247 |
|
| 248 |
st.markdown("---")
|
|
|
|
| 256 |
"Os nomes das classes serão mostrados como índices (0, 1, 2, ...)."
|
| 257 |
)
|
| 258 |
|
| 259 |
+
# ------------------------ Upload de imagem ------------------------
|
| 260 |
+
st.markdown('<div class="card">', unsafe_allow_html=True)
|
| 261 |
+
|
| 262 |
+
st.markdown('<div class="section-title">1) Envie uma imagem (JPG ou PNG)</div>',
|
| 263 |
+
unsafe_allow_html=True)
|
| 264 |
+
|
| 265 |
uploaded_file = st.file_uploader(
|
| 266 |
+
"Arraste ou selecione uma imagem:",
|
| 267 |
type=["jpg", "jpeg", "png"],
|
| 268 |
+
label_visibility="collapsed",
|
| 269 |
)
|
| 270 |
|
| 271 |
if uploaded_file is not None:
|
|
|
|
| 275 |
st.image(pil_img, caption="Imagem enviada", use_container_width=True)
|
| 276 |
st.write("")
|
| 277 |
|
| 278 |
+
with st.spinner("2) Analisando a imagem com o modelo ArqueoIA..."):
|
| 279 |
probs = run_inference(pil_img)
|
| 280 |
|
|
|
|
| 281 |
probs = np.array(probs).flatten()
|
| 282 |
num_classes = len(probs)
|
| 283 |
idx_max = int(np.argmax(probs))
|
|
|
|
| 288 |
else:
|
| 289 |
pred_label = f"classe {idx_max}"
|
| 290 |
|
| 291 |
+
# Monta dicionário {nome: probabilidade}
|
| 292 |
+
class_probs = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
for i in range(num_classes):
|
| 294 |
if labels and i < len(labels):
|
| 295 |
name = labels[i]
|
| 296 |
else:
|
| 297 |
name = f"classe {i}"
|
| 298 |
+
class_probs[name] = float(probs[i])
|
| 299 |
+
|
| 300 |
+
# ---------------- Resultado principal ----------------
|
| 301 |
+
st.markdown('</div>', unsafe_allow_html=True) # fecha card de upload
|
| 302 |
+
st.markdown('<div class="card">', unsafe_allow_html=True)
|
| 303 |
+
|
| 304 |
+
st.markdown('<div class="section-title">3) Resultado principal</div>',
|
| 305 |
+
unsafe_allow_html=True)
|
| 306 |
+
|
| 307 |
+
st.markdown(
|
| 308 |
+
f"**Classe prevista:** `{pred_label}` \n"
|
| 309 |
+
f"**Confiança aproximada:** `{conf_max * 100:.1f}%`",
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
st.markdown("### Detalhamento das classes")
|
| 313 |
+
|
| 314 |
+
# Barras de progresso para cada classe
|
| 315 |
+
for name, p in class_probs.items():
|
| 316 |
+
st.write(f"**{name}** — {p * 100:.1f}%")
|
| 317 |
+
st.progress(min(max(p, 0.0), 1.0))
|
| 318 |
|
| 319 |
st.success("Análise concluída com sucesso! ✅")
|
| 320 |
|
| 321 |
+
st.markdown('</div>', unsafe_allow_html=True) # fecha card de resultado
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
+
# ---------------- Consultar especialista online ----------------
|
| 324 |
+
st.markdown('<div class="card">', unsafe_allow_html=True)
|
| 325 |
+
st.markdown(
|
| 326 |
+
'<div class="section-title">4) Consultar especialista online (ChatGPT)</div>',
|
| 327 |
+
unsafe_allow_html=True,
|
| 328 |
+
)
|
| 329 |
|
| 330 |
+
if client is None:
|
| 331 |
+
st.info(
|
| 332 |
+
"⚠️ A consulta online está desativada: "
|
| 333 |
+
"secret `OPENAI_API_KEY` não encontrado neste Space."
|
| 334 |
+
)
|
| 335 |
+
else:
|
| 336 |
+
default_question = (
|
| 337 |
+
f"Explique, em linguagem simples, como identificar um artefato do tipo "
|
| 338 |
+
f"'{pred_label}' e quais cuidados tomar ao manuseá-lo em campo."
|
| 339 |
)
|
| 340 |
|
| 341 |
+
user_question = st.text_area(
|
| 342 |
+
"Escreva sua pergunta para o especialista:",
|
| 343 |
+
value=default_question,
|
| 344 |
+
height=120,
|
| 345 |
)
|
| 346 |
|
| 347 |
+
if st.button("Consultar especialista agora 🧠"):
|
| 348 |
+
with st.spinner("Consultando o especialista online..."):
|
| 349 |
+
answer = consultar_especialista(pred_label, class_probs, user_question)
|
| 350 |
+
st.markdown("---")
|
| 351 |
+
st.markdown("**Resposta do especialista:**")
|
| 352 |
+
st.markdown(answer)
|
| 353 |
|
| 354 |
+
st.markdown('</div>', unsafe_allow_html=True) # fecha card de consulta
|
|
|
|
| 355 |
|
| 356 |
except Exception as e:
|
| 357 |
+
st.markdown('</div>', unsafe_allow_html=True) # garante fechamento do card
|
| 358 |
st.error(f"Ocorreu um erro ao processar a imagem: {e}")
|
| 359 |
else:
|
| 360 |
+
st.markdown('</div>', unsafe_allow_html=True) # fecha card de upload
|
| 361 |
st.info("Envie uma imagem para iniciar a análise.")
|