Meal identification and calorie estimation method and system based on YOLOv8 model

The YOLOv8 model is used for meal recognition and calorie estimation, which solves the problems of recognition accuracy and estimation accuracy in complex meal scenarios, and realizes personalized health management and efficient calorie monitoring.

CN120599600APending Publication Date: 2025-09-05WUHAN INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510595885.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

Existing food recognition and calorie estimation methods lack recognition accuracy when dealing with complex dining scenarios, and fail to effectively consider cooking methods, portion sizes, and individual differences, resulting in large errors in estimation results.

Method used

The YOLOv8 model is used for meal recognition. Through training data set division, model optimization and performance verification, combined with the nutrition database and individual data, food category recognition and calorie estimation are achieved.

Benefits of technology

It improves the accuracy of meal recognition and calorie estimation, is suitable for smart terminals and edge computing platforms, and supports personalized health management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120599600A_ABST
    Figure CN120599600A_ABST
Patent Text Reader

Abstract

The invention provides a food recognition and calorie estimation method and system based on a YOLOv8 model, and the method comprises the steps: inputting a food image, detecting food in the image in real time based on the YOLOv8 model, recognizing the type of the food, combining the cooking mode and component information of the food, and dynamically calculating the calorie content. The functions of accurately identifying the food in the meal scene and efficiently estimating the calorie are realized. According to the method, the detection precision is greatly improved while the advantage of detection speed is reserved, and the problems that a traditional target detection method is prone to background interference and low in recognition accuracy in meal recognition are effectively solved. According to the method, the practical application capability of the model in a specific scene is greatly improved, and a reliable basis is provided for subsequent calorie estimation and personalized health intervention. The method has high robustness, transportability and real-time performance, is suitable for various intelligent terminals and edge computing platforms, can be widely applied to the fields of intelligent restaurants, nutrition analysis, health management and the like, and has good popularization prospects and industrialization value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision and nutrition and health technology, and specifically relates to a meal recognition and calorie estimation method and system based on the YOLOv8 model. Background Art

[0002] With rising health awareness, people are increasingly concerned about their diet, particularly calorie intake. Traditional calorie estimation methods rely on users manually entering or selecting simplified food lists. This not only makes the estimation process cumbersome but also susceptible to user subjectivity. Significant drawbacks include low efficiency, strong subjectivity, and large errors. Accuracy is particularly difficult to guarantee for complex meal situations, such as mixed dishes or takeout meals.

[0003] The rapid development of computer vision technology in recent years has provided new insights into food recognition. Using image processing techniques, computers can identify food categories in images and estimate their calorie counts. However, existing computer vision-based food recognition technologies still face several challenges. For example, while current mainstream object detection models (such as Faster R-CNN, SSD, and YOLO) perform well in general object detection tasks, they lack accuracy and robustness when dealing with complex scenarios such as meals, due to the diverse forms and complex ingredients of meals. Furthermore, these general-purpose models are not specifically optimized for the distinct characteristics of meals, such as the differences between breakfast and lunch (ingredients, cooking methods, portion sizes, etc.).

[0004] Another significant issue is that current food recognition systems typically rely on fixed calorie databases for matching. However, fixed databases cannot dynamically reflect changes in actual meals. For example, different cooking methods (such as frying, steaming, or grilling) can significantly affect the calorie content of food, and existing systems fail to effectively account for these factors. Furthermore, meal size and individual user differences (such as gender, age, and weight) are not factored into the estimation model, resulting in significant deviations between calorie estimates and actual intake.

[0005] Therefore, given the limitations of current food recognition and calorie estimation methods, a more accurate, automated, and personalized solution is urgently needed. This solution must not only improve recognition accuracy for complex meal scenarios but also dynamically estimate calorie counts based on factors such as cooking methods, portion sizes, and individual differences, providing more accurate calorie estimates. This new technology will improve the efficiency and accuracy of dietary monitoring, helping users achieve more scientific dietary management. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a meal recognition and calorie estimation method and system based on the YOLOv8 model, which is used to accurately identify food in meal scenes and efficiently estimate calories.

[0007] The technical solution adopted by the present invention to solve the above technical problems is: a meal recognition and calorie estimation method based on the YOLOv8 model, comprising the following steps: S1: Obtain training data and build a food image dataset with labeled information; S2: Divide the food image dataset by mealtime scenario and input it into the YOLOv8-based object detection model for detection training and performance verification; S3: Obtaining the standard calorie value based on the detection results of the target detection model and estimating the food portion; S4: Verify the accuracy of the object detection model in identifying food types and estimating calories; S5: Statistically analyze the multi-day image detection results to generate a user's calorie intake trend and nutritional structure assessment report.

