Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,24 +43,66 @@ def nutritional_analysis(image):
|
|
43 |
# Retornar a descrição e a análise nutricional
|
44 |
return description, analysis
|
45 |
|
46 |
-
# Interface Gradio
|
47 |
-
with gr.Blocks() as demo:
|
48 |
-
|
49 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
|
|
51 |
with gr.Row():
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
|
|
|
|
|
58 |
|
|
|
|
|
|
|
|
|
|
|
59 |
def process_image(image):
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
submit_button.click(process_image, inputs=image_input, outputs=[description_output, analysis_output])
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
# Iniciar o aplicativo
|
66 |
demo.launch()
|
|
|
43 |
# Retornar a descrição e a análise nutricional
|
44 |
return description, analysis
|
45 |
|
46 |
+
# Interface Gradio com Design Avançado
|
47 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="cyan")) as demo:
|
48 |
+
# Cabeçalho com Marketing
|
49 |
+
with gr.Row():
|
50 |
+
gr.Markdown("""
|
51 |
+
# 🍽️ Agente Nutricionista Inteligente
|
52 |
+
### Transforme suas refeições em escolhas saudáveis!
|
53 |
+
- **Descrição automática** de pratos de comida com IA avançada.
|
54 |
+
- **Análise nutricional detalhada** com estimativas de calorias e macronutrientes.
|
55 |
+
- **Recomendações personalizadas** para melhorar sua dieta.
|
56 |
+
""")
|
57 |
|
58 |
+
# Seção de Upload de Imagem
|
59 |
with gr.Row():
|
60 |
+
with gr.Column(scale=1):
|
61 |
+
gr.Markdown("### 📸 Carregue uma Imagem")
|
62 |
+
image_input = gr.Image(type="pil", label="Upload de Imagem", height=300, tool="editor")
|
63 |
+
|
64 |
+
with gr.Column(scale=2):
|
65 |
+
gr.Markdown("### 🔍 Resultados")
|
66 |
+
with gr.Tabs():
|
67 |
+
with gr.TabItem("Descrição do Prato"):
|
68 |
+
description_output = gr.Textbox(label="Descrição Gerada", lines=3, interactive=False)
|
69 |
+
|
70 |
+
with gr.TabItem("Análise Nutricional"):
|
71 |
+
analysis_output = gr.Textbox(label="Análise Nutricional", lines=8, interactive=False)
|
72 |
|
73 |
+
# Botão de Ação
|
74 |
+
with gr.Row():
|
75 |
+
submit_button = gr.Button("✨ Analisar Prato", variant="primary")
|
76 |
|
77 |
+
# Feedback do Usuário
|
78 |
+
with gr.Row():
|
79 |
+
feedback = gr.Markdown("")
|
80 |
+
|
81 |
+
# Função para processar a imagem
|
82 |
def process_image(image):
|
83 |
+
try:
|
84 |
+
description, analysis = nutritional_analysis(image)
|
85 |
+
feedback.update("✅ Análise concluída com sucesso!")
|
86 |
+
return description, analysis
|
87 |
+
except Exception as e:
|
88 |
+
feedback.update(f"❌ Erro ao processar a imagem: {str(e)}")
|
89 |
+
return "", ""
|
90 |
+
|
91 |
+
# Conectar botão aos outputs
|
92 |
submit_button.click(process_image, inputs=image_input, outputs=[description_output, analysis_output])
|
93 |
|
94 |
+
# Rodapé com Chamada à Ação
|
95 |
+
with gr.Row():
|
96 |
+
gr.Markdown("""
|
97 |
+
---
|
98 |
+
### 💡 Dicas para Melhores Resultados:
|
99 |
+
- Use imagens claras e bem iluminadas.
|
100 |
+
- Inclua todos os ingredientes visíveis no prato.
|
101 |
+
- Experimente diferentes ângulos para capturar mais detalhes.
|
102 |
+
|
103 |
+
### 🌟 Entre em Contato
|
104 |
+
- Quer saber mais? Visite nosso [site](https://example.com) ou nos siga nas redes sociais!
|
105 |
+
""")
|
106 |
+
|
107 |
# Iniciar o aplicativo
|
108 |
demo.launch()
|