Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -239,34 +239,139 @@ class IrisAnalyzer:
|
|
239 |
|
240 |
def process_image(img):
|
241 |
if img is None:
|
242 |
-
return None, "
|
243 |
|
244 |
analyzer = IrisAnalyzer()
|
245 |
processed_img, results = analyzer.analyze_iris(img)
|
246 |
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
for zone_name, analysis in results["analysis"].items():
|
249 |
-
|
250 |
-
|
251 |
for condition in analysis["conditions"]:
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
255 |
for rec in analysis["recommendations"]:
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
if __name__ == "__main__":
|
272 |
-
|
|
|
239 |
|
240 |
def process_image(img):
|
241 |
if img is None:
|
242 |
+
return [None] * 5, gr.Warning("Por favor, carregue uma imagem.")
|
243 |
|
244 |
analyzer = IrisAnalyzer()
|
245 |
processed_img, results = analyzer.analyze_iris(img)
|
246 |
|
247 |
+
# Relatório Geral
|
248 |
+
general_report = "# 📊 Visão Geral da Análise\n\n"
|
249 |
+
status_counts = {"baixa": 0, "media": 0, "alta": 0}
|
250 |
+
for analysis in results["analysis"].values():
|
251 |
+
status_counts[analysis["status"]] += 1
|
252 |
+
|
253 |
+
health_score = ((status_counts["alta"] * 100) + (status_counts["media"] * 50)) / len(results["analysis"])
|
254 |
+
general_report += f"**Índice de Saúde Geral:** {health_score:.1f}%\n\n"
|
255 |
+
general_report += f"**Data da Análise:** {results['timestamp']}\n\n"
|
256 |
+
|
257 |
+
# Condições Detalhadas
|
258 |
+
detailed_conditions = "# 🔍 Análise Detalhada por Zona\n\n"
|
259 |
for zone_name, analysis in results["analysis"].items():
|
260 |
+
detailed_conditions += f"## {zone_name}\n\n"
|
261 |
+
detailed_conditions += "### Condições Identificadas:\n"
|
262 |
for condition in analysis["conditions"]:
|
263 |
+
detailed_conditions += f"- {condition}\n"
|
264 |
+
detailed_conditions += f"\n**Status:** {analysis['status'].title()}\n"
|
265 |
+
detailed_conditions += f"**Intensidade:** {analysis['intensity']:.1f}\n\n"
|
266 |
+
|
267 |
+
# Recomendações
|
268 |
+
recommendations = "# 💡 Recomendações Personalizadas\n\n"
|
269 |
+
for zone_name, analysis in results["analysis"].items():
|
270 |
+
recommendations += f"## {zone_name}\n\n"
|
271 |
for rec in analysis["recommendations"]:
|
272 |
+
recommendations += f"- {rec}\n"
|
273 |
+
recommendations += "\n"
|
274 |
+
|
275 |
+
# Alertas de Saúde
|
276 |
+
health_alerts = "# ⚠️ Alertas e Atenção Especial\n\n"
|
277 |
+
for zone_name, analysis in results["analysis"].items():
|
278 |
+
if analysis["status"] == "baixa":
|
279 |
+
health_alerts += f"## {zone_name}\n"
|
280 |
+
health_alerts += "### Pontos de Atenção:\n"
|
281 |
+
for condition in analysis["conditions"]:
|
282 |
+
health_alerts += f"- ⚠️ {condition}\n"
|
283 |
+
health_alerts += "\n### Ações Recomendadas:\n"
|
284 |
+
for rec in analysis["recommendations"]:
|
285 |
+
health_alerts += f"- ✅ {rec}\n"
|
286 |
+
health_alerts += "\n"
|
287 |
+
|
288 |
+
return [
|
289 |
+
processed_img,
|
290 |
+
general_report,
|
291 |
+
detailed_conditions,
|
292 |
+
recommendations,
|
293 |
+
health_alerts
|
294 |
+
]
|
295 |
+
|
296 |
+
# Interface Gradio moderna com Blocks
|
297 |
+
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
298 |
+
gr.Markdown("""
|
299 |
+
# 🔍 Analisador Avançado de Íris
|
300 |
+
### Sistema Educacional de Análise Iridológica v2.0
|
301 |
+
|
302 |
+
⚠️ Este é um sistema para fins educacionais. Não utilize para diagnósticos médicos.
|
303 |
+
""")
|
304 |
+
|
305 |
+
with gr.Tabs() as tabs:
|
306 |
+
# Aba de Análise
|
307 |
+
with gr.Tab("📸 Análise de Imagem", id=1):
|
308 |
+
with gr.Row():
|
309 |
+
with gr.Column(scale=1):
|
310 |
+
input_image = gr.Image(
|
311 |
+
label="Upload da Imagem da Íris",
|
312 |
+
type="numpy",
|
313 |
+
sources=["upload", "webcam", "clipboard"],
|
314 |
+
height=400
|
315 |
+
)
|
316 |
+
analyze_btn = gr.Button("🔍 Analisar Íris", variant="primary", size="lg")
|
317 |
+
|
318 |
+
with gr.Column(scale=1):
|
319 |
+
output_image = gr.Image(label="Visualização da Análise", height=400)
|
320 |
+
|
321 |
+
# Aba de Resultados
|
322 |
+
with gr.Tab("📊 Resultados", id=2):
|
323 |
+
with gr.Tabs() as result_tabs:
|
324 |
+
with gr.Tab("📈 Visão Geral", id=2.1):
|
325 |
+
general_output = gr.Markdown()
|
326 |
+
|
327 |
+
with gr.Tab("🔍 Condições Detalhadas", id=2.2):
|
328 |
+
conditions_output = gr.Markdown()
|
329 |
+
|
330 |
+
with gr.Tab("💡 Recomendações", id=2.3):
|
331 |
+
recommendations_output = gr.Markdown()
|
332 |
+
|
333 |
+
with gr.Tab("⚠️ Alertas", id=2.4):
|
334 |
+
alerts_output = gr.Markdown()
|
335 |
+
|
336 |
+
# Aba de Informações
|
337 |
+
with gr.Tab("ℹ️ Informações", id=3):
|
338 |
+
gr.Markdown("""
|
339 |
+
## 📚 Sobre a Análise Iridológica
|
340 |
+
|
341 |
+
### 🎯 Zonas Analisadas:
|
342 |
+
1. **Zona Cerebral/Neural** - Sistema nervoso central e periférico
|
343 |
+
2. **Zona Digestiva** - Sistema digestório completo
|
344 |
+
3. **Zona Respiratória** - Sistema respiratório
|
345 |
+
4. **Zona Circulatória** - Sistema cardiovascular
|
346 |
+
5. **Zona Linfática** - Sistema imunológico
|
347 |
+
6. **Zona Endócrina** - Sistema hormonal
|
348 |
+
7. **Zona Pupilar** - Sistema nervoso autônomo
|
349 |
+
|
350 |
+
### 📋 Como Usar:
|
351 |
+
1. Faça upload de uma imagem clara da íris
|
352 |
+
2. Clique em "Analisar Íris"
|
353 |
+
3. Verifique os resultados nas diferentes abas
|
354 |
+
4. Consulte os alertas e recomendações
|
355 |
|
356 |
+
### ⚠️ Observações Importantes:
|
357 |
+
- Sistema para fins educacionais
|
358 |
+
- Não substitui avaliação médica
|
359 |
+
- Consulte profissionais de saúde
|
360 |
+
- Mantenha check-ups regulares
|
361 |
+
""")
|
362 |
+
|
363 |
+
# Configurar eventos
|
364 |
+
analyze_btn.click(
|
365 |
+
fn=process_image,
|
366 |
+
inputs=input_image,
|
367 |
+
outputs=[
|
368 |
+
output_image,
|
369 |
+
general_output,
|
370 |
+
conditions_output,
|
371 |
+
recommendations_output,
|
372 |
+
alerts_output
|
373 |
+
]
|
374 |
+
)
|
375 |
|
376 |
if __name__ == "__main__":
|
377 |
+
iface.launch()
|