[0008] According to the above scheme, in step S1, the specific steps are: S11: Filter food images from the training data according to the rules of clear boundaries and prioritizing single foods; S12: Combined with the generative adversarial network to generate more than two categories of food images, and simultaneous manual quality verification to ensure that the images are reasonable and effective; S13: Manually annotate and verify the bounding boxes and category labels of food images.

[0009] According to the above scheme, in step S2, the specific steps are: S21: Divide the dataset into training and validation sets according to different mealtime scenarios; use a 50-fold cross-validation strategy to obtain model performance indicators; S22: Set image input parameters, configure training hyperparameters, design loss functions and data augmentation strategies, train an object detection model based on YOLOv8, and output food category labels; S23: Verify the performance of the trained YOLOv8-based object detection model. Performance indicators include average detection accuracy, recall rate, and F1 value.

[0010] Furthermore, in step S22, the hyperparameters include training rounds, batch size, number of data loading threads, optimizer selection, adaptive gradient update strategy and initial learning rate, and the learning rate scheduling strategy adopts cosine annealing scheduling; a YOLOv8 custom loss function is adopted, including bounding box regression loss, category prediction loss and distributed focal loss, as well as the weight setting of each loss item.

[0011] Furthermore, in step S23, the average detection accuracy is calculated by the total number of categories. The average precision of the class when the IoU threshold is 0.5 is used to measure the comprehensive detection ability of the target detection model on all categories; Recall is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of missed targets. It is used to measure the proportion of all real targets that the model can correctly identify. The F1 value is the harmonic mean of precision and recall, which is used to comprehensively reflect the overall performance of the model; Precision is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of incorrect classifications.

[0012] Furthermore, in step S3, the specific steps are: S31: Match the food category label output by the target detection model with the standard food nutritional information in the nutritional database to obtain the nutritional parameters per unit weight; S32: Calculate food quantities by gram weight or piece weight based on the food category labels output by the target detection model; when calculating by piece weight, a preset standard weight is used.

[0013] According to the above scheme, in step S4, the specific steps are: S41: Set different lighting conditions and multiple food detection scenarios; S42: Verify the accuracy of food recognition and the comparison of calorie estimates with actual values ​​for each test image; S43: Continuously test multiple test photos to obtain the overall recognition accuracy.

[0014] According to the above scheme, in step S5, the specific steps are: S51: Random sampling was used to select research subjects from the user population. The food intake of each meal by the research subjects was counted. The calorie intake of each meal was calculated based on the calorie value of each food. The calorie intake trend of the research subjects within a day was displayed using data visualization methods. S52: Propose suggestions for optimizing the nutritional structure based on the research subjects’ calorie intake problems and generate a nutritional structure assessment report.

[0015] A meal recognition and calorie estimation system based on the YOLOv8 model. The data acquisition submodule is used to obtain training data and build a food image dataset with label information; The model training submodule is used to divide the food image dataset according to meal time scenarios and input it into the YOLOv8-based object detection model for detection training and performance verification; Nutrition estimation submodule, which is used to obtain standard calorie values ​​and estimate food portions based on the detection results of the target detection model; The verification submodule is used to verify the accuracy of the object detection model in identifying food types and estimating calories; The statistical analysis submodule is used to statistically analyze the multi-day image detection results and generate a user's calorie intake trend and nutritional structure assessment report.

[0016] A computer memory stores a computer program executable by a computer processor, wherein the computer program executes a meal recognition and calorie estimation method based on a YOLOv8 model.

[0017] The beneficial effects of the present invention are: 1. The present invention provides a meal recognition and calorie estimation method and system based on the YOLOv8 model. By inputting a meal image, the YOLOv8 model is used to detect the food in the image in real time, identify the food category, and dynamically calculate the calorie content based on the cooking method and portion information of the food. This achieves the functions of accurately identifying food in meal scenes and efficiently estimating calories.

[0018] 2. The food recognition model constructed in this invention based on the YOLOv8s network structure can more accurately extract the features of food targets in images, greatly improving the detection accuracy while retaining the advantage of detection speed, and effectively solving the problem that traditional target detection methods are easily affected by background interference and have low recognition accuracy in food recognition.

