Spaces:
Running
on
Zero
Running
on
Zero
examples
Browse files- README.md +7 -7
- app.py +20 -9
- examples/{pain_choc.jpeg → chocolatine.jpeg} +0 -0
- examples/mc_do.jpeg +0 -0
- examples/mistral_desert.jpeg +0 -0
- examples/mistral_juice.jpeg +0 -0
- examples/mistral_pasta.jpeg +0 -0
- examples/mistral_snacks.jpeg +0 -0
- examples/pate_carbo.jpg +0 -0
- examples/salad_cesar.jpeg +0 -0
README.md
CHANGED
@@ -4,17 +4,17 @@ emoji: 🚀
|
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
hf_oauth: true
|
12 |
tags:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
---
|
19 |
|
20 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.0.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
hf_oauth: true
|
12 |
tags:
|
13 |
+
- mistral
|
14 |
+
- pixtral
|
15 |
+
- nutrition
|
16 |
+
- diet
|
17 |
+
- chatbot
|
18 |
---
|
19 |
|
20 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -13,6 +13,9 @@ from dotenv import load_dotenv
|
|
13 |
import os
|
14 |
# Import Supabase functions
|
15 |
from db_client import get_user_history, update_user_history, delete_user_history
|
|
|
|
|
|
|
16 |
|
17 |
load_dotenv()
|
18 |
|
@@ -80,8 +83,14 @@ def bot_streaming(chatbot, image_input, max_new_tokens=250):
|
|
80 |
images = []
|
81 |
text_input = chatbot[-1][0]
|
82 |
|
|
|
|
|
|
|
|
|
83 |
if text_input != "":
|
84 |
-
text_input = "
|
|
|
|
|
85 |
|
86 |
# Add current message
|
87 |
if image_input is not None:
|
@@ -151,7 +160,7 @@ html = f"""
|
|
151 |
</p>
|
152 |
<center><font size=3><b>PixDiet</b> is your AI nutrition expert. Upload an image of your meal and chat with our AI to get personalized advice on your diet, meal composition, and ways to improve your nutrition.</font></center>
|
153 |
<div style="display: flex; justify-content: center; align-items: center; margin-top: 20px;">
|
154 |
-
<img src="https://
|
155 |
<img src="https://seeklogo.com/images/M/mistral-ai-icon-logo-B3319DCA6B-seeklogo.com.png" alt="Mistral AI Logo" style="height: 50px;">
|
156 |
</div>
|
157 |
"""
|
@@ -176,17 +185,19 @@ with gr.Blocks(title="PixDiet", theme=gr.themes.Ocean()) as demo:
|
|
176 |
gr.Examples(
|
177 |
examples=[
|
178 |
["./examples/mistral_breakfast.jpeg", ""],
|
179 |
-
["./examples/
|
180 |
-
["./examples/
|
|
|
|
|
181 |
],
|
182 |
inputs=[image_input, gr.Textbox(visible=False)]
|
183 |
)
|
184 |
with gr.Column(scale=7):
|
185 |
chatbot = gr.Chatbot(label="Chat with PixDiet", layout="panel", height=600, show_copy_button=True, latex_delimiters=latex_delimiters_set)
|
186 |
-
text_input = gr.Textbox(label="Ask about your meal", placeholder="Enter your
|
187 |
with gr.Row():
|
188 |
send_btn = gr.Button("Send", variant="primary")
|
189 |
-
clear_btn = gr.Button("Delete my historic", variant="
|
190 |
|
191 |
def submit_chat(chatbot, text_input):
|
192 |
response = ''
|
@@ -200,9 +211,9 @@ with gr.Blocks(title="PixDiet", theme=gr.themes.Ocean()) as demo:
|
|
200 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
201 |
bot_streaming, [chatbot, image_input], chatbot
|
202 |
)
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
clear_btn.click(clear_chat, outputs=[chatbot, image_input, text_input])
|
207 |
|
208 |
if __name__ == "__main__":
|
|
|
13 |
import os
|
14 |
# Import Supabase functions
|
15 |
from db_client import get_user_history, update_user_history, delete_user_history
|
16 |
+
# Add these imports
|
17 |
+
from datetime import datetime
|
18 |
+
import pytz
|
19 |
|
20 |
load_dotenv()
|
21 |
|
|
|
83 |
images = []
|
84 |
text_input = chatbot[-1][0]
|
85 |
|
86 |
+
# Get current time in Paris timezone
|
87 |
+
paris_tz = pytz.timezone('Europe/Paris')
|
88 |
+
current_time = datetime.now(paris_tz).strftime("%I:%M%p")
|
89 |
+
|
90 |
if text_input != "":
|
91 |
+
text_input = f"Current time: {current_time}. You are a nutrition expert. Identify the food/ingredients in this image. Is this a healthy meal? Can you think of how to improve it?"
|
92 |
+
else:
|
93 |
+
text_input = f"Current time: {current_time}. You are a nutrition expert. Identify the food/ingredients in this image. Is this a healthy meal? Can you think of how to improve it?"
|
94 |
|
95 |
# Add current message
|
96 |
if image_input is not None:
|
|
|
160 |
</p>
|
161 |
<center><font size=3><b>PixDiet</b> is your AI nutrition expert. Upload an image of your meal and chat with our AI to get personalized advice on your diet, meal composition, and ways to improve your nutrition.</font></center>
|
162 |
<div style="display: flex; justify-content: center; align-items: center; margin-top: 20px;">
|
163 |
+
<img src="https://zozs97eh0bkqexza.public.blob.vercel-storage.com/alan-VD7bRf1rKuEBL6EDAjw0eLGVodhoh8.png" alt="Alan AI Logo" style="height: 50px; margin-right: 20px;">
|
164 |
<img src="https://seeklogo.com/images/M/mistral-ai-icon-logo-B3319DCA6B-seeklogo.com.png" alt="Mistral AI Logo" style="height: 50px;">
|
165 |
</div>
|
166 |
"""
|
|
|
185 |
gr.Examples(
|
186 |
examples=[
|
187 |
["./examples/mistral_breakfast.jpeg", ""],
|
188 |
+
["./examples/mistral_desert.jpeg", ""],
|
189 |
+
["./examples/mistral_snacks.jpeg", ""],
|
190 |
+
["./examples/mistral_pasta.jpeg", ""],
|
191 |
+
|
192 |
],
|
193 |
inputs=[image_input, gr.Textbox(visible=False)]
|
194 |
)
|
195 |
with gr.Column(scale=7):
|
196 |
chatbot = gr.Chatbot(label="Chat with PixDiet", layout="panel", height=600, show_copy_button=True, latex_delimiters=latex_delimiters_set)
|
197 |
+
text_input = gr.Textbox(label="Ask about your meal", placeholder="(Optional) Enter your message here...", lines=1, container=False)
|
198 |
with gr.Row():
|
199 |
send_btn = gr.Button("Send", variant="primary")
|
200 |
+
clear_btn = gr.Button("Delete my historic", variant="huggingface")
|
201 |
|
202 |
def submit_chat(chatbot, text_input):
|
203 |
response = ''
|
|
|
211 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
212 |
bot_streaming, [chatbot, image_input], chatbot
|
213 |
)
|
214 |
+
submit_event = text_input.submit(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
215 |
+
bot_streaming, [chatbot, image_input], chatbot
|
216 |
+
)
|
217 |
clear_btn.click(clear_chat, outputs=[chatbot, image_input, text_input])
|
218 |
|
219 |
if __name__ == "__main__":
|
examples/{pain_choc.jpeg → chocolatine.jpeg}
RENAMED
File without changes
|
examples/mc_do.jpeg
DELETED
Binary file (47.1 kB)
|
|
examples/mistral_desert.jpeg
ADDED
examples/mistral_juice.jpeg
ADDED
examples/mistral_pasta.jpeg
ADDED
examples/mistral_snacks.jpeg
ADDED
examples/pate_carbo.jpg
DELETED
Binary file (114 kB)
|
|
examples/salad_cesar.jpeg
DELETED
Binary file (275 kB)
|
|