Llama Use Case : Nutrition

Shows the usage Ollama hosted llama models
from utils import llama32, stream_response, disp_image, img2base64, llama32pi, rs4llama, merge_images, llama32opi, ocr_reprompt
from fastcore.all import *
import pathlib
import PIL
disp_image("images/drinks.png")
question = "I am on a diet. Which drink should I drink? Explain your decision step by step."
llama32pi(question, image_url="images/drinks.png", stream=True)

<<Streaming response>>

To make an informed decision, let’s analyze the nutritional information provided for each drink:

Drink 1:

  • Calories: 0
  • Sodium: 25 mg
  • Fat: 0 g
  • Carbohydrates: 0 g

This drink appears to be a low-calorie option with no fat or carbohydrates. However, it does contain some sodium.

Drink 2:

  • Calories: 130
  • Sodium: 50 mg
  • Fat: 0 g
  • Carbohydrates: 33 g

This drink has significantly more calories and carbohydrates compared to Drink 1 but still lacks fat.

Considering your diet goals, you may want to opt for the lower-calorie option. However, it’s essential to note that while both drinks are low in fat, they differ in their carbohydrate content. If you’re trying to manage your carb intake, Drink 1 might be a better choice. Nevertheless, if you prioritize reducing overall calorie consumption without worrying about carbs, Drink 2 could still be an acceptable option.

Ultimately, the decision depends on your specific dietary needs and preferences. It’s always a good idea to consult with a healthcare professional or registered dietitian for personalized advice.

"To make an informed decision, let's analyze the nutritional information provided for each drink:\n\n**Drink 1:**\n\n* Calories: 0\n* Sodium: 25 mg\n* Fat: 0 g\n* Carbohydrates: 0 g\n\nThis drink appears to be a low-calorie option with no fat or carbohydrates. However, it does contain some sodium.\n\n**Drink 2:**\n\n* Calories: 130\n* Sodium: 50 mg\n* Fat: 0 g\n* Carbohydrates: 33 g\n\nThis drink has significantly more calories and carbohydrates compared to Drink 1 but still lacks fat.\n\nConsidering your diet goals, you may want to opt for the lower-calorie option. However, it's essential to note that while both drinks are low in fat, they differ in their carbohydrate content. If you're trying to manage your carb intake, Drink 1 might be a better choice. Nevertheless, if you prioritize reducing overall calorie consumption without worrying about carbs, Drink 2 could still be an acceptable option.\n\nUltimately, the decision depends on your specific dietary needs and preferences. It's always a good idea to consult with a healthcare professional or registered dietitian for personalized advice."
question = "Image contains two drinks. Generate nutritional facts about the two drinks."
llama32pi(question, image_url="images/drinks.png", stream=True)

<<Streaming response>>

The image shows two drinks, a can of soda and an unidentifiable beverage in a bottle. The nutrition facts for each drink are as follows:

Soda Can:

  • Calories: 0
  • Fat: 0g
  • Sodium: 35mg
  • Total Carbohydrates: 39g
  • Sugars: 33g
  • Protein: 0g

Unidentifiable Beverage Bottle:

Unfortunately, the nutrition facts for this drink are not visible in the image. However, based on the label design and font style, it appears to be a similar brand or type of beverage as the soda can.

It’s worth noting that without more information or access to the actual labels, it’s impossible to provide an accurate nutritional breakdown for the unidentifiable beverage bottle. If you have any additional details or images, I’d be happy to try and help further.

"The image shows two drinks, a can of soda and an unidentifiable beverage in a bottle. The nutrition facts for each drink are as follows:\n\n**Soda Can:**\n\n* Calories: 0\n* Fat: 0g\n* Sodium: 35mg\n* Total Carbohydrates: 39g\n* Sugars: 33g\n* Protein: 0g\n\n**Unidentifiable Beverage Bottle:**\n\nUnfortunately, the nutrition facts for this drink are not visible in the image. However, based on the label design and font style, it appears to be a similar brand or type of beverage as the soda can.\n\nIt's worth noting that without more information or access to the actual labels, it's impossible to provide an accurate nutritional breakdown for the unidentifiable beverage bottle. If you have any additional details or images, I'd be happy to try and help further."
system_prompt = """
You are an intelligent OCR assistant designed to read and extract information from image. 
When presented with an image for drink, your task is to:
1. Identify if image contains one or multiple drinks.
1. Identify the sections where the nutritional facts and calorie information is mentioned for each drink.
2. Accurately read the numerical values like nutrition, calories, serving size for each drink. Compare results if multiple drinks are present in image under their own name.
3. Clearly provide decision on healthier option based on nutritional fact and calorie count.
4. Explain your decision step by step.
"""