[0019] 3. This paper applies the detection model to breakfast and lunch image subsets respectively, and combines them with college students' dietary data for category optimization, which greatly improves the practical application ability of the model in specific scenarios and provides a reliable foundation for subsequent calorie estimation and personalized health intervention.

[0020] 4. This paper uses the YOLOv8 target detection algorithm to test multiple data sets, demonstrating high accuracy in meal recognition and calorie estimation, and has strong robustness in processing meal scenarios.

[0021] 5. The present invention has strong portability and real-time performance, and is suitable for the deployment requirements of various smart terminals and edge computing platforms. It can be widely used in smart restaurants, nutritional analysis, health management and other fields, and has good promotion prospects and industrialization value.

[0022] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1 4 is a flowchart of the YOLOv8 algorithm according to an embodiment of the present invention.

[0025] Figure 2 This is a diagram showing a partial recognition effect of a breakfast model according to an embodiment of the present invention.

[0026] Figure 3 This is a diagram showing a partial recognition effect of the lunch model according to an embodiment of the present invention.

[0027] Figure 4 This is a line chart showing the calorie trends for breakfast, lunch, and dinner for student A in an embodiment of the present invention for one week.

[0028] Figure 5 This is a line chart showing the calorie trends for breakfast, lunch, and dinner for student B in an embodiment of the present invention for one week.

[0029] Figure 6 This is a line chart showing the calorie trends for breakfast, lunch, and dinner for student C in an embodiment of the present invention for one week.

[0030] Figure 7 is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0032] Example 1 See also Figure 7 The specific steps of a meal recognition and calorie estimation method based on the YOLOv8 model are as follows: S1: Obtain training data and build a food image dataset with labeled information; S2: Divide the food image dataset by mealtime scenario and input it into the YOLOv8-based object detection model for detection training and performance verification; S3: Obtaining the standard calorie value based on the detection results of the target detection model and estimating the food portion; S4: Verify the accuracy of the object detection model in identifying food types and estimating calories; S5: Statistically analyze the multi-day image detection results to generate a user's calorie intake trend and nutritional structure assessment report.

[0033] Furthermore, in step S1, the specific steps are: S11: Filter food images from the training data according to the rules of clear boundaries and prioritizing single foods; S12: Combined with the generative adversarial network to generate more than two categories of food images, and simultaneous manual quality verification to ensure that the images are reasonable and effective; S13: Manually annotate and verify the bounding boxes and category labels of food images.

[0034] In step S2, the specific steps are: S21: Divide the dataset into training and validation sets according to different mealtime scenarios; use a 50-fold cross-validation strategy to obtain model performance indicators; S22: Set image input parameters, configure training hyperparameters, design loss functions and data augmentation strategies, train an object detection model based on YOLOv8, and output food category labels; S23: Verify the performance of the trained YOLOv8-based object detection model. Performance indicators include average detection accuracy, recall rate, and F1 value.

[0035] Furthermore, in step S22, the hyperparameters include training rounds, batch size, number of data loading threads, optimizer selection, adaptive gradient update strategy and initial learning rate, and the learning rate scheduling strategy adopts cosine annealing scheduling; the YOLOv8 custom loss function is adopted, including bounding box regression loss, category prediction loss and distributed focal loss, as well as the weight setting of each loss item.

[0036] Furthermore, in step S23, the average detection accuracy is calculated by the total number of categories. The average precision of the class when the IoU threshold is 0.5 is used to measure the comprehensive detection ability of the target detection model on all categories; Recall is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of missed detections. It is used to measure the proportion of all real targets that the model can correctly identify. The F1 value is the harmonic mean of precision and recall, which is used to comprehensively reflect the overall performance of the model; Precision is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of incorrect classifications.

[0037] Furthermore, in step S3, the specific steps are: S31: Match the food category label output by the target detection model with the standard food nutritional information in the nutritional database to obtain the nutritional parameters per unit weight; S32: Calculate food quantities by gram weight or piece weight based on the food category labels output by the target detection model; when calculating by piece weight, a preset standard weight is used.

[0038] In step S4, the specific steps are: S41: Set different lighting conditions and multiple food detection scenarios; S42: Verify the accuracy of food recognition and the comparison of calorie estimates with actual values ​​for each test image; S43: Continuously test multiple test photos to obtain the overall recognition accuracy.

