Update src/streamlit_app.py
Browse files- src/streamlit_app.py +117 -21
src/streamlit_app.py
CHANGED
|
@@ -120,15 +120,29 @@ st.set_page_config(
|
|
| 120 |
st.markdown(
|
| 121 |
"""
|
| 122 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
.main {
|
| 124 |
-
max-width:
|
| 125 |
margin: 0 auto;
|
| 126 |
-
padding-top:
|
| 127 |
font-family: "Segoe UI", sans-serif;
|
| 128 |
}
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
h1, h2, h3, h4 {
|
| 131 |
-
text-align: center;
|
| 132 |
font-family: "Segoe UI", sans-serif;
|
| 133 |
}
|
| 134 |
|
|
@@ -137,12 +151,12 @@ h1, h2, h3, h4 {
|
|
| 137 |
font-size: 2.4rem;
|
| 138 |
font-weight: 800;
|
| 139 |
color: #1A73E8; /* azul profissional */
|
| 140 |
-
margin-bottom: -
|
| 141 |
}
|
| 142 |
|
| 143 |
.arqueoia-title {
|
| 144 |
text-align: center;
|
| 145 |
-
font-size:
|
| 146 |
font-weight: 700;
|
| 147 |
color: #222;
|
| 148 |
margin-top: 0;
|
|
@@ -151,23 +165,77 @@ h1, h2, h3, h4 {
|
|
| 151 |
|
| 152 |
.subtitle {
|
| 153 |
text-align: center;
|
| 154 |
-
font-size: 1.
|
| 155 |
color: #555;
|
| 156 |
margin-top: -2px;
|
| 157 |
margin-bottom: 18px;
|
| 158 |
}
|
| 159 |
|
|
|
|
| 160 |
hr {
|
| 161 |
border: none;
|
| 162 |
height: 1px;
|
| 163 |
-
background-color: #
|
| 164 |
-
margin:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
</style>
|
| 167 |
""",
|
| 168 |
unsafe_allow_html=True,
|
| 169 |
)
|
| 170 |
|
|
|
|
| 171 |
st.markdown('<div class="netuno-title">Equipe Netuno</div>', unsafe_allow_html=True)
|
| 172 |
st.markdown('<div class="arqueoia-title">ArqueoIA</div>', unsafe_allow_html=True)
|
| 173 |
st.markdown(
|
|
@@ -180,7 +248,8 @@ Sistema profissional de inteligência artificial para identificação e classifi
|
|
| 180 |
unsafe_allow_html=True,
|
| 181 |
)
|
| 182 |
|
| 183 |
-
|
|
|
|
| 184 |
|
| 185 |
# ============================================================
|
| 186 |
# 5. Estado de sessão para chat
|
|
@@ -203,7 +272,11 @@ if labels:
|
|
| 203 |
# 6. Entrada de imagem (câmera + upload)
|
| 204 |
# ============================================================
|
| 205 |
|
| 206 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
uploaded_file = st.camera_input("Tire uma foto do artefato (opcional)")
|
| 209 |
|
|
@@ -220,14 +293,22 @@ if uploaded_file is not None:
|
|
| 220 |
# -------------------------------------
|
| 221 |
# 2) Visualização
|
| 222 |
# -------------------------------------
|
| 223 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
st.image(pil_img, caption="Imagem enviada", use_container_width=True)
|
| 225 |
st.write("")
|
| 226 |
|
| 227 |
# -------------------------------------
|
| 228 |
# 3) Resultado (modelo local)
|
| 229 |
# -------------------------------------
|
| 230 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
with st.spinner("Analisando a imagem com o modelo ArqueoIA..."):
|
| 233 |
probs = run_inference(pil_img)
|
|
@@ -259,13 +340,22 @@ if uploaded_file is not None:
|
|
| 259 |
name = labels[i]
|
| 260 |
else:
|
| 261 |
name = f"classe {i}"
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
# -------------------------------------
|
| 265 |
# 4) Consultar especialista online
|
| 266 |
# -------------------------------------
|
| 267 |
st.markdown("---")
|
| 268 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
if client is None:
|
| 271 |
st.info(
|
|
@@ -280,17 +370,22 @@ if uploaded_file is not None:
|
|
| 280 |
|
| 281 |
# histórico
|
| 282 |
if st.session_state["chat_history"]:
|
| 283 |
-
st.markdown("#### Conversa")
|
| 284 |
for msg in st.session_state["chat_history"]:
|
| 285 |
if msg["role"] == "user":
|
| 286 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
| 287 |
else:
|
| 288 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
pergunta_usuario = st.text_input(
|
| 291 |
"Pergunte ao especialista:",
|
| 292 |
key="input_user",
|
| 293 |
-
placeholder="Ex.: Essa moeda é de qual época?"
|
| 294 |
)
|
| 295 |
|
| 296 |
if st.button("Enviar pergunta ao especialista"):
|
|
@@ -330,9 +425,7 @@ if uploaded_file is not None:
|
|
| 330 |
model="gpt-4o-mini",
|
| 331 |
messages=mensagens,
|
| 332 |
)
|
| 333 |
-
texto_resposta = (
|
| 334 |
-
resposta.choices[0].message.content.strip()
|
| 335 |
-
)
|
| 336 |
st.session_state["chat_history"].append(
|
| 337 |
{"role": "assistant", "content": texto_resposta}
|
| 338 |
)
|
|
@@ -348,6 +441,9 @@ if uploaded_file is not None:
|
|
| 348 |
else:
|
| 349 |
st.info("Tire uma foto ou envie uma imagem para iniciar a análise.")
|
| 350 |
|
|
|
|
|
|
|
|
|
|
| 351 |
# ============================================================
|
| 352 |
# 7. Rodapé
|
| 353 |
# ============================================================
|
|
|
|
| 120 |
st.markdown(
|
| 121 |
"""
|
| 122 |
<style>
|
| 123 |
+
/* fundo geral mais claro */
|
| 124 |
+
body {
|
| 125 |
+
background-color: #f4f5f7;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/* container principal */
|
| 129 |
.main {
|
| 130 |
+
max-width: 950px;
|
| 131 |
margin: 0 auto;
|
| 132 |
+
padding-top: 1.5rem;
|
| 133 |
font-family: "Segoe UI", sans-serif;
|
| 134 |
}
|
| 135 |
|
| 136 |
+
/* card branco central */
|
| 137 |
+
.app-card {
|
| 138 |
+
background-color: #ffffff;
|
| 139 |
+
padding: 1.8rem 2.2rem 2.2rem 2.2rem;
|
| 140 |
+
border-radius: 16px;
|
| 141 |
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/* títulos */
|
| 145 |
h1, h2, h3, h4 {
|
|
|
|
| 146 |
font-family: "Segoe UI", sans-serif;
|
| 147 |
}
|
| 148 |
|
|
|
|
| 151 |
font-size: 2.4rem;
|
| 152 |
font-weight: 800;
|
| 153 |
color: #1A73E8; /* azul profissional */
|
| 154 |
+
margin-bottom: -4px;
|
| 155 |
}
|
| 156 |
|
| 157 |
.arqueoia-title {
|
| 158 |
text-align: center;
|
| 159 |
+
font-size: 2.0rem;
|
| 160 |
font-weight: 700;
|
| 161 |
color: #222;
|
| 162 |
margin-top: 0;
|
|
|
|
| 165 |
|
| 166 |
.subtitle {
|
| 167 |
text-align: center;
|
| 168 |
+
font-size: 1.02rem;
|
| 169 |
color: #555;
|
| 170 |
margin-top: -2px;
|
| 171 |
margin-bottom: 18px;
|
| 172 |
}
|
| 173 |
|
| 174 |
+
/* separador */
|
| 175 |
hr {
|
| 176 |
border: none;
|
| 177 |
height: 1px;
|
| 178 |
+
background-color: #e2e4ea;
|
| 179 |
+
margin: 16px 0 22px 0;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/* título de seção numerado */
|
| 183 |
+
.section-header {
|
| 184 |
+
font-size: 1.05rem;
|
| 185 |
+
font-weight: 600;
|
| 186 |
+
display: inline-flex;
|
| 187 |
+
align-items: center;
|
| 188 |
+
margin: 10px 0 8px 0;
|
| 189 |
+
color: #1f2933;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.section-badge {
|
| 193 |
+
display: inline-flex;
|
| 194 |
+
align-items: center;
|
| 195 |
+
justify-content: center;
|
| 196 |
+
width: 22px;
|
| 197 |
+
height: 22px;
|
| 198 |
+
border-radius: 999px;
|
| 199 |
+
font-size: 0.9rem;
|
| 200 |
+
font-weight: 700;
|
| 201 |
+
margin-right: 8px;
|
| 202 |
+
background: #1A73E8;
|
| 203 |
+
color: #ffffff;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/* chat */
|
| 207 |
+
.chat-bubble {
|
| 208 |
+
padding: 0.55rem 0.8rem;
|
| 209 |
+
border-radius: 10px;
|
| 210 |
+
margin-bottom: 6px;
|
| 211 |
+
font-size: 0.95rem;
|
| 212 |
+
line-height: 1.35rem;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.chat-user {
|
| 216 |
+
background-color: #e3f2fd;
|
| 217 |
+
border: 1px solid #bbdefb;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.chat-assistant {
|
| 221 |
+
background-color: #f3f4f6;
|
| 222 |
+
border: 1px solid #e5e7eb;
|
| 223 |
}
|
| 224 |
+
|
| 225 |
+
/* label "Resposta do especialista" */
|
| 226 |
+
.section-subtitle {
|
| 227 |
+
font-size: 1.0rem;
|
| 228 |
+
font-weight: 600;
|
| 229 |
+
margin-top: 10px;
|
| 230 |
+
margin-bottom: 4px;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
</style>
|
| 234 |
""",
|
| 235 |
unsafe_allow_html=True,
|
| 236 |
)
|
| 237 |
|
| 238 |
+
# Cabeçalho fora do card para “flutuar” um pouco
|
| 239 |
st.markdown('<div class="netuno-title">Equipe Netuno</div>', unsafe_allow_html=True)
|
| 240 |
st.markdown('<div class="arqueoia-title">ArqueoIA</div>', unsafe_allow_html=True)
|
| 241 |
st.markdown(
|
|
|
|
| 248 |
unsafe_allow_html=True,
|
| 249 |
)
|
| 250 |
|
| 251 |
+
# Abre o card principal
|
| 252 |
+
st.markdown('<div class="app-card">', unsafe_allow_html=True)
|
| 253 |
|
| 254 |
# ============================================================
|
| 255 |
# 5. Estado de sessão para chat
|
|
|
|
| 272 |
# 6. Entrada de imagem (câmera + upload)
|
| 273 |
# ============================================================
|
| 274 |
|
| 275 |
+
st.markdown(
|
| 276 |
+
'<div class="section-header"><span class="section-badge">1</span>'
|
| 277 |
+
'<span>Envie uma imagem ou tire uma foto</span></div>',
|
| 278 |
+
unsafe_allow_html=True,
|
| 279 |
+
)
|
| 280 |
|
| 281 |
uploaded_file = st.camera_input("Tire uma foto do artefato (opcional)")
|
| 282 |
|
|
|
|
| 293 |
# -------------------------------------
|
| 294 |
# 2) Visualização
|
| 295 |
# -------------------------------------
|
| 296 |
+
st.markdown(
|
| 297 |
+
'<div class="section-header"><span class="section-badge">2</span>'
|
| 298 |
+
'<span>Visualização</span></div>',
|
| 299 |
+
unsafe_allow_html=True,
|
| 300 |
+
)
|
| 301 |
st.image(pil_img, caption="Imagem enviada", use_container_width=True)
|
| 302 |
st.write("")
|
| 303 |
|
| 304 |
# -------------------------------------
|
| 305 |
# 3) Resultado (modelo local)
|
| 306 |
# -------------------------------------
|
| 307 |
+
st.markdown(
|
| 308 |
+
'<div class="section-header"><span class="section-badge">3</span>'
|
| 309 |
+
'<span>Resultado (modelo local)</span></div>',
|
| 310 |
+
unsafe_allow_html=True,
|
| 311 |
+
)
|
| 312 |
|
| 313 |
with st.spinner("Analisando a imagem com o modelo ArqueoIA..."):
|
| 314 |
probs = run_inference(pil_img)
|
|
|
|
| 340 |
name = labels[i]
|
| 341 |
else:
|
| 342 |
name = f"classe {i}"
|
| 343 |
+
|
| 344 |
+
col1, col2 = st.columns([1, 4])
|
| 345 |
+
with col1:
|
| 346 |
+
st.write(f"**{name}**")
|
| 347 |
+
with col2:
|
| 348 |
+
st.progress(float(probs[i]))
|
| 349 |
|
| 350 |
# -------------------------------------
|
| 351 |
# 4) Consultar especialista online
|
| 352 |
# -------------------------------------
|
| 353 |
st.markdown("---")
|
| 354 |
+
st.markdown(
|
| 355 |
+
'<div class="section-header"><span class="section-badge">4</span>'
|
| 356 |
+
'<span>Consultar especialista online</span></div>',
|
| 357 |
+
unsafe_allow_html=True,
|
| 358 |
+
)
|
| 359 |
|
| 360 |
if client is None:
|
| 361 |
st.info(
|
|
|
|
| 370 |
|
| 371 |
# histórico
|
| 372 |
if st.session_state["chat_history"]:
|
|
|
|
| 373 |
for msg in st.session_state["chat_history"]:
|
| 374 |
if msg["role"] == "user":
|
| 375 |
+
st.markdown(
|
| 376 |
+
f'<div class="chat-bubble chat-user"><b>Você:</b> {msg["content"]}</div>',
|
| 377 |
+
unsafe_allow_html=True,
|
| 378 |
+
)
|
| 379 |
else:
|
| 380 |
+
st.markdown(
|
| 381 |
+
f'<div class="chat-bubble chat-assistant"><b>Especialista:</b> {msg["content"]}</div>',
|
| 382 |
+
unsafe_allow_html=True,
|
| 383 |
+
)
|
| 384 |
|
| 385 |
pergunta_usuario = st.text_input(
|
| 386 |
"Pergunte ao especialista:",
|
| 387 |
key="input_user",
|
| 388 |
+
placeholder="Ex.: Essa moeda é de qual época?",
|
| 389 |
)
|
| 390 |
|
| 391 |
if st.button("Enviar pergunta ao especialista"):
|
|
|
|
| 425 |
model="gpt-4o-mini",
|
| 426 |
messages=mensagens,
|
| 427 |
)
|
| 428 |
+
texto_resposta = resposta.choices[0].message.content.strip()
|
|
|
|
|
|
|
| 429 |
st.session_state["chat_history"].append(
|
| 430 |
{"role": "assistant", "content": texto_resposta}
|
| 431 |
)
|
|
|
|
| 441 |
else:
|
| 442 |
st.info("Tire uma foto ou envie uma imagem para iniciar a análise.")
|
| 443 |
|
| 444 |
+
# Fecha o card principal
|
| 445 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 446 |
+
|
| 447 |
# ============================================================
|
| 448 |
# 7. Rodapé
|
| 449 |
# ============================================================
|