question =  "Following image contains two drinks. I am on a diet. Which drink should I drink?"

llama32opi(question, system_prompt, image_url="images/drinks.png")

<<Streaming response>>

Drink Comparison Analysis

Based on the provided image, we have identified two drinks: “Diet Coke” and “Sprite Zero”. To determine which one is healthier, we will compare their nutritional facts.

Nutritional Facts Comparison

  • Diet Coke
    • Calories: 0
    • Total Fat: 0g
    • Sodium: 35mg
    • Total Carbohydrates: 0g
    • Sugars: 0g
    • Protein: 0g
  • Sprite Zero
    • Calories: 0
    • Total Fat: 0g
    • Sodium: 15mg
    • Total Carbohydrates: 0g
    • Sugars: 0g
    • Protein: 0g

Comparison Summary

Both drinks have the same nutritional profile, with zero calories, fat, sodium, carbohydrates, sugars, and protein. However, Diet Coke has slightly more sodium than Sprite Zero.

Healthier Option Decision

Based on the comparison, we cannot definitively say that one drink is healthier than the other since they share identical nutritional profiles. However, if you prefer to minimize your sodium intake, Sprite Zero might be a slightly better choice due to its lower sodium content.

Conclusion

Ultimately, the decision comes down to personal preference regarding sodium levels and no significant difference exists between the two drinks in terms of calorie or macronutrient content.

'**Drink Comparison Analysis**\n\nBased on the provided image, we have identified two drinks: "Diet Coke" and "Sprite Zero". To determine which one is healthier, we will compare their nutritional facts.\n\n### Nutritional Facts Comparison\n\n* **Diet Coke**\n\t+ Calories: 0\n\t+ Total Fat: 0g\n\t+ Sodium: 35mg\n\t+ Total Carbohydrates: 0g\n\t+ Sugars: 0g\n\t+ Protein: 0g\n* **Sprite Zero**\n\t+ Calories: 0\n\t+ Total Fat: 0g\n\t+ Sodium: 15mg\n\t+ Total Carbohydrates: 0g\n\t+ Sugars: 0g\n\t+ Protein: 0g\n\n### Comparison Summary\n\nBoth drinks have the same nutritional profile, with zero calories, fat, sodium, carbohydrates, sugars, and protein. However, Diet Coke has slightly more sodium than Sprite Zero.\n\n### Healthier Option Decision\n\nBased on the comparison, we cannot definitively say that one drink is healthier than the other since they share identical nutritional profiles. However, if you prefer to minimize your sodium intake, Sprite Zero might be a slightly better choice due to its lower sodium content.\n\n**Conclusion**\n\nUltimately, the decision comes down to personal preference regarding sodium levels and no significant difference exists between the two drinks in terms of calorie or macronutrient content.'
reprompt = "Revalidate your findings from image, maintain order of drinks and make corrections and changes only when necessary. Explain your decision step by step."
ocr_reprompt(question, reprompt, system_prompt, image_url="images/drinks.png")

<<Streaming response>>

The drink that is zero calories and does not contain any sugar would be the best choice to fit within your dietary goals.

The can of soda on the left-hand side indicates it has 0 calories, while the can of energy drink on the right-hand side indicates that it contains 130 calories per serving. Therefore, the soda would be a better choice for someone who is trying to stick to their diet and watch their calorie intake.

It’s also important to note that the soda does not contain any sugar, which makes it an even more attractive option for those watching their sugar intake as well.

<<Streaming response>>

Upon re-examining the images, I notice that the soda on the left-hand side actually contains 130 calories per serving, while the energy drink on the right-hand side has 0 calories. Therefore, the energy drink would be a better choice for someone who is trying to stick to their diet and watch their calorie intake.

Here’s my revised decision:

  1. The image contains two drinks: soda on the left-hand side and an energy drink on the right-hand side.
  2. I identified the sections where the nutritional facts are mentioned for each drink. The nutrition facts are listed on both cans, but the information is not clearly visible due to the image quality.
  3. After carefully examining the images, I found that the soda on the left-hand side has 130 calories per serving, while the energy drink on the right-hand side has 0 calories.
  4. Based on this information, I conclude that the energy drink would be a better choice for someone who is trying to stick to their diet and watch their calorie intake.