[0039] In step S5, the specific steps are: S51: Random sampling was used to select research subjects from the user population. The food intake of each meal by the research subjects was counted. The calorie intake of each meal was calculated based on the calorie value of each food. The calorie intake trend of the research subjects within a day was displayed using data visualization methods. S52: Based on the gap between the calorie intake of the research subjects and the recommended calorie intake in the nutrition database, make suggestions for optimizing the nutritional structure and generate a nutritional structure assessment report.

[0040] This embodiment inputs meal images, detects the food in the image in real time based on the YOLOv8 model, identifies the food category, and dynamically calculates the calorie content based on the food's cooking method and portion information, thus achieving the functions of accurately identifying food in meal scenes and efficiently estimating calories.

[0041] Example 2 The steps of this embodiment are the same as those of embodiment 1, except that each step is applied to a specific example. Specifically, the following steps are included: S1: Collect food images and build a dataset with images and label information; the specific steps are: S11: Image acquisition: To ensure diversity and representativeness in the training data, the data collection platform covers multiple commonly used social media platforms. Food images were manually screened to ensure that these images reflect the frequency of common food items and are easily distinguishable from other foods. When selecting images, we prioritized the uniqueness and distinguishability of the food items, particularly clear and concise presentation. For example, breakfast images primarily depict individual items like fried dough sticks or steamed buns. Other meals, such as lotus root and pork rib soup and braised chicken, are typically presented in a bowl or pot, making them more difficult to accurately segment into individual items. Therefore, during image collection, we prioritized images with clear backgrounds, clear test subjects, and a small number of individual items (preferably individual items). This ensures that the food items in the images are the primary subject of recognition, facilitating subsequent model training and testing. This targeted image screening effectively improves the model's ability to recognize different types of food, further enhancing its generalization.

[0042] S12: Generate AI image: To supplement the categories with fewer samples in the actual captured data (such as mixed breakfast, fried dough sticks, and steamed buns), a generative adversarial network (GAN) was used to synthesize highly realistic food images. These generated images not only increase the diversity of the dataset but also address the issue of scarce categories, thereby improving the model's recognition ability for rare categories. The generated images were rigorously manually verified to ensure quality and authenticity to avoid affecting model training results.

[0043] S13: Data annotation: Labeling food images is a critical step in training high-quality object detection models. We used manual labeling, using the Make Sense website, to accurately annotate food images with bounding boxes and category labels. Manual verification ensured labeling accuracy exceeded 99%, ensuring high-quality training data and improving model accuracy and robustness.

[0044] S2: Use the YOLOv8 model to process multiple image classes and train the model to detect food objects. The model is divided into a breakfast model and a lunch model, each of which supports the recognition of eight common food categories. The specific steps are as follows: S21: Training set and test set division: In this model training, the dataset was divided into a training set (80%) and a validation set (20%) according to the breakfast and lunch scenarios to ensure category balance.

[0045] Assume the total number of samples is , the division results are as follows:

[0046] During the training process, in order to improve the robustness and accuracy of the model, a five-fold cross-validation strategy was adopted. The dataset was divided into five non-overlapping subsets. In each iteration, one of the subsets is selected as the validation set, and the remaining four subsets are used as the training set. The training is repeated for five rounds, and the five validation results are averaged to obtain the final model performance index:

[0047] S22: Model training: To achieve high-precision food object detection, we trained an object detection model based on the YOLOv8s network structure and designed a systematic training strategy, including image input parameter setting, training hyperparameter configuration, loss function design, and data augmentation strategy. The details are as follows: The image input size used for training is set to Pixels, denoted as:

[0048] This ensures efficient use of computing resources while maintaining image detail information.

[0049] The following hyperparameters are set during the training phase: Training rounds:

[0050] Batch size:

[0051] Number of data loading threads:

[0052] Optimizer selection: AdamW, adaptive gradient update strategy Initial learning rate:

[0053] Learning rate scheduling strategy: Cosine Annealing is used, and its changing rule is:

[0054] in, Indicates the The learning rate of the round, is the total number of rounds, is the minimum learning rate.

[0055] This model uses the YOLOv8 custom loss function , by the bounding box regression loss , category prediction loss Distributed focal loss Common components:

[0056] Among them, the loss item weight is set as follows:

[0057]

[0058]

[0059] S23: Performance Verification: After training, the YOLOv8-based object detection model was systematically validated for performance. Specific metrics included mean average precision (mAP@0.5), recall, and F1 score. The calculation methods for each performance metric are as follows: Mean Average Precision (MAP) is used to measure the comprehensive detection capability of the target detection model across all categories and is defined as follows:

