Image recognition-based dietary assessment method and apparatus
Patent Information
- Application Number
- CN202611144875.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]目前,慢性病患者的饮食管理主要依赖患者记忆、查阅通用资料或使用常规健康管理应用,且管理方法主要基于菜品名称,无法进行精细化营养成分分析,并给出专科化饮食风险评估,从而无法实现精细化的饮食管理
本申请实施例提供的基于图像识别的饮食评估方法及装置,与相关技术相比,本申请实施例首先获取用户的菜品图片及当前康复阶段,通过图像识别技术解析菜品中的各类食材种类,然后基于预设的营养数据库,确定各类食材种类的营养成分数据,为量化评估提供数据支撑。进一步地,根据预先构建的康复阶段与饮食规则约束集之间的第一映射关系,确定适配用户当前康复阶段的专属饮食规则约束集,将识别得到的食材种类及营养成分数据,与专属饮食规则约束集进行比对,以确定所述菜品图片对应的风险等级,可以使风险等级的评估结果与患者的实时康复阶段相结合,从而生成具有高度针对性和时效性的个性化风险评估结果。
Smart Images

Figure CN122991605A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of dietary assessment technology based on image recognition, and more specifically, relates to a dietary assessment method and apparatus based on image recognition. Background Technology
[0002] For patients with chronic diseases, proper dietary management can stabilize indicators such as blood pressure, blood sugar, and blood lipids, reduce the burden on organs such as the liver, kidneys, and pancreas, slow the progression of chronic diseases, reduce acute attacks and complications, and help improve the efficacy of medications.
[0003] Currently, dietary management for patients with chronic diseases mainly relies on patients' memory, consulting general information, or using routine health management applications. Moreover, the management methods are mainly based on the names of dishes, and cannot conduct detailed nutritional component analysis or provide specialized dietary risk assessments, thus failing to achieve refined dietary management. Summary of the Invention
[0004] The purpose of this application is to provide a diet assessment method and apparatus based on image recognition that can improve the precision of diet management. To achieve the above objective, the technical solution provided by this application is as follows: Firstly, an image recognition-based dietary assessment method is provided, including: Obtain images of the food the user consumed, as well as the user's current recovery stage; Image recognition is performed on the dish image to obtain the types of ingredients contained in the dish image; The system searches a pre-defined nutrition database for each type of food to obtain nutritional data for each type of food. Based on the user's current recovery stage, a preset first mapping relationship is found to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to characterize the correspondence between the recovery stage and the set of dietary rules constraints. The types of ingredients and the nutritional data of each type of ingredient are compared with the set of dietary rules constraints, and the risk level corresponding to the dish image is determined based on the comparison results.
[0005] Secondly, an image recognition-based dietary assessment device is provided, comprising: The image acquisition module is used to acquire images of the food the user is eating, as well as the user's current recovery stage; An image recognition module is used to perform image recognition on the dish image to obtain the types of ingredients contained in the dish image; The first search module is used to search the preset nutrition database based on each type of food to obtain the nutritional composition data of each type of food. The second search module is used to search for a preset first mapping relationship based on the user's current recovery stage to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to represent the correspondence between the recovery stage and the set of dietary rules constraints. The risk assessment module is used to compare the types of ingredients and the nutritional data of each type of ingredient with the set of dietary rules constraints, and determine the risk level corresponding to the dish image based on the comparison results.
[0006] Thirdly, embodiments of this application also provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the image recognition-based dietary assessment method provided by any possible implementation of the first aspect.
[0007] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the image recognition-based dietary assessment method provided by any possible implementation of the first aspect.
[0008] The beneficial effects of the technical solution provided in this application are as follows: The image recognition-based dietary assessment method and apparatus provided in this application, compared with related technologies, first acquires the user's food images and current recovery stage. It then analyzes the various ingredient types in the food using image recognition technology. Based on a pre-set nutrition database, it determines the nutritional components of each ingredient type, providing data support for quantitative assessment. Furthermore, according to a pre-constructed first mapping relationship between recovery stages and dietary rule constraint sets, it determines a specific dietary rule constraint set adapted to the user's current recovery stage. The identified ingredient types and nutritional component data are compared with the specific dietary rule constraint set to determine the risk level corresponding to the food image. This allows the risk level assessment results to be combined with the patient's real-time recovery stage, thereby generating highly targeted and timely personalized risk assessment results. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0010] Figure 1 A schematic flowchart of the image recognition-based dietary assessment method provided in this application embodiment; Figure 2 A structural block diagram of the image recognition-based diet assessment device provided in an embodiment of this application; Figure 3 A schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0011] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0012] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.” When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items can refer to one, several or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2 and A3.
[0013] It is understood that in the embodiments of this application, data related to user information (such as pictures of the dishes eaten by the user and the user's current recovery stage) are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with relevant laws, regulations and standards.
[0014] To make the objectives, technical solutions, and advantages of this application clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.
[0015] This application provides an image recognition-based dietary assessment method, applied to an image recognition-based dietary assessment system deployed in an electronic device. The method is executed by the electronic device, such as... Figure 1 As shown, the method may include: S101: Obtain images of the dishes the user consumed, as well as the user's current recovery stage.
[0016] In this embodiment, the user can take a picture of the dishes for a meal using a mobile terminal and upload it to the diet assessment system. When uploading the picture, the user needs to input their current recovery stage.
[0017] Taking pancreatitis patients as an example, the current recovery stage of a user includes five stages from 0 to 4. Stage 0 is the acute phase, stages 1 to 3 are intermediate phases, and stage 4 is the stable phase. The specific values of the recovery stages can be viewed in the doctor's diagnosis and follow-up records.
[0018] S102: Perform image recognition on the dish image to obtain the types of ingredients contained in the dish image.
[0019] In this embodiment, image recognition can be performed on food images to automatically identify the types of ingredients contained in the images. For example, by performing image recognition on an image of a dish called "Stir-fried Chicken and Celery," it can be determined that the ingredients in the image include chicken breast, celery, and cooking oil.
[0020] To ensure the accuracy of image recognition results, the following preprocessing operations can be performed on the food images before image recognition: (1) Size scaling: If the short side of the image exceeds 1080 pixels, it will be scaled proportionally to 1080 pixels to reduce the transmission and computing load.
[0021] (2) Compression processing: The JPEG compression algorithm is adopted, and the quality factor is set to an adaptive value between 70 and 85: when the original file size is less than 500KB, the quality factor is 85; when the original file size is between 500KB and 2MB, the quality factor is 75; when the original file size is greater than 2MB, the quality factor is 70, to ensure that the compressed image size is controlled within 800KB and retains sufficient recognition details; (3) Image enhancement: To improve the accuracy of subsequent food recognition, the system performs one or more of the following image enhancement operations on the preprocessed images: (3.1) Brightness assessment and adjustment: The system calculates the average pixel brightness value of the image (range 0-255). If the average brightness value is lower than the first threshold of 85, it is determined to be a low-light image, and gamma correction is used to improve the overall brightness, with a gamma value γ preferably of 0.5-0.7; if the average brightness value is higher than the second threshold of 220, it is determined to be an overexposed image, and a gamma value γ preferably of 1.5-1.8 is used for darkening; no brightness adjustment is made in other cases.
[0022] (3.2) Contrast Enhancement: For the image after brightness adjustment, a contrast-limited adaptive histogram equalization (CLAHE) algorithm is used to enhance local contrast. Preferably, the image is converted to the LAB color space, and the CLAHE operation is performed only on the luminance channel (L channel). The clip limit is set to 2.0, and the grid size is divided into 8×8 to avoid excessive amplification of noise.
[0023] (3.3) Denoising: If the ISO sensitivity information of the original image is available and is higher than the preset value of ISO 800, or if the system detects that the noise level of the image is higher than the preset threshold, then denoising is performed on the image. Bilateral filtering is preferred, which retains the food edge contour information while filtering out noise. The filtering parameters are: spatial domain Gaussian kernel diameter is set to 9, and color gamut standard deviation is set to 75.
[0024] S103: Based on each type of food ingredient, search the preset nutrition database to obtain the nutritional composition data of each type of food ingredient.
[0025] In this embodiment, a nutrition database can be pre-built and stored. Each data entry in the nutrition database uses a unique ingredient name as an index field, corresponding to the storage of fixed nutritional parameters such as calories, fat, protein, and dietary fiber per 100 grams of standard serving size for that ingredient. The data is sourced from authoritative dietary nutrition manuals, clinical chronic disease dietary databases, etc., ensuring data standardization and medical applicability. Simultaneously, reference values for the typical single-serving intake of each ingredient (based on the "Chinese Dietary Guidelines" and commonly used ingredient serving size standards in clinical nutrition departments) can also be pre-stored in the nutrition database.
[0026] Based on this, by searching the aforementioned nutrition database for each type of ingredient in the dish image, detailed nutritional data such as calories (kcal) and fat (g) contained in that ingredient type can be obtained.
[0027] S104: Based on the user's current recovery stage, find the preset first mapping relationship to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to characterize the correspondence between the recovery stage and the set of dietary rules constraints.
[0028] In this embodiment, considering that the user's dietary restrictions change dynamically with the recovery stage, a set of dietary rules and constraints, i.e., a first mapping relationship, can be pre-constructed for each recovery stage. Based on this, the corresponding set of dietary rules and constraints can be obtained by searching the first mapping relationship according to the user's current recovery stage. The set of dietary rules and constraints may include: maximum fat intake (g / meal), maximum calories (kcal / meal), and a list of prohibited foods, etc.
[0029] S105: Compare the types of ingredients and the nutritional data of each type of ingredient with the dietary rule constraint set, and determine the risk level corresponding to the dish image based on the comparison results.
[0030] In this embodiment, by comparing the types of ingredients and the nutritional data of each type of ingredient with the dietary rule constraint set corresponding to the recovery stage, the risk level corresponding to the dish image can be determined. This allows the risk level assessment results to be combined with the patient's real-time recovery stage, thereby generating highly targeted and timely personalized risk assessment results.
[0031] In one embodiment of this application, image recognition is performed on a food image to obtain the types of ingredients contained in the food image, including: The preset image recognition engine is called to perform image recognition on the dish image to obtain the first candidate ingredients contained in the dish image and the confidence level of each first candidate ingredient; Display the first candidate ingredients with a confidence level greater than or equal to a preset first confidence threshold; If a second candidate ingredient exists among the first candidate ingredients, a reminder icon will be added to the display position of the second candidate ingredient to remind the user to confirm the second candidate ingredient; the second candidate ingredient is an ingredient among the first candidate ingredients whose confidence level is greater than or equal to the first confidence threshold and less than the second confidence threshold; the first confidence threshold is less than the second confidence threshold. In response to the user's confirmation command for the second candidate ingredient, save the confirmed second candidate ingredient; The confirmed second candidate ingredient and the first candidate ingredient with a confidence level greater than or equal to the second confidence threshold are included as the types of ingredients in the dish image.
[0032] In this embodiment, an existing image recognition engine (such as a visual recognition API) can be invoked to perform image recognition on the dish image, obtaining the ingredients contained in the dish image, which are recorded as first candidate ingredients. Simultaneously, the visual recognition API returns the confidence score corresponding to each first candidate ingredient. Ingredient items with a confidence score lower than the first confidence threshold (e.g., 0.3) are directly discarded, and only first candidate ingredients with a confidence score greater than or equal to the preset first confidence threshold are displayed on the display interface. Ingredient items with a confidence score lower than the second confidence threshold (e.g., 0.6), i.e., second candidate ingredients, are marked as "suspected" and displayed separately on the front-end interface (e.g., with a "?" icon), prompting the user to manually confirm or correct them, rather than discarding them directly. Specifically, if the second candidate ingredient is correctly identified, the user can directly click the "Confirm" button to confirm the second candidate ingredient; if the second candidate ingredient is incorrectly identified, the user can correct the second candidate ingredient and click the "Confirm" button after correction. The correction takes effect, meaning that after the user clicks the "Confirm" button, the confirmed second candidate ingredient is obtained.
[0033] Finally, the second candidate ingredient confirmed by the user, and the first candidate ingredient with a confidence level greater than or equal to the second confidence threshold, are selected as the ingredient types included in the dish image.
[0034] In one embodiment of this application, there are multiple preset image recognition engines, each with a corresponding priority; calling the preset image recognition engines to perform image recognition on the dish image includes: The call identification operation is executed repeatedly until the preset stopping condition is met; The invocation of recognition operations includes: Select the highest priority image recognition engine from the unused image recognition engines as the target image recognition engine; Image recognition of food images is performed based on a target image recognition engine; The preset stopping condition is: receiving the image recognition result returned by the target image recognition engine, or traversing all image recognition engines; the image recognition result includes the first candidate ingredient and the confidence level corresponding to each first candidate ingredient.
[0035] In this embodiment, the dietary assessment system pre-configures a priority order for multiple visual recognition APIs. This priority order is stored in a structured configuration file (such as JSON format), allowing for dynamic addition or deletion of service providers or adjustment of priorities via a backend management interface, without requiring a system restart. Preferably, the priority configuration storage structure is as follows: { "providers": [ {"name": "primary_vision_api", "timeout": 8000, "retry": 2, "priority": 1}, {"name": "secondary_vision_api", "timeout": 6000, "retry": 1, "priority": 2}, {"name": "tertiary_vision_api", "timeout": 10000, "retry": 2, "priority": 3} ] } The system attempts to call multiple visual recognition APIs sequentially according to their priority. For each visual recognition API, a timeout threshold (8 seconds) is set; exceeding the timeout threshold is considered a failure. Upon failure, an exponential backoff retry strategy is employed: the first retry interval is 1 second, the second retry interval is 2 seconds, and if the system still fails after reaching the maximum number of retries configured for that visual recognition API, it automatically switches to the next higher priority visual recognition API.
[0036] In one embodiment of this application, if none of the image recognition engines returned by the target image recognition engine are received after traversing all image recognition engines, then: Based on the user's current recovery stage, a preset second mapping relationship is found to obtain a preset food list corresponding to the user's current recovery stage; the second mapping relationship is used to represent the correspondence between the recovery stage and the preset food list. Set the confidence level of each ingredient in the preset ingredient list to a preset value; the preset value is not less than the first confidence threshold and is less than the second confidence threshold; The preset ingredient list is used as the first candidate ingredient in the dish image, and the confidence level of each ingredient in the preset ingredient list is used as the confidence level of the first candidate ingredient.
[0037] In this embodiment, if all configured visual recognition APIs fail, a fallback strategy is adopted: based on the user's current recovery stage, results are returned from a pre-configured default food list (i.e., a preset ingredient list). The default food list is stored with the recovery stage as the key-value pair, pre-set in the system backend, and can be dynamically adjusted in the background. For example: Recovery Stage 0 (Liquid Phase): Default return ["Rice Water", "Lotus Root Starch", "Thin Rice Porridge"] Recovery Stage 1 (Semi-liquid phase): Default return values are ["Steamed Egg Custard", "Soft Noodles", "Mashed Potatoes"]. Recovery Stage 2 (Soft Food Phase): Default return values are ["Steamed Egg", "Tofu", "Rice Porridge", "Steamed Fish"]. Recovery stage 3 and above (recovery period): Default return ["chicken breast", "broccoli", "rice", "steamed fish"].
[0038] Correspondingly, the confidence level of each ingredient in the preset ingredient list is set to a value between the first confidence threshold and the second confidence threshold, such as 0.4. In this way, a reminder label (such as adding a "?" label) will be added to the display position of each ingredient in the preset ingredient list to remind the user to manually confirm or correct it.
[0039] Therefore, the service degradation and fallback mechanism in this embodiment can automatically activate alternative solutions when the visual recognition API is unavailable, maximizing functional availability and improving system robustness. Secondly, a user manual correction mechanism is introduced in the result presentation stage, allowing users to correct possible recognition errors. This not only improves the accuracy of the final data but also enhances the user's sense of control and trust in the system, optimizing the overall user experience.
[0040] In one embodiment of this application, the dietary rule constraint set includes a list of prohibited ingredients, a maximum fat content, a maximum calorie content, and a cooking method restriction set, and the nutritional data for each type of ingredient includes fat content and calories; This involves comparing the types of ingredients and the nutritional data of each type with a set of dietary rules constraints, and determining the risk level corresponding to the dish images based on the comparison results, including: If the food ingredients include any ingredients from the list of prohibited ingredients, then the risk level corresponding to the dish image is determined to be the highest level. If the food ingredients do not include any ingredients from the prohibited food list, the total fat content of the dish image is determined based on the fat content of each of the various food ingredients, and the total calorie content of the dish image is determined based on the calorie content of each of the various food ingredients. The excess fat rate is determined based on the total fat content and the maximum fat content, and the excess calorie rate is determined based on the total calorie content and the maximum calorie content. If the food ingredients include any ingredients from a pre-defined list of indigestible foods, the proportion of indigestible foods in the food ingredients is calculated. The risk score for the dish image is determined based on the excess fat rate, excess calorie rate, and proportion of indigestible foods, and the risk level of the dish image is determined based on the risk score.
[0041] In this embodiment, based on the dietary rule constraint set corresponding to the user's current recovery stage, the types of ingredients in the dish images and the nutritional composition data of each type of ingredient can be analyzed. The analysis process combines multi-level serial filtering with risk quantification calculation, as detailed below: First layer: Forbidden food pairings (hard filtering) Each identified ingredient is checked one by one to see if it matches the list of prohibited ingredients for the current stage. If it does, the ingredient is directly judged as "prohibited from consumption" and does not need to be included in subsequent quantitative calculations.
[0042] Second layer: Compliance check of cooking methods If the user has provided cooking method information, then check whether the cooking method belongs to the current stage's restricted set. If the cooking method is not in the restricted set (for example, "frying" or "deep-frying" is not allowed in stage 0 (liquid diet), then it is directly determined as "prohibited from consumption," and a reason is given (such as "frying and deep-frying are not allowed in the current recovery stage"). If the user has not provided cooking method information (e.g., the user did not bring the photo recognition scene), then this layer of checks is skipped, and the third layer is used for nutritional quantitative assessment.
[0043] Third layer: Quantitative calculation of nutritional indicator risks For ingredients that pass the first two layers of filtering, the fat content of each type of ingredient is summed to obtain the total fat content corresponding to the dish image. The calorie content of each type of ingredient is summed to obtain the total calorie content corresponding to the dish image. Then, the excess fat rate is determined based on the total fat content and the maximum fat content, and the excess calorie rate is determined based on the total calorie content and the maximum calorie content. If the ingredient types include ingredients from a pre-defined list of indigestible ingredients, the proportion of indigestible ingredients in the ingredient types is calculated. Finally, the risk score corresponding to the dish image is determined based on the excess fat rate, excess calorie rate, and proportion of indigestible ingredients, and the risk level corresponding to the dish image is determined based on the risk score.
[0044] in: Excess fat percentage = (Total fat - Maximum fat content) / Maximum fat content, take 0 when the result is negative; Calorie excess rate = (Total calories - Maximum calories) / Maximum calories, take 0 when the result is negative; Percentage of indigestible components = Quantity of indigestible ingredients / Total quantity of ingredients.
[0045] Risk level assessment: Risk score R < threshold T1 (preferably T1 = 0.5): determined as "edible"; Risk score R in the range [T1, T2) (preferably T2=1.5): judged as "consume with caution"; Risk score R ≥ T2: Determined to be "not for consumption".
[0046] Based on the above risk levels, a risk assessment conclusion for each ingredient and dish as a whole is generated, and a preset text template is used to generate a phased consumption recommendation that includes specific reasons (such as "total fat content exceeds the current stage limit of 150%)".
[0047] Furthermore, a structured assessment report can be generated and presented to the user. The report clearly shows the list of identified ingredients, the nutritional composition of each ingredient, and the risk assessment conclusions and reasons based on the current recovery stage. The content of the above assessment report can also be written into the user's long-term diet log in one click, completing the business loop from rapid identification to formal recording.
[0048] In one embodiment of this application, a risk score corresponding to a dish image is determined based on the excess fat rate, excess calorie rate, and the proportion of indigestible ingredients, including: Based on a preset mapping function, the first evaluation value corresponding to the fat excess rate, the second evaluation value corresponding to the calorie excess rate, and the third evaluation value corresponding to the proportion of indigestible food are determined. Determine the first weight corresponding to the first assessment value, the second weight corresponding to the second assessment value, and the third weight corresponding to the third assessment value based on the user's current recovery stage; The risk score corresponding to the dish image is obtained by weighting and summing the first, second, and third evaluation values based on the first, second, and third weights.
[0049] In this embodiment, the preset mapping function can be a nonlinear mapping function, preferably an exponential function. , where is sensitivity Coefficient (preferred) This means that the greater the exceedance of the limit, the more exponentially the risk score increases, thus more accurately reflecting the degree of harm caused by high-risk diets.
[0050] After determining the first assessment value corresponding to the fat excess rate, the second assessment value corresponding to the calorie excess rate, and the third assessment value corresponding to the proportion of indigestible foods based on the above mapping function, the first weight corresponding to the first assessment value, the second weight corresponding to the second assessment value, and the third weight corresponding to the third assessment value can be allocated differently according to the clinical dietary control focus of the user at different stages of recovery. Specifically, in the early stage of recovery, strict control of fat intake is given priority, so the fat excess rate is assigned a higher weight; as the condition gradually recovers, the weight of calorie intake control and dietary restriction of indigestible foods increases accordingly.
[0051] Finally, the first, second, and third assessment values are weighted and summed based on the first, second, and third weights, thus integrating the multi-dimensional evaluation dimensions into a single quantitative risk score. This can be expressed by the formula: Risk score R = f(fat excess rate) × w1 + f(calorie excess rate) × w2 + f(percentage of indigestible components) × w3.
[0052] Where w1, w2 and w3 represent the first weight, the second weight and the third weight, respectively.
[0053] As can be seen from the above, the assessment method in this embodiment can not only avoid the one-sidedness of assessment caused by a single evaluation dimension, but also adapt the dietary management needs of different recovery stages through dynamic weights, so that the risk assessment results are more in line with clinical diagnosis and treatment standards, and realize personalized and refined quantitative judgment of dietary risks.
[0054] In one embodiment of this application, determining a first weight corresponding to a first assessment value, a second weight corresponding to a second assessment value, and a third weight corresponding to a third assessment value based on the user's current recovery stage includes: If the user is currently in the initial stage of recovery, then the first weight, the second weight, and the third weight are determined to be the first value, the second value, and the third value, respectively; the first value is greater than the second value, and the first value is greater than the third value. If the user is currently in the later stage of recovery, then the first weight, the second weight, and the third weight are determined to be the fourth value, the fifth value, and the sixth value, respectively; the fourth value is less than the first value, the fifth value is greater than the second value, and the sixth value is greater than the third value. If the user's current recovery stage is intermediate, then a first weight is determined by linear interpolation based on the first and fourth values; a second weight is determined by linear interpolation based on the second and fifth values; and a third weight is determined by linear interpolation based on the third and sixth values.
[0055] For example, the baseline weight vector for stage 0 (acute phase) can be set as (w1, w2, w3) = (0.6, 0.2, 0.2), and the baseline weight vector for stage 4 (stable phase) can be set as (0.35, 0.35, 0.3). For intermediate stages (1, 2, 3), each weight value is calculated through linear interpolation: w i (stage n) = w i (Phase 0) + [w i (Phase 4) - w i [(Stage 0)] × n / 4; where n is the current rehabilitation stage number, i=1,2,3. The above method allows the weights to transition smoothly with the rehabilitation process: the fat weight is the highest in the acute phase (0.6), reflecting the strict control of fat intake; as the stage increases, the fat weight gradually decreases to 0.35, and the weights of calories and digestion dimensions increase accordingly, which is in line with the actual pattern of gradually relaxing dietary restrictions in the clinical rehabilitation process.
[0056] The following describes the complete execution process of this embodiment using a specific scenario.
[0057] User background: Mr. Zhang, a patient recovering from pancreatitis, is currently in recovery stage 2 (soft food stage). The corresponding dietary rules for this stage are: fat threshold of 15g per meal, calorie threshold of 400Kcal, and cooking methods are limited to "steaming / boiling / stewing / braising".
[0058] Step 1: Zhang took a photo of a plate of "stir-fried chicken and celery" during lunch. The system front-end detected that the image size was 3.2MB and the shorter side was 1920px. The system performed preprocessing: the image was scaled proportionally to 1080px on the shorter side and compressed using JPEG (quality factor 70, since the original image was >2MB). The compressed file size was 720KB.
[0059] Step 2: The system calls the visual recognition API in priority order. The visual recognition API returns the following recognition results: chicken breast (confidence 0.92), celery (0.88), cooking oil (0.65), and carrot (0.55). Among these, the confidence score for "carrot" (0.55 < 0.6) is marked as "suspected" and displayed on the front end. The confidence score for "cooking oil" (0.65), while low, is still ≥ 0.6 and is retained normally. The visual recognition API call was successful on the first attempt, without triggering the backup service. Mr. Zhang confirmed on the front end that "carrot" was a misidentified item and manually deleted it; the other three items were correct.
[0060] Step 3: The system acquires nutritional data in parallel (chicken breast: 133Kcal / 5g fat per 100g; celery: 13Kcal / 0.1g fat per 100g; cooking oil: 899Kcal / 99.8g fat per 100g), and reads that Zhang's current stage is Level 2, loading the corresponding fat threshold of 15g, calorie threshold of 400Kcal, and a list of prohibited foods, etc.
[0061] Regarding the determination of ingredient weight: Since the system cannot accurately obtain the weight of ingredients from a single dish image, the following method is used to obtain the weight input value: The system pre-stores reference values for the typical single-serving amount of each ingredient in its nutrition database (based on the "Chinese Dietary Guidelines" and commonly used ingredient portion standards in clinical nutrition departments). For example, the reference value for the typical single-serving amount of poultry and meat is 100-150g, and for leafy vegetables it is 80-120g. After identification, the system pre-fills the assessment interface with the median value of the typical single-serving amount reference values for each ingredient as the default weight. In this example, chicken breast is 125g, celery is 100g, and cooking oil is 15g (the median value of 10-20g, commonly used in Chinese stir-frying). This default weight serves as the initial input for subsequent risk calculations. Users can manually adjust the actual weight of each ingredient in the assessment report interface; after adjustment, the system automatically recalculates the risk score.
[0062] Step 4: The system performs a three-level evaluation.
[0063] First layer: Chicken breast, celery, and cooking oil are not on the taboo list for stage 2, so this is acceptable.
[0064] Second layer: If the user takes a photo and does not carry cooking method information, this check will be skipped for now.
[0065] Third layer: Based on the default weight, the dish contains 125g chicken breast (6.25g fat), 100g celery (0.1g fat), and 15g cooking oil (approximately 15g fat), for a total fat content of approximately 21.35g. Total calories are calculated as follows: 125g chicken breast ≈ 166Kcal + 100g celery ≈ 13Kcal + 15g cooking oil ≈ 135Kcal, totaling approximately 314Kcal. Calculations: Excess fat = (21.35-15) / 15 ≈ 0.42; Excess calorie rate = (314-400) / 400 < 0, rounded to 0; Percentage of indigestible components = 0 (no identifiable indigestible ingredients).
[0066] Meanwhile, the stage 2 weights are calculated using the linear interpolation formula: w1=0.6+(0.35-0.6)×2 / 4=0.48, w2=0.2+(0.35-0.2)×2 / 4=0.28, w3=0.2+(0.3-0.2)×2 / 4=0.25.
[0067] Then calculate R = (e^(2×0.42)-1)×0.48 + 0×0.28 + 0×0.25 = (e^0.84-1)×0.48 ≈ (2.316-1)×0.48 ≈ 0.63.
[0068] Finally, setting T1=0.5, T2=1.5, and R=0.63 within the range [0.5, 1.5), the dish was judged as "consume with caution." The system output the reason: "The total fat content exceeds the current stage limit by approximately 42%, it is recommended to reduce the amount of cooking oil used."
[0069] Step 5: The system generates an assessment report displayed on the interface. The report clearly shows the list of identified ingredients (chicken breast, celery, cooking oil), the nutritional composition of each ingredient, the overall assessment of the dish as "consume with caution," and the specific reasons. After viewing the report, Mr. Zhang selected the "Lunch" meal and clicked "Add to Log." The system then batch-wrote the three records—chicken breast, celery, and cooking oil—into the log and associated them with the ID of this identification record.
[0070] In summary, the image recognition-based dietary assessment method of this embodiment can achieve the following beneficial effects: (1) Solved the problem of the disconnect between recognition results and business needs: This embodiment adopts or calls an image recognition engine that can recognize multiple ingredients, and directly outputs a structured list of ingredients rather than a single dish name. This provides an accurate and usable data foundation for subsequent refined nutritional analysis and specialized risk assessment of each ingredient, and opens up the technical link from image recognition to specialized health management.
[0071] (2) It solves the problem of lack of dynamic and personalized specialty adaptation: This embodiment creatively introduces the user's real-time recovery stage as the core variable. The risk assessment is not based on a set of static rules, but dynamically calls the specialty diet rule library that matches the user's current stage. This enables the system to provide pancreatitis patients in different recovery stages with completely different and highly targeted dietary advice, realizes true personalized health management, and significantly improves the medical accuracy and practical value of the advice.
[0072] (3) Improved system robustness and user experience: First, the image recognition steps in this embodiment include a service degradation and fallback mechanism, which can automatically activate alternative solutions when the main image recognition engine is unavailable, maximizing the availability of functions and improving system robustness. Second, a user manual correction mechanism is introduced in the result presentation stage, allowing users to correct possible recognition errors, which not only improves the accuracy of the final data, but also enhances the user's sense of control and trust in the system, optimizing the overall user experience.
[0073] Based on the same principle as the image recognition-based dietary assessment method provided in the embodiments of this application, the embodiments of this application also provide an image recognition-based dietary assessment device, such as... Figure 2 As shown, the image recognition-based dietary assessment device 20 may specifically include: an image acquisition module 21, an image recognition module 22, a first search module 23, a second search module 24, and a risk assessment module 25.
[0074] Among them, the image acquisition module 21 is used to acquire images of the dishes consumed by the user, as well as the user's current recovery stage; Image recognition module 22 is used to perform image recognition on food images to obtain the types of ingredients contained in the food images; The first search module 23 is used to search the preset nutrition database based on each type of food to obtain the nutritional composition data of each type of food. The second search module 24 is used to search for a preset first mapping relationship based on the user's current recovery stage to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to characterize the correspondence between the recovery stage and the set of dietary rules constraints. The risk assessment module 25 is used to compare the types of ingredients and the nutritional data of each type of ingredient with the set of dietary rules constraints, and determine the risk level corresponding to the dish image based on the comparison results.
[0075] In one embodiment of this application, the image recognition module 22 is specifically used for: The preset image recognition engine is called to perform image recognition on the dish image to obtain the first candidate ingredients contained in the dish image and the confidence level of each first candidate ingredient; Display the first candidate ingredients with a confidence level greater than or equal to a preset first confidence threshold; If a second candidate ingredient exists among the first candidate ingredients, a reminder icon will be added to the display position of the second candidate ingredient to remind the user to confirm the second candidate ingredient; the second candidate ingredient is an ingredient among the first candidate ingredients whose confidence level is greater than or equal to the first confidence threshold and less than the second confidence threshold; the first confidence threshold is less than the second confidence threshold. In response to the user's confirmation command for the second candidate ingredient, save the confirmed second candidate ingredient; The confirmed second candidate ingredient and the first candidate ingredient with a confidence level greater than or equal to the second confidence threshold are included as the types of ingredients in the dish image.
[0076] In one embodiment of this application, there are multiple preset image recognition engines, each with a corresponding priority; the image recognition module 22 is further used for: The call identification operation is executed repeatedly until the preset stopping condition is met; The invocation of recognition operations includes: Select the highest priority image recognition engine from the unused image recognition engines as the target image recognition engine; Image recognition of food images is performed based on a target image recognition engine; The preset stopping condition is: receiving the image recognition result returned by the target image recognition engine, or traversing all image recognition engines; the image recognition result includes the first candidate ingredient and the confidence level corresponding to each first candidate ingredient.
[0077] In one embodiment of this application, if no image recognition result is received from the target image recognition engine after traversing all image recognition engines, the image recognition module 22 is further configured to: Based on the user's current recovery stage, a preset second mapping relationship is found to obtain a preset food list corresponding to the user's current recovery stage; the second mapping relationship is used to represent the correspondence between the recovery stage and the preset food list. Set the confidence level of each ingredient in the preset ingredient list to a preset value; the preset value is not less than the first confidence threshold and is less than the second confidence threshold; The preset ingredient list is used as the first candidate ingredient in the dish image, and the confidence level of each ingredient in the preset ingredient list is used as the confidence level of the first candidate ingredient.
[0078] In one embodiment of this application, the dietary rule constraint set includes a list of prohibited ingredients, a maximum fat content, a maximum calorie content, and a cooking method restriction set, and the nutritional data for each type of ingredient includes fat content and calories; Risk assessment module 25 is specifically used for: If the food ingredients include any ingredients from the list of prohibited ingredients, then the risk level corresponding to the dish image is determined to be the highest level. If the food ingredients do not include any ingredients from the prohibited food list, the total fat content of the dish image is determined based on the fat content of each of the various food ingredients, and the total calorie content of the dish image is determined based on the calorie content of each of the various food ingredients. The excess fat rate is determined based on the total fat content and the maximum fat content, and the excess calorie rate is determined based on the total calorie content and the maximum calorie content. If the food ingredients include any ingredients from a pre-defined list of indigestible foods, the proportion of indigestible foods in the food ingredients is calculated. The risk score for the dish image is determined based on the excess fat rate, excess calorie rate, and proportion of indigestible foods, and the risk level of the dish image is determined based on the risk score.
[0079] In one embodiment of this application, the risk assessment module 25 is further configured to: Based on a preset mapping function, the first evaluation value corresponding to the fat excess rate, the second evaluation value corresponding to the calorie excess rate, and the third evaluation value corresponding to the proportion of indigestible food are determined. Determine the first weight corresponding to the first assessment value, the second weight corresponding to the second assessment value, and the third weight corresponding to the third assessment value based on the user's current recovery stage; The risk score corresponding to the dish image is obtained by weighting and summing the first, second, and third evaluation values based on the first, second, and third weights.
[0080] In one embodiment of this application, the risk assessment module 25 is further configured to: If the user is currently in the initial stage of recovery, then the first weight, the second weight, and the third weight are determined to be the first value, the second value, and the third value, respectively; the first value is greater than the second value, and the first value is greater than the third value. If the user is currently in the later stage of recovery, then the first weight, the second weight, and the third weight are determined to be the fourth value, the fifth value, and the sixth value, respectively; the fourth value is less than the first value, the fifth value is greater than the second value, and the sixth value is greater than the third value. If the user's current recovery stage is intermediate, then a first weight is determined by linear interpolation based on the first and fourth values; a second weight is determined by linear interpolation based on the second and fifth values; and a third weight is determined by linear interpolation based on the third and sixth values.
[0081] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0082] Figure 3 A schematic diagram of the structure of an electronic device to which this application embodiment applies is shown, such as... Figure 3 As shown, the electronic device can be used to implement the methods provided in any embodiment of this application.
[0083] like Figure 3 As shown, the electronic device 300 may primarily include at least one processor 301. Figure 3 The diagram shows components such as a memory 302, a communication module 303, and an input / output interface 304. Optionally, these components can be connected and communicate with each other via a bus 305. It should be noted that... Figure 3 The structure of the electronic device 300 shown is merely illustrative and does not constitute a limitation on the electronic devices to which the methods provided in the embodiments of this application are applicable.
[0084] The memory 302 can be used to store operating systems and applications, etc. The applications can include computer programs that implement the methods shown in the embodiments of this application when invoked by the processor 301, and can also include programs for implementing other functions or services. The memory 302 can be ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices that can store information and computer programs, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
[0085] Processor 301 is connected to memory 302 via bus 305 and implements corresponding functions by calling the application programs stored in memory 302. Processor 301 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 301 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0086] Electronic device 300 can connect to a network via communication module 303 (which may include, but is not limited to, components such as a network interface) to communicate with other devices (such as user terminals or servers) through the network and achieve data interaction, such as sending data to or receiving data from other devices. Communication module 303 may include wired network interfaces and / or wireless network interfaces, meaning the communication module may include at least one of wired or wireless communication modules.
[0087] The electronic device 300 can connect to necessary input / output devices, such as a keyboard or display device, via the input / output interface 304. The electronic device 300 itself may have a display device, and other external display devices can also be connected via the input / output interface 304. Optionally, a storage device, such as a hard drive, can also be connected via the input / output interface 304. Data from the electronic device 300 can be stored in the storage device, or data can be retrieved from the storage device. Data from the storage device can also be stored in the memory 302. It is understood that the input / output interface 304 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 304 can be a component of the electronic device 300 or an external device connected to the electronic device 300 when needed.
[0088] The bus 305 used to connect the components may include a path for transmitting information between the components. The bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Depending on its function, the bus 305 may be divided into an address bus, a data bus, a control bus, etc.
[0089] Optionally, for the solution provided in the embodiments of this application, the memory 302 can be used to store a computer program that executes the solution of this application, and the processor 301 runs the computer program. When the processor 301 runs the computer program, it implements the operation of the method or apparatus provided in the embodiments of this application.
[0090] Based on the same principle as the method provided in the embodiments of this application, the embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.
[0091] It should be noted that the terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0092] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0093] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0094] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A dietary assessment method based on image recognition, characterized in that, include: Obtain images of the food the user consumed, as well as the user's current recovery stage; Image recognition is performed on the dish image to obtain the types of ingredients contained in the dish image; The system searches a pre-defined nutrition database for each type of food to obtain nutritional data for each type of food. Based on the user's current recovery stage, a preset first mapping relationship is found to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to characterize the correspondence between the recovery stage and the set of dietary rules constraints. The types of ingredients and the nutritional data of each type of ingredient are compared with the set of dietary rules constraints, and the risk level corresponding to the dish image is determined based on the comparison results.
2. The dietary assessment method based on image recognition as described in claim 1, characterized in that, The step of performing image recognition on the dish image to obtain the types of ingredients contained in the dish image includes: A preset image recognition engine is invoked to perform image recognition on the dish image, thereby obtaining the first candidate ingredients contained in the dish image and the confidence level corresponding to each first candidate ingredient; Display the first candidate ingredients with a confidence level greater than or equal to a preset first confidence threshold; If a second candidate ingredient exists among the first candidate ingredients, a reminder icon is added to the display position of the second candidate ingredient to remind the user to confirm the second candidate ingredient; the second candidate ingredient is an ingredient among the first candidate ingredients whose confidence level is greater than or equal to the first confidence threshold and less than the second confidence threshold; the first confidence threshold is less than the second confidence threshold; In response to the user's confirmation command for the second candidate ingredient, the confirmed second candidate ingredient is saved; The confirmed second candidate ingredient and the first candidate ingredient with a confidence level greater than or equal to the second confidence threshold are used as the ingredient types included in the dish image.
3. The dietary assessment method based on image recognition as described in claim 2, characterized in that, There are multiple preset image recognition engines, and each image recognition engine has a corresponding priority. The step of calling a preset image recognition engine to perform image recognition on the dish image includes: The call identification operation is executed repeatedly until the preset stopping condition is met; The call identification operation includes: Select the highest priority image recognition engine from the unused image recognition engines as the target image recognition engine; Image recognition of the food images is performed based on a target image recognition engine; The preset stopping condition is: receiving the image recognition result returned by the target image recognition engine, or traversing all image recognition engines; the image recognition result includes the first candidate ingredient and the confidence level corresponding to each first candidate ingredient.
4. The dietary assessment method based on image recognition as described in claim 3, characterized in that, If, after iterating through all image recognition engines, no image recognition result is received from the target image recognition engine, then: Based on the user's current recovery stage, a preset second mapping relationship is found to obtain a preset food list corresponding to the user's current recovery stage; The second mapping relationship is used to represent the correspondence between the recovery stage and the preset food ingredient list; The confidence level of each ingredient in the preset ingredient list is set to a preset value; the preset value is not less than the first confidence threshold and is less than the second confidence threshold. The preset ingredient list is used as the first candidate ingredient in the dish image, and the confidence level of each ingredient in the preset ingredient list is used as the confidence level corresponding to the first candidate ingredient.
5. The dietary assessment method based on image recognition as described in claim 1, characterized in that, The dietary rules constraint set includes a list of prohibited ingredients, maximum fat content, maximum calories, and a set of cooking method restrictions. The nutritional data for each type of ingredient includes fat content and calories. The step of comparing the types of ingredients and the nutritional data of each type of ingredient with the dietary rule constraint set, and determining the risk level corresponding to the dish image based on the comparison results, includes: If the food ingredients include any of the ingredients listed in the prohibited food ingredients list, then the risk level corresponding to the dish image is determined to be the highest level. If the food ingredients do not include any ingredients from the prohibited food ingredient list, then the total fat content of the dish image is determined based on the fat content of each of the various food ingredients, and the total calorie content of the dish image is determined based on the calorie content of each of the various food ingredients; the excess fat rate is determined based on the total fat content and the maximum fat content, and the excess calorie rate is determined based on the total calorie content and the maximum calorie content; if the food ingredients include any ingredients from a pre-defined list of indigestible ingredients, then the proportion of indigestible ingredients in the food ingredients is calculated; the risk score corresponding to the dish image is determined based on the excess fat rate, the excess calorie rate, and the proportion of indigestible ingredients, and the risk level corresponding to the dish image is determined based on the risk score.
6. The dietary assessment method based on image recognition as described in claim 5, characterized in that, The process of determining the risk score corresponding to the dish image based on the excess fat rate, the excess calorie rate, and the proportion of indigestible ingredients includes: The first evaluation value corresponding to the fat excess rate, the second evaluation value corresponding to the calorie excess rate, and the third evaluation value corresponding to the proportion of indigestible food are determined based on a preset mapping function. Based on the user's current recovery stage, determine the first weight corresponding to the first assessment value, the second weight corresponding to the second assessment value, and the third weight corresponding to the third assessment value; The risk score corresponding to the dish image is obtained by weighted summation of the first evaluation value, the second evaluation value, and the third evaluation value based on the first weight, the second weight, and the third weight.
7. The dietary assessment method based on image recognition as described in claim 6, characterized in that, The step of determining the first weight corresponding to the first assessment value, the second weight corresponding to the second assessment value, and the third weight corresponding to the third assessment value based on the user's current recovery stage includes: If the user's current recovery stage is the initial stage, then the first weight, the second weight, and the third weight are determined to be the first value, the second value, and the third value, respectively; the first value is greater than the second value, and the first value is greater than the third value; If the user's current recovery stage is the later stage, then the first weight, the second weight, and the third weight are determined to be the fourth value, the fifth value, and the sixth value, respectively; the fourth value is less than the first value, the fifth value is greater than the second value, and the sixth value is greater than the third value. If the user's current recovery stage is intermediate, then the first weight is determined by linear interpolation based on the first value and the fourth value; the second weight is determined by linear interpolation based on the second value and the fifth value; and the third weight is determined by linear interpolation based on the third value and the sixth value.
8. A dietary assessment device based on image recognition, characterized in that, include: The image acquisition module is used to acquire images of the food the user is eating, as well as the user's current recovery stage; An image recognition module is used to perform image recognition on the dish image to obtain the types of ingredients contained in the dish image; The first search module is used to search the preset nutrition database based on each type of food to obtain the nutritional composition data of each type of food. The second search module is used to search for a preset first mapping relationship based on the user's current recovery stage to obtain the corresponding set of dietary rules constraints; the first mapping relationship is used to represent the correspondence between the recovery stage and the set of dietary rules constraints. The risk assessment module is used to compare the types of ingredients and the nutritional data of each type of ingredient with the set of dietary rules constraints, and determine the risk level corresponding to the dish image based on the comparison results.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the image recognition-based dietary assessment method according to any one of claims 1 to 7 when running the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the image recognition-based dietary assessment method according to any one of claims 1 to 7.