Therefore, my revised decision is to choose the energy drink over the soda. This is because the energy drink has zero calories, which aligns with the goal of maintaining a low-calorie diet.

"Upon re-examining the images, I notice that the soda on the left-hand side actually contains 130 calories per serving, while the energy drink on the right-hand side has 0 calories. Therefore, the energy drink would be a better choice for someone who is trying to stick to their diet and watch their calorie intake.\n\nHere's my revised decision:\n\n1. The image contains two drinks: soda on the left-hand side and an energy drink on the right-hand side.\n2. I identified the sections where the nutritional facts are mentioned for each drink. The nutrition facts are listed on both cans, but the information is not clearly visible due to the image quality.\n3. After carefully examining the images, I found that the soda on the left-hand side has 130 calories per serving, while the energy drink on the right-hand side has 0 calories.\n4. Based on this information, I conclude that the energy drink would be a better choice for someone who is trying to stick to their diet and watch their calorie intake.\n\nTherefore, my revised decision is to choose the energy drink over the soda. This is because the energy drink has zero calories, which aligns with the goal of maintaining a low-calorie diet."
rs4llama("images/drinks.png")

reprompt = "Revalidate your findings from image, maintain order of drinks and make corrections and changes only when necessary. Explain your decision step by step."
ocr_reprompt(question, reprompt, system_prompt, image_url=rs4llama("images/drinks.png"))

<<Streaming response>>

The image shows two cans of beverages. The can on the left is white and appears to be a juice or milk product, while the can on the right is green with a label indicating it is caffeine-free.

To determine which drink you should choose based on your dietary preferences, let’s examine the nutrition information provided for each:

  • White Can (Left):
    • Calories: Not specified
    • Fat content: Not specified
    • Protein: Not specified
    • Carbohydrates: Not specified
    • Fiber: Not specified

Since specific nutritional details are not available, we cannot accurately determine whether this drink aligns with your dietary goals.

  • Green Can (Right):
    • Calories: 0
    • Fat content: 0%
    • Protein: 0g
    • Carbohydrates: 0%
    • Fiber: Not specified

Given the provided nutrition facts, this green can appears to be a low-calorie or zero-calorie beverage. It contains no fat, protein, or carbohydrates, which could make it an attractive option if you’re watching your calorie intake.

Considering these details, the green can is likely a better choice for someone on a diet who wants to minimize their caloric intake without sacrificing flavor or nutritional value. However, always consult the packaging or manufacturer’s website for more detailed and up-to-date nutrition information to ensure it meets your specific dietary needs and preferences.

<<Streaming response>>

Upon re-examining the original image provided, I notice that there are two cans of beverages, but they do not match the description I previously gave.

The can on the left is indeed white with a label indicating it is caffeine-free, and the one on the right is green with a similar label. However, upon closer inspection, I realize that both cans have their labels facing towards us, making it difficult to discern any specific details about the drinks.

To make an informed decision based on the provided nutrition facts, let’s assume that the information displayed on these cans is accurate and relevant to our choices:

  1. White Can (Left):
    • Calories: 0
    • Fat content: Not specified
    • Protein: Not specified
    • Carbohydrates: Not specified
    • Fiber: Not specified
  2. Green Can (Right):
    • Calories: 130
    • Fat content: 0%
    • Protein: 0g
    • Carbohydrates: 33g
    • Fiber: Not specified

Given these details, the white can appears to be a zero-calorie beverage without specifying other nutritional values. In contrast, the green can has a significantly higher calorie count of 130 per serving and does not provide information on its fat or protein content.

Decision: Based solely on the provided nutrition facts, the white can is likely a better choice for someone on a diet who wants to minimize their caloric intake without sacrificing flavor or nutritional value. However, it’s essential to consult the packaging or manufacturer’s website for more detailed and up-to-date nutrition information to ensure these drinks meet your specific dietary needs and preferences.

Explanation: Since both cans are caffeine-free, they could be suitable options for someone looking to avoid caffeine in their beverages. The white can is zero-calorie, which might appeal to those watching their calorie intake closely. However, it lacks detailed nutritional information, making it challenging to assess its suitability based solely on the provided details.

Conclusion: Based on the available nutrition facts and assuming they are accurate representations of these beverages, the white can appears to be a more attractive option for someone on a diet due to its zero-calorie nature. Nevertheless, always verify this information against the actual packaging or manufacturer’s website to ensure it aligns with your dietary requirements and preferences.