[0060] in, is the total number of categories, For the The average precision (AveragePrecision) of the class when the IoU threshold is 0.5.

[0061] The recall rate is used to measure the proportion of all true targets that the model can correctly identify. The calculation formula is as follows:

[0062] in, represents the number of correct classifications, Indicates the number of missed targets.

[0063] The F1 value is the harmonic mean of precision and recall, which comprehensively reflects the overall performance of the model:

[0064] Among them, FP is the number of samples that are not originally classified as this type but are mistakenly classified as this type. The precision is defined as:

[0065] S3: Match the food name in the test result with the nutrition database to find the corresponding standard calorie value; the specific steps are as follows: S31: Nutrition data integration module: After completing meal image recognition, we further introduce standard food nutritional information from the nutrition database to achieve automatic matching of food recognition and nutritional data: Match the food category labels output by the model with the standardized food names in the nutrition database to obtain the nutritional parameters per unit weight (e.g. per 100 grams):

[0066] in, Indicates the calories per 100 grams of food.

[0067] S32: Food portion and calorie calculation model: To improve the accuracy of calorie estimation, a food portion estimation model based on image analysis was designed, which was combined with a nutritional information database to calculate the total energy of each meal. The specific technical implementation is as follows: We use a method to calculate food weights directly based on 100 grams. That is, based on the classification labels of the food images, we assume that the weight of each food is 100 grams. The formula is as follows:

[0068] in, Indicates the actual weight of the food (g), assuming it is 100 grams.

[0069] Typical classification estimation method: For some common foods (such as buns, steamed buns, chicken legs, etc.), the "item estimation" strategy is adopted: categorize according to appearance size and characteristics (such as large package, medium package, small package), and preset standard weight for each category , the estimation can be completed without precise weighing.

[0070] Estimation formula by piece:

[0071] S4: Estimate the total calorie content of the entire image based on the identified food types. The specific steps are as follows: S41: Test image requirements: To ensure the model's broad adaptability, this example was tested under various lighting conditions (indoor and outdoor) and in a variety of food scenarios. The test set contains a large number of images, ensuring coverage of various complex scenes and diverse dining scenarios. Each test image contains multiple food varieties as well as a single food variety, ensuring that the model can maintain high recognition accuracy in a variety of scenarios. The coverage of the test set can be expressed as:

[0072] in, is the number of images in the test set. The number of food types contained in each test image can be expressed as:

[0073] in, Indicates the The types of food in the picture, is the number of food types in each test image.

[0074] S42: Automated test scripts: To improve system development efficiency and comprehensive testing, we wrote an automated test script to verify the accuracy of food recognition for each test image. Each test image was tested individually, and the accuracy of the model recognition and the comparison of the food's calorie estimate with the actual calorie value were recorded. The specific automated test process is as follows: Each test image corresponds to a different food type. An automated script calls the model to identify the food and records the calorie estimate it outputs. The calorie content range for each food type is predefined; for example, the calorie range for a particular food is [C_min, C_max].

[0075] Recognition accuracy ( ) is calculated as:

[0076] in, is the total number of food types in each image, and the number of correctly identified foods indicates the number of foods successfully identified by the model.

[0077] Conduct continuous testing on multiple test photos and record the accuracy of food recognition in each picture ( ). After multiple tests, the overall recognition accuracy is obtained:

[0078] in, is the recognition accuracy of the entire test set, For the The food recognition accuracy of the image.

[0079] S5: Statistically analyze the multi-day image detection results to generate a user's calorie intake trend and nutritional structure assessment report; the specific steps are as follows: S51: Generate user's calorie intake trend: This embodiment adopts the random sampling method, randomly selecting three students from the population as research subjects, and synchronously tracking and recording three meals a day for each selected student, and recording detailed statistics of the food consumed.

[0080] For each food recorded, the calorie count is calculated based on its calorie value. The calorie intake per meal (H) is calculated using the following formula:

[0081] in represents the caloric value of the i-th food, and n is the number of food types consumed at the meal. The caloric value range of each food is [C_min, C_max]. The caloric intake of each meal is the sum of the caloric values ​​of the foods consumed within this caloric range.

[0082] Based on this data, we used data visualization methods to generate a line chart to visually display the user's daily calorie intake trends. This line chart clearly shows the dynamic changes in each student's calorie intake between meals, providing a visual basis for in-depth analysis of individual dietary calorie intake patterns.

