Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -108,8 +108,8 @@ def generate_analysis(uploaded_file, client):
|
|
108 |
response = client.chat.completions.create(
|
109 |
model="llama-3.2-11b-vision-preview",
|
110 |
messages=[{
|
111 |
-
"
|
112 |
-
"
|
113 |
You are an expert nutritionist with advanced image analysis capabilities.
|
114 |
Your task is to analyze the provided image, identify all visible food items, and estimate their calorie content with high accuracy.
|
115 |
**Instructions:**
|
@@ -124,6 +124,10 @@ def generate_analysis(uploaded_file, client):
|
|
124 |
- **Total Estimated Calories:** [value] kcal
|
125 |
If the image lacks sufficient detail or is unclear, specify the limitations and include your confidence level in the estimate as a percentage.
|
126 |
"""
|
|
|
|
|
|
|
|
|
127 |
}],
|
128 |
temperature=0.2,
|
129 |
max_tokens=400,
|
@@ -134,6 +138,7 @@ def generate_analysis(uploaded_file, client):
|
|
134 |
st.error(f"Error communicating with API: {e}")
|
135 |
return None
|
136 |
|
|
|
137 |
# ======================
|
138 |
# UI COMPONENTS
|
139 |
# ======================
|
|
|
108 |
response = client.chat.completions.create(
|
109 |
model="llama-3.2-11b-vision-preview",
|
110 |
messages=[{
|
111 |
+
"role": "system", # Define the role for the system message
|
112 |
+
"content": """
|
113 |
You are an expert nutritionist with advanced image analysis capabilities.
|
114 |
Your task is to analyze the provided image, identify all visible food items, and estimate their calorie content with high accuracy.
|
115 |
**Instructions:**
|
|
|
124 |
- **Total Estimated Calories:** [value] kcal
|
125 |
If the image lacks sufficient detail or is unclear, specify the limitations and include your confidence level in the estimate as a percentage.
|
126 |
"""
|
127 |
+
},
|
128 |
+
{
|
129 |
+
"role": "user", # Define the role for the user message
|
130 |
+
"content": f"Analyze this image and provide the nutrition analysis: {image_url}"
|
131 |
}],
|
132 |
temperature=0.2,
|
133 |
max_tokens=400,
|
|
|
138 |
st.error(f"Error communicating with API: {e}")
|
139 |
return None
|
140 |
|
141 |
+
|
142 |
# ======================
|
143 |
# UI COMPONENTS
|
144 |
# ======================
|