"Upon re-examining the original image provided, I notice that there are two cans of beverages, but they do not match the description I previously gave.\n\nThe can on the left is indeed white with a label indicating it is caffeine-free, and the one on the right is green with a similar label. However, upon closer inspection, I realize that both cans have their labels facing towards us, making it difficult to discern any specific details about the drinks.\n\nTo make an informed decision based on the provided nutrition facts, let's assume that the information displayed on these cans is accurate and relevant to our choices:\n\n1. **White Can (Left):**\n   * Calories: 0\n   * Fat content: Not specified\n   * Protein: Not specified\n   * Carbohydrates: Not specified\n   * Fiber: Not specified\n\n2. **Green Can (Right):**\n   * Calories: 130\n   * Fat content: 0%\n   * Protein: 0g\n   * Carbohydrates: 33g\n   * Fiber: Not specified\n\nGiven these details, the white can appears to be a zero-calorie beverage without specifying other nutritional values. In contrast, the green can has a significantly higher calorie count of 130 per serving and does not provide information on its fat or protein content.\n\n**Decision:** Based solely on the provided nutrition facts, the white can is likely a better choice for someone on a diet who wants to minimize their caloric intake without sacrificing flavor or nutritional value. However, it's essential to consult the packaging or manufacturer's website for more detailed and up-to-date nutrition information to ensure these drinks meet your specific dietary needs and preferences.\n\n**Explanation:** Since both cans are caffeine-free, they could be suitable options for someone looking to avoid caffeine in their beverages. The white can is zero-calorie, which might appeal to those watching their calorie intake closely. However, it lacks detailed nutritional information, making it challenging to assess its suitability based solely on the provided details.\n\n**Conclusion:** Based on the available nutrition facts and assuming they are accurate representations of these beverages, the white can appears to be a more attractive option for someone on a diet due to its zero-calorie nature. Nevertheless, always verify this information against the actual packaging or manufacturer's website to ensure it aligns with your dietary requirements and preferences."
im = PIL.Image.open("images/drinks.png"); type(im)
PIL.PngImagePlugin.PngImageFile
isinstance(im, PIL.Image.Image)
True
question = ("Generate nutritional facts about the two drinks"
            "in json format for easy comparison.")
a = llama32pi(question, image_url="images/drinks.png", stream=True); a

<<Streaming response>>

Here is a structured description of the image in two paragraphs, with some key points highlighted:

Image Description

The image shows a close-up of two cans of Sierra Mist brand beverages against a white background. The left can has a label that reads “CONTAINS NO JUICE” and displays nutritional facts for one serving size (330 mL). The right can is green in color with the same label on it, but only partially visible.

Nutritional Facts

Here are the key points from the nutritional facts on both cans:

  • Calories: 0 calories per serving
  • Sodium: 0mg per serving
  • Total Carbohydrates: 0g per serving
  • Added Sugars: 0% of daily value (DV)
  • Protein: 0g per serving
  • Total Fat: 0g per serving
  • Saturated Fat: 0g per serving
  • Trans Fat: 0g per serving

Note: The image does not provide a clear view of the entire nutritional facts label on the right can, so some information may be missing.

'Here is a structured description of the image in two paragraphs, with some key points highlighted:\n\n**Image Description**\n\nThe image shows a close-up of two cans of Sierra Mist brand beverages against a white background. The left can has a label that reads "CONTAINS NO JUICE" and displays nutritional facts for one serving size (330 mL). The right can is green in color with the same label on it, but only partially visible.\n\n**Nutritional Facts**\n\nHere are the key points from the nutritional facts on both cans:\n\n* **Calories**: 0 calories per serving\n* **Sodium**: 0mg per serving\n* **Total Carbohydrates**: 0g per serving\n* **Added Sugars**: 0% of daily value (DV)\n* **Protein**: 0g per serving\n* **Total Fat**: 0g per serving\n* **Saturated Fat**: 0g per serving\n* **Trans Fat**: 0g per serving\n\nNote: The image does not provide a clear view of the entire nutritional facts label on the right can, so some information may be missing.'
question = ("Generate nutritional facts about the two drinks in the image"
            "in json format for easy comparison.")
a = llama32opi(question, system_prompt, image_url="images/drinks.png", format='json', stream=True); a

<<Streaming response>>

Here is a detailed breakdown of the nutritional information for each drink:

Drink 1: Coca-Cola

  • Serving Size: 12 fl oz (355 ml)
  • Servings per Container: 1
  • Calories: 140
  • Total Fat: 0g
  • Sodium: 39mg
  • Total Carbohydrates: 41g
    • Sugars: 41g
  • Protein: 0g

Drink 2: Pepsi

  • Serving Size: 12 fl oz (355 ml)
  • Servings per Container: 1
  • Calories: 150
  • Total Fat: 0g
  • Sodium: 40mg
  • Total Carbohydrates: 41g
    • Sugars: 41g
  • Protein: 0g

Comparison of Nutritional Facts

  • Calories: Pepsi has 10 more calories than Coca-Cola.
  • Total Fat: Both drinks are fat-free.
  • Sodium: Both drinks have similar amounts of sodium.
  • Total Carbohydrates: Both drinks have the same amount of total carbohydrates and sugars.

Based on this comparison, it is clear that both drinks have similar nutritional profiles. However, if I had to choose a healthier option based solely on these facts, I would recommend Coca-Cola due to its slightly lower calorie count.

Healthier Option: Coca-Cola

Reasoning: While neither drink is particularly healthy, Coca-Cola has 10 fewer calories than Pepsi. This is the only notable difference between the two drinks in terms of nutritional content. Therefore, based on this comparison, I would recommend Coca-Cola as the healthier option.

'Here is a detailed breakdown of the nutritional information for each drink:\n\n**Drink 1: Coca-Cola**\n\n* **Serving Size:** 12 fl oz (355 ml)\n* **Servings per Container:** 1\n* **Calories:** 140\n* **Total Fat:** 0g\n* **Sodium:** 39mg\n* **Total Carbohydrates:** 41g\n\t+ Sugars: 41g\n* **Protein:** 0g\n\n**Drink 2: Pepsi**\n\n* **Serving Size:** 12 fl oz (355 ml)\n* **Servings per Container:** 1\n* **Calories:** 150\n* **Total Fat:** 0g\n* **Sodium:** 40mg\n* **Total Carbohydrates:** 41g\n\t+ Sugars: 41g\n* **Protein:** 0g\n\n**Comparison of Nutritional Facts**\n\n* Calories: Pepsi has 10 more calories than Coca-Cola.\n* Total Fat: Both drinks are fat-free.\n* Sodium: Both drinks have similar amounts of sodium.\n* Total Carbohydrates: Both drinks have the same amount of total carbohydrates and sugars.\n\nBased on this comparison, it is clear that both drinks have similar nutritional profiles. However, if I had to choose a healthier option based solely on these facts, I would recommend Coca-Cola due to its slightly lower calorie count.\n\n**Healthier Option:** Coca-Cola\n\n**Reasoning:** While neither drink is particularly healthy, Coca-Cola has 10 fewer calories than Pepsi. This is the only notable difference between the two drinks in terms of nutritional content. Therefore, based on this comparison, I would recommend Coca-Cola as the healthier option.'
print(a)
Here is a detailed breakdown of the nutritional information for each drink:

**Drink 1: Coca-Cola**

* **Serving Size:** 12 fl oz (355 ml)
* **Servings per Container:** 1
* **Calories:** 140
* **Total Fat:** 0g
* **Sodium:** 39mg
* **Total Carbohydrates:** 41g
    + Sugars: 41g
* **Protein:** 0g

**Drink 2: Pepsi**

* **Serving Size:** 12 fl oz (355 ml)
* **Servings per Container:** 1
* **Calories:** 150
* **Total Fat:** 0g
* **Sodium:** 40mg
* **Total Carbohydrates:** 41g
    + Sugars: 41g
* **Protein:** 0g

**Comparison of Nutritional Facts**

* Calories: Pepsi has 10 more calories than Coca-Cola.
* Total Fat: Both drinks are fat-free.
* Sodium: Both drinks have similar amounts of sodium.
* Total Carbohydrates: Both drinks have the same amount of total carbohydrates and sugars.

Based on this comparison, it is clear that both drinks have similar nutritional profiles. However, if I had to choose a healthier option based solely on these facts, I would recommend Coca-Cola due to its slightly lower calorie count.

**Healthier Option:** Coca-Cola

**Reasoning:** While neither drink is particularly healthy, Coca-Cola has 10 fewer calories than Pepsi. This is the only notable difference between the two drinks in terms of nutritional content. Therefore, based on this comparison, I would recommend Coca-Cola as the healthier option.