[0083] A. User calorie intake trend analysis: According to system records, user A's breakfast calorie intake was approximately 320 kcal, mainly composed of carbohydrate foods, with a low proportion of protein and fat; lunch calorie intake was approximately 680 kcal, covering staple foods, meat and vegetables, with a relatively balanced calorie structure, but the total amount was relatively high; dinner calorie intake further increased to approximately 780 kcal, exceeding the recommended value, indicating a trend of excessive calorie intake at dinner.

[0084] B. User calorie intake trend analysis: System analysis results show that user B's breakfast calorie intake is about 230 kcal, which is generally low and the protein intake is insufficient; lunch calorie intake is about 600 kcal, but the food types are single and lack vegetables and high-quality protein sources; dinner calorie intake is maintained at around 550 kcal, with a relatively reasonable structure, showing a certain degree of control ability, but breakfast and lunch still need to be optimized.

[0085] C. User calorie intake trend analysis: User C's breakfast calorie intake fluctuates greatly, with a minimum of 190 kcal and a maximum of 500 kcal, indicating unstable intake; lunch calorie intake is relatively constant, with an average of 620 kcal, but contains a high proportion of fried foods, resulting in a high calorie density; dinner calorie intake is approximately 720 kcal, with a relatively high fat content, indicating a characteristic of heavy energy intake at dinner.

[0086] S52: Nutritional structure assessment report: All three students have varying degrees of issues with caloric intake, and their nutritional structure needs to be optimized. We recommend that Student A maintain consistent food types and portions for all three meals and manage dinner calories appropriately; Student B increase breakfast calorie intake appropriately and diversify lunch food; and Student C avoid large fluctuations in breakfast calories, maintain a balanced lunch diet, and rationally adjust dinner to reduce excessive intake of high-calorie foods. Further detailed food type analysis can be conducted to support more targeted nutritional interventions.

[0087] Simulation experiment: In this embodiment, a number of simulation experiments were conducted to verify the effectiveness of the meal recognition and calorie estimation method based on YOLOv8.

[0088] This experiment was based on a self-built meal image dataset, which contains 16 typical meal images from breakfast and lunch scenes, including common food items such as steamed buns, steamed buns, fried rice, rice noodles, and noodles. The image data was primarily sourced from online platforms and constructed through manual screening and detailed annotation using the MakeSense platform.

[0089] The entire dataset is classified into breakfast and lunch categories and divided into training set (80%), validation set (10%) and test set (10%) respectively. A five-fold cross-validation method is used to improve the robustness and generalization ability of the model.

[0090] The model is trained using the YOLOv8s structure with an input image size of 640×640. It is optimized using the AdamW optimizer with an initial learning rate of 0.01 and a cosine annealing scheduling strategy to stabilize the training process.

[0091] In the performance evaluation phase, indicators such as mean average precision (mAP@0.5), recall rate (Recall), and F1 value are used for quantitative comparison. Among them: The mean average precision (mAP@0.5) is calculated as follows:

[0092] in For the The average precision of the class, is the number of categories.

[0093] Recall is defined as:

[0094] Precision is defined as:

[0095] The F1 value is the harmonic mean of precision and recall:

[0096] To further evaluate the application performance of the system in daily diet analysis, a simulation experiment based on actual user meal recognition and nutritional estimation was designed and implemented. The details are as follows: Using a random sampling method, we selected three typical individuals from the user population (referred to as User A, User B, and User C) and simultaneously recorded and analyzed their three meals a day. During the experiment, the system identified the food categories actually consumed by the users and, in conjunction with its built-in nutritional database, estimated and calculated the calorie content of each meal.

[0097] After structuring all data, the system generates a calorie intake trend chart based on the time dimension (breakfast, lunch, and dinner), which displays the calorie distribution and fluctuations across the three meals in a broken line format. This trend chart helps analyze the stability of individual dietary intake and the rationality of energy balance.

[0098] User A: Breakfast intake is about 320 kcal, mainly staple foods, with low protein intake; lunch intake is about 680 kcal, with a relatively balanced structure; dinner calories rise to 780 kcal, exceeding the recommended intake, and there is a problem of dinner being too heavy.

[0099] User B: Breakfast intake is 230 kcal, which is obviously too low. Lunch is 600 kcal, with a single food type. Dinner is 550 kcal, with an acceptable structure, but breakfast and lunch need to be optimized.

[0100] User C: Breakfast fluctuates between 190–500 kcal and is unstable; lunch is 620 kcal, mainly fried foods; dinner is about 720 kcal, with a high fat content.

[0101] Based on the above trends and data, the system outputs preliminary nutritional analysis recommendations as follows: A. Users should reduce dinner calories and balance the distribution of three meals; B. Users need to increase breakfast intake and improve the structure of lunch ingredients; C. Users should control breakfast fluctuations, reduce high-fat foods at lunch, and adjust the fat ratio of dinner.

[0102] The above tests show that the system of the present invention not only has good image recognition capabilities, but can also complete structured nutritional analysis in actual dietary scenarios, support visual evaluation and health management recommendation output, and has the potential for practical application.

[0103] Figure 1 This is the YOLOv8 algorithm process. Figure 2 Figure 3 shows the partial recognition effect of the breakfast model. Figure 4 shows the partial recognition effect of the lunch model. Figure 4 This is a line chart showing the calorie trend of Student A’s breakfast, lunch, and dinner for a week. Figure 5 This is a line chart showing the calorie trend for student B’s breakfast, lunch, and dinner for a week. Figure 6 This is a line chart showing the calorie trend for student C’s breakfast, lunch, and dinner for a week. Figure 7 Flow chart of the method of the present invention.

[0104] Experimental results show that the method proposed in this invention has good recognition accuracy and estimation stability in actual scenarios, and can effectively assist users in scientific diet management.

[0105] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0106] Example 3 This embodiment is used to implement the principles of the above method embodiment to build a meal recognition and calorie estimation system based on the YOLOv8 model, including a data acquisition submodule, a model training submodule, a nutrition estimation submodule, a verification submodule, and a statistical analysis submodule; The data acquisition submodule is used to obtain training data and build a food image dataset with label information; The model training submodule is used to divide the food image dataset according to meal time scenarios and input it into the YOLOv8-based object detection model for detection training and performance verification; Nutrition estimation submodule, which is used to obtain standard calorie values ​​and estimate food portions based on the detection results of the target detection model; The verification submodule is used to verify the accuracy of the object detection model in identifying food types and estimating calories; The statistical analysis submodule is used to statistically analyze the multi-day image detection results and generate a user's calorie intake trend and nutritional structure assessment report.

[0107] Each sub-module is mainly used to implement each step of the method embodiment, which will not be described in detail here.

[0108] It should be pointed out that, according to the needs of implementation, the various steps / components described in this application can be split into more steps / components, or two or more steps / components or partial operations of steps / components can be combined into new steps / components to achieve the purpose of the present invention.

[0109] This embodiment also includes a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; the memory stores a computer program, and when the program is executed by the processor, the processor performs the steps of a meal recognition and calorie estimation method based on the YOLOv8 model.

[0110] This embodiment also provides a computer-readable storage medium having executable instructions stored thereon. When the instructions are executed by a processor, the processor implements a meal recognition and calorie estimation method based on the YOLOv8 model.

[0111] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware.

[0112] Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0113] This application is described with reference to the flowcharts of the method and computer program product according to Example 1 of the application and the block diagram of the device (system) according to Example 3. It should be understood that each process or block in the flowchart or block diagram, as well as combinations of processes or blocks in the flowchart or block diagram, can be implemented by computer program instructions.

[0114] These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce the instructions for implementing the process Figure 1 a process or multiple processes or boxes Figure 1 A meal recognition and calorie estimation system based on the YOLOv8 model that specifies the functions in one or more boxes.

[0115] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes or boxes Figure 1 The function specified in one or more boxes.

[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes or boxes Figure 1 The steps of a meal recognition and calorie estimation method based on the YOLOv8 model are specified in one or more boxes.

[0117] The above embodiments are intended only to illustrate the design concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. The scope of protection of the present invention is not limited to the above embodiments. Therefore, any equivalent changes or modifications made based on the principles and design concepts disclosed in the present invention are within the scope of protection of the present invention.

Claims

1. A meal recognition and calorie estimation method based on the YOLOv8 model, characterized by: The following steps are involved: S1: Obtain training data and build a food image dataset with labeled information; S2: Divide the food image dataset by mealtime scenario and input it into the YOLOv8-based object detection model for detection training and performance verification; S3: Obtaining the standard calorie value based on the detection results of the target detection model and estimating the food portion; S4: Verify the accuracy of the object detection model in identifying food types and estimating calories; S5: Statistically analyze the multi-day image detection results to generate a user's calorie intake trend and nutritional structure assessment report.

2. The meal recognition and calorie estimation method based on the YOLOv8 model according to claim 1, characterized in that: In the step S1, the specific steps are: S11: Filter food images from the training data according to the rules of clear boundaries and prioritizing single foods; S12: Combined with the generative adversarial network to generate more than two categories of food images, and simultaneous manual quality verification to ensure that the images are reasonable and effective; S13: Manually annotate and verify the bounding boxes and category labels of food images.

3. The meal recognition and calorie estimation method based on the YOLOv8 model according to claim 1, characterized in that: In the step S2, the specific steps are: S21: Divide the dataset into training and validation sets according to different mealtime scenarios; use a 50-fold cross-validation strategy to obtain model performance indicators; S22: Set image input parameters, configure training hyperparameters, design loss functions and data augmentation strategies, train an object detection model based on YOLOv8, and output food category labels; S23: Verify the performance of the trained YOLOv8-based object detection model. Performance indicators include average detection accuracy, recall rate, and F1 value.

4. The meal recognition and calorie estimation method based on the YOLOv8 model according to claim 3, characterized in that: In step S22, the hyperparameters include training rounds, batch size, number of data loading threads, optimizer selection, adaptive gradient update strategy and initial learning rate, and the learning rate scheduling strategy adopts cosine annealing scheduling; the YOLOv8 custom loss function is adopted, including bounding box regression loss, category prediction loss and distributed focal loss, as well as the weight setting of each loss item.

5. The method for meal recognition and calorie estimation based on the YOLOv8 model according to claim 3, characterized in that: In step S23, the average detection accuracy is the number of categories. The average precision of the class when the IoU threshold is 0.5 is used to measure the comprehensive detection ability of the target detection model on all categories; Recall is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of missed detections. It is used to measure the proportion of all real targets that the model can correctly identify. The F1 value is the harmonic mean of precision and recall, which is used to comprehensively reflect the overall performance of the model; Precision is the ratio of the number of correct classifications to the sum of the number of correct classifications and the number of incorrect classifications.

6. The method for meal recognition and calorie estimation based on the YOLOv8 model according to claim 3, characterized in that: In the step S3, the specific steps are: S31: Match the food category label output by the target detection model with the standard food nutritional information in the nutritional database to obtain the nutritional parameters per unit weight; S32: Calculate food quantities by gram weight or piece weight based on the food category labels output by the target detection model; when calculating by piece weight, a preset standard weight is used.

7. The method for meal recognition and calorie estimation based on the YOLOv8 model according to claim 1, characterized in that: In the step S4, the specific steps are: S41: Set different lighting conditions and multiple food detection scenarios; S42: Verify the accuracy of food recognition and the comparison of calorie estimates with actual values ​​for each test image; S43: Continuously test multiple test photos to obtain the overall recognition accuracy.

8. The method for meal recognition and calorie estimation based on the YOLOv8 model according to claim 1, characterized in that: In the step S5, the specific steps are: S51: Random sampling was used to select research subjects from the user population. The food intake of each meal by the research subjects was counted. The calorie intake of each meal was calculated based on the calorie value of each food. The calorie intake trend of the research subjects within a day was displayed using data visualization methods. S52: Based on the gap between the calorie intake of the research subjects and the recommended calorie intake in the nutrition database, make suggestions for optimizing the nutritional structure and generate a nutritional structure assessment report.

9. A meal recognition and calorie estimation system based on the YOLOv8 model, characterized by: The data acquisition submodule is used to obtain training data and build a food image dataset with labeled information; The model training submodule is used to divide the food image dataset according to meal time scenarios and input it into the YOLOv8-based object detection model for detection training and performance verification; Nutrition estimation submodule, which is used to obtain standard calorie values ​​and estimate food portions based on the detection results of the target detection model; The verification submodule is used to verify the accuracy of the object detection model in identifying food types and estimating calories; The statistical analysis submodule is used to statistically analyze the multi-day image detection results and generate a user's calorie intake trend and nutritional structure assessment report.

10. A computer memory, characterized in that: A computer program executable by a computer processor is stored therein, which executes a meal recognition and calorie estimation method based on a YOLOv8 model as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Diet behavior-based disease prediction model construction method and system

    CN111816280A

  • Complex environment-oriented Chinese food dish detection and identification method

    CN119445562A