Beef freshness detection method, equipment and medium based on lightweight deep learning

Through a beef freshness detection method based on lightweight deep learning, using image data in multiple color spaces to train the model, combined with convolutional attention and cascade hole pyramid pooling modules, the existing beef freshness detection is time-consuming and burdensome. The problem of environmental impact is achieved, and fast and accurate detection results are achieved.

CN118334648BActive Publication Date: 2024-09-24INNOVATION CENTER OF YANGTZE RIVER DELTA ZHEJIANG UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410748676.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-09-24
Estimated Expiration
2044-06-12

AI Technical Summary

Technical Problem

Existing beef freshness detection methods are time-consuming and labor-intensive, require a large number of chemical reagents, and are affected by ambient temperature and humidity, making it impossible to achieve fast and accurate online detection.

Method used

A beef freshness detection method based on lightweight deep learning is adopted. By acquiring multiple RGB beef images with different freshness labels, a training set and a test set of RGB, HSV and color spaces are constructed to train a lightweight deep learning model, combined with The convolutional attention module and the cascaded hole pyramid pooling module realize the rapid detection of beef freshness.

Benefits of technology

It achieves fast and accurate detection of beef freshness. The model is lightweight and can be deployed on resource-constrained equipment, which improves the diversity and accuracy of detection and is not affected by ambient temperature and humidity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334648B
    Figure CN118334648B
Patent Text Reader

Abstract

The present invention discloses a beef freshness detection method, device and medium based on lightweight deep learning, and relates to the field of food quality and safety. The present invention obtains beef freshness detection models of different color spaces by training a lightweight deep learning model, and selects a beef freshness detection model of a target color space according to the test results, and then realizes the detection of beef freshness in the target color space. The present invention adopts computer vision technology to realize rapid detection of beef freshness, and the lightweight deep learning model used can be deployed on external devices with limited hardware resources, thereby improving the diversity of detection methods, and the detection method is not affected by ambient temperature and humidity, thereby improving the accuracy of detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of food quality and safety, and in particular to a beef freshness detection method, device and medium based on lightweight deep learning. Background Art

[0002] Due to the high protein and water content in beef, protein degradation and fat oxidation in the storage process of beef are promoted, which accelerates beef spoilage and makes beef have a short shelf life. Failure to detect beef quality in time will cause a large waste of resources, and eating unfresh beef will cause food safety problems. Therefore, the demand for online, rapid and intelligent detection technology for beef freshness is particularly urgent. Traditional beef freshness detection methods mainly use the methods in "GB5009.228-2016 Determination of Volatile Basic Nitrogen in Food" and "GB 4789.2-2010 Determination of Total Colony Count in Food Microbiology Inspection", which is time-consuming and labor-intensive and requires a large amount of chemical reagents. In recent years, the main methods for beef freshness detection include molecular spectroscopy detection, electronic nose method, olfactory visualization detection method, etc., but these methods require the beef to be cut into small pieces first, the detection time is at least 1 minute, and the detection process is easily affected by ambient temperature and humidity. Summary of the invention

[0003] The purpose of the present invention is to provide a beef freshness detection method, device and medium based on lightweight deep learning, which can realize rapid and accurate detection of beef freshness.

[0004] To achieve the above object, the present invention provides the following solution.

[0005] A beef freshness detection method based on lightweight deep learning, the method comprising: obtaining a plurality of RGB beef images with different freshness labels respectively; constructing a training set, a validation set and a test set in different color spaces based on the plurality of RGB beef images with different freshness labels; the different color spaces include RGB color space, HSV color space and color space; respectively use the training set and validation set of each color space to train and validate the lightweight deep learning model, obtain the trained lightweight deep learning model of each color space, and use it as the beef freshness detection model of each color space; the lightweight deep learning model includes a first convolution module, a first efficient bottleneck layer component, a second efficient bottleneck layer component, a cascaded dilute pyramid pooling module, a convolution attention module, a second convolution module, a third convolution module, a fourth convolution module and a decision function connected in sequence; respectively use the test set of each color space to test the beef freshness detection model of each color space, and obtain the beef freshness detection model of the color space with the best test result as the beef freshness detection model of the target color space; use the beef freshness detection model of the target color space to detect the freshness of the beef to be tested.

[0006] Optionally, constructing training sets, validation sets, and test sets in different color spaces based on multiple RGB beef images with different freshness labels, specifically comprising: dividing the multiple RGB beef images with different freshness labels into a training set, a validation set, and a test set to obtain a training set, a validation set, and a test set in an RGB color space; converting the RGB beef images in the training set, the validation set, and the test set in the RGB color space to an HSV color space to obtain a training set, a validation set, and a test set in an HSV color space; converting the RGB beef images in the training set, the validation set, and the test set in the RGB color space to an HSV color space to obtain a training set, a validation set, and a test set in an HSV color space. Color space, get Training, validation, and test sets in color space.

[0007] Optionally, the first high-efficiency bottleneck layer component includes multiple first high-efficiency bottleneck layer modules connected in sequence, and the second high-efficiency bottleneck layer component includes multiple second high-efficiency bottleneck layer modules connected in sequence; the first high-efficiency bottleneck layer module and the second high-efficiency bottleneck layer module both adopt an E-bneck network structure; the E-bneck network structure includes a fifth convolution module, a depth-separable convolution module, an ECA judgment module and a sixth convolution module connected in sequence.

[0008] Optionally, the cascaded atrous pyramid pooling module includes: a plurality of Split modules arranged in parallel; a seventh convolution module connected to the first Split module among the plurality of Split modules arranged in parallel; N-2 atrous convolution modules respectively connected to the second Split module to the N-1th Split module among the plurality of Split modules arranged in parallel; wherein the output end of the nth Split module is also connected to the input end of the n+1th Split module, n=1, 2, ..., N-2; N is the number of Split modules; an eighth convolution module connected to the Nth Split module among the plurality of Split modules arranged in parallel; and a ninth convolution module connected to the seventh convolution module, the atrous convolution module and the eighth convolution module.

[0009] Optionally, the convolutional attention module includes: a channel attention module, a first multiplication module and a spatial attention module; the first input end of the first multiplication module is used to input the original beef image, the second input end of the first multiplication module is connected to the output end of the channel attention module, and the output end of the first multiplication module is connected to the spatial attention module; the channel attention module includes a first maximum pooling layer and a first average pooling layer arranged in parallel, a tenth convolution module connected to the output ends of the first maximum pooling layer and the first average pooling layer, an addition module connected to the tenth convolution module, a Sigmoid activation function connected to the addition module, and a channel attention layer connected to the Sigmoid activation function; the spatial attention module includes a second maximum pooling layer and a second average pooling layer arranged in series, a convolution layer connected to the second average pooling layer, a spatial attention layer connected to the convolution layer, and a second multiplication module; the first input end of the second multiplication module is connected to the spatial attention layer, the second input end of the second multiplication module is connected to the output end of the first multiplication module, and the output end of the second multiplication module is used to output the processed beef image.

[0010] Optionally, the lightweight deep learning model is trained and verified using the training set and verification set of each color space respectively to obtain the trained lightweight deep learning model of each color space as the beef freshness detection model of each color space, which also includes: enhancing the training set and verification set of each color space respectively; the methods for enhancing the training set and verification set of each color space include: one or more of scaling enhancement, rotation enhancement, translation enhancement, stretching enhancement, pixel block random disappearance enhancement, rotation + scaling enhancement, rotation + translation enhancement, translation + pixel block random disappearance enhancement and rotation + pixel block random disappearance enhancement.

[0011] Optionally, the indicators for testing the beef freshness detection model in each color space include: one or more of average weighted accuracy, average weighted precision, average weighted recall and F1 score.

[0012] A computer device comprises: a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above method.

[0013] A computer-readable storage medium stores a computer program, which implements the above method when executed by a processor.

[0014] A smart phone device includes: a memory, a processor, and an app program stored in the memory and executable on the processor, wherein the processor executes the app program to implement the above method.

[0015] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0016] The embodiments of the present invention provide a beef freshness detection method, device and medium based on lightweight deep learning. The embodiments of the present invention obtain beef freshness detection models of different color spaces by training a lightweight deep learning model, and select the beef freshness detection model of the target color space according to the test results, so as to realize the detection of beef freshness in the target color space. The embodiments of the present invention adopt computer vision technology to realize rapid detection of beef freshness, and the lightweight deep learning model used can be deployed on external devices with limited hardware resources, thereby improving the diversity of detection methods, and the detection method is not affected by ambient temperature and humidity, thereby improving the accuracy of detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A flowchart of a beef freshness detection method based on lightweight deep learning provided in an embodiment of the present invention.

[0019] Figure 2 The stored beef provided by the embodiment of the present invention is in RGB, HSV, Example images in color space.

[0020] Figure 3A schematic diagram of the structure of a lightweight deep learning model provided in an embodiment of the present invention.

[0021] Figure 4 This is an example diagram of the detection results provided by the embodiment of the present invention.

[0022] Figure 5 A schematic diagram of using the mobile phone app provided in an embodiment of the present invention.

[0023] Figure 6 An internal structure diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] The purpose of the present invention is to provide a beef freshness detection method, device and medium based on lightweight deep learning, which can realize rapid and accurate detection of beef freshness.

[0026] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0027] Example 1

[0028] like Figure 1 As shown, this embodiment provides a beef freshness detection method based on lightweight deep learning, and the method includes the following steps.

[0029] Step 101, respectively obtaining a plurality of RGB beef images with different freshness labels, specifically comprises the following steps.

[0030] Step 1-1, collect RGB images of stored beef samples of different freshness, and determine the volatile basic nitrogen (TVB-N) and total bacterial count (TVC) contents in stored beef according to the methods in "GB 5009.228-2016 Determination of volatile basic nitrogen in food" and "GB 4789.2-2010 Determination of total bacterial count in food microbiological examination".

[0031] Exemplarily, about 26 kg of fresh beef tenderloin is obtained from 10 cows, sliced ​​and stored in a refrigerator at 4°C, 30 samples are taken out from the beef samples during the storage period every day, RGB images of the beef samples are obtained, and the TVB-N and TVC contents of the beef are measured, and sampling is performed continuously for 7 times (day 0, day 1, day 2, day 3, day 4, day 5, day 6), and RGB images, TVB-N contents, and TVC contents of a total of 210 beef samples are obtained.

[0032] Among them, the TVB-N content in beef is detected by the method in "GB 5009.228-2016 Determination of Volatile Basic Nitrogen in Food"; the TVC content in beef is detected by the method in "GB 4789.2-2010 Determination of Total Colony Count in Food Microbiological Examination"; the size of the RGB image of the stored beef sample (i.e., RGB beef image) is 512×512×3.

[0033] Step 1-2, according to the content standards in "GB 4789.2-2010 Determination of total bacterial count in food microbiology examination" and "GB 4789.2-2010 Determination of total bacterial count in food microbiology examination" and the TVB-N and TVC contents in stored beef measured in step 101, the RGB beef images collected in step 1-1 are divided into three categories: fresh beef, acceptable beef, and corrupt beef, thereby obtaining a data set of RGB beef images with freshness labels.

[0034] Exemplarily, 210 beef samples were divided into three categories, wherein 90 samples stored for 0-2 days belonged to the fresh beef category, 30 samples stored for 3 days belonged to the acceptable beef category, and 90 samples stored for 4-6 days belonged to the spoiled beef category.

[0035] Step 102, constructing a training set, a validation set, and a test set in different color spaces based on a plurality of RGB beef images with different freshness labels; the different color spaces include RGB color space, HSV color space, and The color space specifically includes the following steps.

[0036] In step 2-1, the dataset of RGB beef images with different freshness labels is divided into a training set, a validation set, and a test set in a ratio of 7:1:2 and summarized to obtain the training set, validation set, and test set of RGB beef images of all categories, that is, the training set, validation set, and test set of the RGB color space.

[0037] Among them, there are a total of 147 RGB beef images in the test set, of which 63 belong to the fresh beef category, 21 belong to the acceptable beef category, and 63 belong to the corrupt beef category.

[0038] There are a total of 21 RGB beef images in the validation set, of which 9 belong to the fresh beef category, 3 belong to the acceptable beef category, and 9 belong to the spoiled beef category.

[0039] There are a total of 42 RGB beef images in the test set, 18 of which belong to the fresh beef category, 6 to the acceptable beef category, and 18 to the spoiled beef category.

[0040] Step 2-2, convert the RGB beef images in the training set, validation set, and test set in RGB color space to HSV and In the color space, a total of three color space training sets, validation sets and test sets were obtained, namely RGB, HSV, The training set, validation set and test set of the color space, among which the stored beef is in RGB, HSV, Images in color space, such as Figure 2 shown.

[0041] Step 103, respectively using the training set and validation set of each color space to train and validate the lightweight deep learning model, to obtain the trained lightweight deep learning model of each color space as the beef freshness detection model of each color space, specifically includes the following steps.

[0042] Step 3-1, using at least one of the 9 image enhancement methods, respectively, perform image enhancement on the images in the training set and the validation set in the three color spaces. The 9 image enhancement methods include 5 single enhancement methods and 4 mixed enhancement methods. The 5 single enhancement methods are: scaling enhancement, rotation enhancement, translation enhancement, stretching enhancement, and pixel block random disappearance enhancement; the 4 mixed enhancement methods are: rotation + scaling enhancement, rotation + translation enhancement, translation + pixel block random disappearance enhancement, and rotation + pixel block random disappearance enhancement. As an implementation method, the above 9 image enhancement methods are used to enhance RGB, HSV and Data augmentation was performed on the images in the training set and validation set in color space, and the images in the test set remained unchanged. For example, the number of beef images after image augmentation is shown in Table 1.

[0043]

[0044] Step 3-2, in the embodiment of the present invention, a plurality of efficient bottleneck layer modules (E-bneck), cascaded atrous pyramid pooling modules (CASPP), convolutional attention modules (CBAM), convolutional layers and decision functions (SoftMax) are used to build a lightweight deep learning model (Real-time beef freshness evaluation, RT-BFE), such as Figure 3 As shown, Figure 3 Part (a) is the overall structure of the RT-BFE deep learning model. Figure 3 Part (b) is the structure of the E-neck part. Figure 3 Part (c) is the structure of the CASPP part. Figure 3 Part (d) is the structure of the CBAM part. Figure 3 In the figure, BN is batch normalization; HS is the h-swish activation function; RE is the ReLU activation function; ReLU is also the ReLU activation function; AvgPool is average pooling; MaxPool is maximum pooling; Dilated Conv is dilated convolution; Softmax is the Softmax decision function; σ is the Sigmoid activation function; C is the number of input channels; C' is the expansion layer channel, H and W are the height and width of the image, and ECA is the efficient channel attention mechanism.

[0045] like Figure 3 As shown, the lightweight deep learning model includes a first convolution module, a first efficient bottleneck layer component, a second efficient bottleneck layer component, a cascaded void pyramid pooling module, a convolution attention module, a second convolution module, a third convolution module, a fourth convolution module and a decision function connected in sequence.

[0046] The first high-efficiency bottleneck layer component includes a plurality of first high-efficiency bottleneck layer modules connected in sequence, and the second high-efficiency bottleneck layer component includes a plurality of second high-efficiency bottleneck layer modules connected in sequence.

[0047] The first high-efficiency bottleneck layer module and the second high-efficiency bottleneck layer module both adopt an E-bneck network structure.

[0048] The E-bneck network structure includes a fifth convolution module, a depth-separable convolution module, an ECA judgment module and a sixth convolution module which are connected in sequence.

[0049] The cascaded atrous pyramid pooling module includes: a plurality of Split modules arranged in parallel; a seventh convolution module connected to the first Split module among the plurality of Split modules arranged in parallel; N-2 atrous convolution modules respectively connected to the second Split module to the N-1th Split module among the plurality of Split modules arranged in parallel; wherein the output end of the nth Split module is also connected to the input end of the n+1th Split module, n=1, 2, ..., N-2; N is the number of Split modules; an eighth convolution module connected to the Nth Split module among the plurality of Split modules arranged in parallel; and a ninth convolution module connected to the seventh convolution module, the atrous convolution module and the eighth convolution module.

[0050] The convolutional attention module includes: a channel attention module, a first multiplication module and a spatial attention module; the first input end of the first multiplication module is used to input the original beef image, the second input end of the first multiplication module is connected to the output end of the channel attention module, and the output end of the first multiplication module is connected to the spatial attention module.

[0051] The channel attention module includes a first maximum pooling layer and a first average pooling layer arranged in parallel, a tenth convolution module connected to the output ends of the first maximum pooling layer and the first average pooling layer, an addition module connected to the tenth convolution module, a Sigmoid activation function connected to the addition module, and a channel attention layer connected to the Sigmoid activation function.

[0052] The spatial attention module includes a second maximum pooling layer and a second average pooling layer arranged in series, a convolutional layer connected to the second average pooling layer, a spatial attention layer connected to the convolutional layer, and a second multiplication module; a first input end of the second multiplication module is connected to the spatial attention layer, a second input end of the second multiplication module is connected to the output end of the first multiplication module, and the output end of the second multiplication module is used to output the processed beef image.

[0053] The convolution module in the embodiment of the present invention includes a convolution layer (Conv), a batch normalization (BN) and an activation function layer. Different convolution modules can be obtained by setting different convolution layers or activation functions. For details, see Figure 3 .

[0054] Further, such as Figure 3 As shown, in the embodiment of the present invention, convolutional layer, batch normalization, activation function ReLu, activation function h-swish, activation function Sigmoid, depthwise separable convolution (Depthwise Separable Conv), dilated convolution (Dilated Conv), efficient channel attention mechanism ECA, channel attention mechanism CAM, spatial attention mechanism SAM, average pooling layer Avgpool, maximum pooling layer Maxpool are used to construct an efficient bottleneck layer module, a cascaded dilated pyramid pooling module, and a convolution attention module. Finally, a decision function (SoftMax) is connected to build the entire RT-BFE network for beef freshness detection. The parameters of each part are shown in Table 2.

[0055]

[0056] In step 3-3, the beef images in the training set and validation set enhanced in step 3-1 are respectively input into the RT-BFE network established in step 3-2, the beef images in the training set are iteratively trained in a supervised manner, the beef images in the validation set are used to verify the model obtained in each round of training, and the model weights are updated in real time using the back propagation method to continuously iterate and optimize the model, thereby obtaining three beef freshness detection models (i.e., three trained lightweight deep learning models) that can effectively extract beef freshness features and detect beef freshness based on these features, namely: a beef freshness detection model in RGB color space for detecting beef freshness using RGB beef images, a beef freshness detection model in HSV color space for detecting beef freshness using HSV beef images, and a beef freshness detection model in HSV color space for detecting beef freshness using Beef image for beef freshness detection Beef freshness detection model in color space.

[0057] Step 104, respectively testing the beef freshness detection model of each color space using the test set of each color space, and obtaining the beef freshness detection model of the color space with the best test result as the beef freshness detection model of the target color space.

[0058] In step 104 of the present invention, RGB, HSV, The performance of beef freshness detection models based on different color spaces was compared to determine the optimal color space (i.e., target color space) for beef freshness detection.

[0059] The indicators tested or compared in the embodiment of the present invention include average weighted accuracy, average weighted precision, average weighted recall, and F1 score. The higher the value of the indicator, the better the accuracy and robustness of the model. By comparing the performance of the three models, the optimal color space for beef freshness detection is determined to be Color space.

[0060] The calculation method of average weighted accuracy, average weighted precision, average weighted recall, and average weighted F1 score is shown in the following formula.

[0061] (1)

[0062] (2)

[0063] (3)

[0064] (4)

[0065] in, is the average weighted accuracy, is the average weighted precision, is the average weighted recall, is the average weighted F1 score, represents the number of categories; Representative in the The number of samples in each category; Representative in the The number of positive samples predicted by the beef freshness detection model in the category as positive; Representative in the The number of negative samples predicted as positive by the beef freshness detection model in the category; Representative in the The number of positive samples predicted as negative by the beef freshness detection model in the category, For the The prediction accuracy of each category, For the The recall rate of each category, For the The F1 score of each category.

[0066] The indicators of the beef freshness detection model in different color spaces are shown in Table 3.

[0067]

[0068] By comparing the performance of the three models, the optimal color space for beef freshness detection is determined to be Color space, the optimal model is Beef freshness detection model in color space.

[0069] exist The beef freshness detection model trained on the image is used as the best beef freshness detection model, that is, the beef freshness detection model in the target color space. Color space in the test set Beef image, according to , , , F 1 indicator, testing the beef freshness detection model in the target color space Color space in the test set Freshness detection effect of beef images; evaluate the computing performance of lightweight deep learning models based on the parameters, computation, and inference speed (FPS) of lightweight deep learning models. Color space in the test set The detection effect and computational performance of beef images are shown in Table 4.

[0070]

[0071] According to the results in Table 4, The lightweight deep learning model trained on the image also has a high detection accuracy for new samples, proving that the lightweight deep learning model of the present invention has good accuracy and robustness; in addition, the number of parameters of the lightweight deep learning model is only 1.11 M, the computational complexity of the lightweight deep learning model is only 59.35M FLOPs, and the detection speed of the lightweight deep learning model is as high as 72.25 FPS, proving that the lightweight deep learning model of the present invention has lightweight characteristics and can be deployed on resource-constrained edge devices.

[0072]

[0073] According to the results in Table 5, adding E-bncek, CASPP and CBAM modules to the deep learning model can significantly improve the detection accuracy, and the model has a high detection speed.

[0074] Figure 4 The CAM visualization diagram of the prediction results of the trained lightweight deep learning model for beef of different freshness. Through the CAM visualization method, it is verified that only adding the E-bneck module will make the deep learning model focus on the edge features; then adding the CASPP module expands the receptive field of deep learning and the attention range, so that the model can pay attention to more image features, but also pays attention to the background; finally, adding the CBAM module makes the deep learning model focus on the key image feature area, reducing the interference of useless information and improving the model's anti-interference ability. In summary, it is verified that the lightweight deep learning model focuses on the key feature area where the freshness of beef changes most obviously, which improves the interpretability of the lightweight deep learning model on the one hand, and shows that the lightweight deep learning model has good prediction performance on the other hand.

[0075] Step 105: Use the beef freshness detection model in the target color space to detect the freshness of the beef to be tested.

[0076] In summary, the beef freshness detection method based on lightweight deep learning of the present invention can detect the freshness of beef in real time, online and non-destructively, and has the advantages of simple operation, small computational complexity and fast detection speed. It can be deployed on resource-constrained edge devices to realize edge computing; in addition, the model has high scalability and portability, and can be used for freshness detection of different meat products.

[0077] Example 2

[0078] Embodiment 2 of the present invention provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method in Embodiment 1.

[0079] The computer device may be a database, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store pending transactions. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the method in Example 1 is implemented.

[0080] Example 3

[0081] Embodiment 3 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method in Embodiment 1 is implemented.

[0082] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0083] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present invention may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present invention may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0084] Example 4

[0085] This example 4 provides a mobile phone terminal, on which an app program is stored, and when the mobile phone app program is executed, the method in Example 1 is implemented.

[0086] Figure 5 This is an example of deploying a trained lightweight deep learning model on a smartphone and running an app on the phone to detect beef freshness in real time. Figure 5(a), (b) and (c) are example diagrams of the detection results of beef of different freshness, which verify that the above deep learning model has lightweight characteristics and can be deployed on the edge device to perform real-time detection of beef freshness. In addition, the deep learning model has high detection accuracy and can display the detection results with high precision.

[0087] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0088] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A beef freshness detection method based on lightweight deep learning, characterized in that: The method comprises: Obtain multiple RGB beef images with different freshness labels; Based on multiple RGB beef images with different freshness labels, we construct training sets, validation sets, and test sets in different color spaces; different color spaces include RGB color space, HSV color space, and Color space; The lightweight deep learning model is trained and verified using the training set and validation set of each color space respectively, and the trained lightweight deep learning model of each color space is obtained as the beef freshness detection model of each color space; the lightweight deep learning model includes a first convolution module, a first efficient bottleneck layer component, a second efficient bottleneck layer component, a cascaded dilated pyramid pooling module, a convolution attention module, a second convolution module, a third convolution module, a fourth convolution module and a decision function connected in sequence; the first efficient bottleneck layer component includes a plurality of first efficient bottleneck layer modules connected in sequence, and the second efficient bottleneck layer component includes a plurality of second efficient bottleneck layer modules connected in sequence; the first efficient bottleneck layer module and the second efficient bottleneck layer module both adopt an E-bneck network structure; the E-bneck network structure includes a fifth convolution module, a depthwise separable convolution module, an ECA judgment module and a sixth convolution module connected in sequence; The beef freshness detection model of each color space is tested using the test set of each color space respectively, and the beef freshness detection model of the color space with the best test result is used as the beef freshness detection model of the target color space; The beef freshness detection model in the target color space is used to detect the freshness of the beef.

2. The beef freshness detection method based on lightweight deep learning according to claim 1 is characterized in that: Based on multiple RGB beef images with different freshness labels, we constructed training sets, validation sets, and test sets in different color spaces, including: Multiple RGB beef images with different freshness labels are divided into training set, validation set and test set to obtain training set, validation set and test set in RGB color space; Convert the RGB beef images in the training set, validation set, and test set in the RGB color space to the HSV color space to obtain the training set, validation set, and test set in the HSV color space; Convert the RGB beef images in the training set, validation set, and test set to RGB color space respectively Color space, get Training, validation, and test sets for the color space.

3. The beef freshness detection method based on lightweight deep learning according to claim 1 is characterized in that: The cascaded dilute pyramid pooling module includes: multiple Split modules set in parallel; a seventh convolution module connected to the first Split module among the plurality of Split modules arranged in parallel; N-2 dilated convolution modules are respectively connected to the second to N-1th Split modules in the multiple Split modules arranged in parallel; wherein the output end of the nth Split module is also connected to the input end of the n+1th Split module, n=1, 2, ..., N-2; N is the number of Split modules; an eighth convolution module connected to an Nth Split module among the plurality of Split modules arranged in parallel; A ninth convolution module connected to the seventh convolution module, the dilated convolution module, and the eighth convolution module.

4. The beef freshness detection method based on lightweight deep learning according to claim 1 is characterized in that: The convolutional attention module includes: a channel attention module, a first multiplication module and a spatial attention module; the first input end of the first multiplication module is used to input the original beef image, the second input end of the first multiplication module is connected to the output end of the channel attention module, and the output end of the first multiplication module is connected to the spatial attention module; The channel attention module includes a first maximum pooling layer and a first average pooling layer arranged in parallel, a tenth convolution module connected to the output ends of the first maximum pooling layer and the first average pooling layer, an addition module connected to the tenth convolution module, a Sigmoid activation function connected to the addition module, and a channel attention layer connected to the Sigmoid activation function; The spatial attention module includes a second maximum pooling layer and a second average pooling layer arranged in series, a convolutional layer connected to the second average pooling layer, a spatial attention layer connected to the convolutional layer, and a second multiplication module; the first input end of the second multiplication module is connected to the spatial attention layer, the second input end of the second multiplication module is connected to the output end of the first multiplication module, and the output end of the second multiplication module is used to output the processed beef image.

5. The beef freshness detection method based on lightweight deep learning according to claim 1 is characterized in that: The lightweight deep learning model is trained and verified using the training set and validation set of each color space respectively, and the trained lightweight deep learning model of each color space is obtained as the beef freshness detection model of each color space. Previously, the following was also included: Enhance the training set and validation set of each color space separately; The methods for enhancing the training set and validation set of each color space include: one or more of: scaling enhancement, rotation enhancement, translation enhancement, stretching enhancement, pixel block random disappearance enhancement, rotation + scaling enhancement, rotation + translation enhancement, translation + pixel block random disappearance enhancement, and rotation + pixel block random disappearance enhancement.

6. The beef freshness detection method based on lightweight deep learning according to claim 1 is characterized in that: The indicators for testing the beef freshness detection model in each color space include one or more of: average weighted accuracy, average weighted precision, average weighted recall and F1 score.

7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. A smartphone device comprising: A memory, a processor, and an app program stored in the memory and executable on the processor, wherein the processor executes the app program to implement the method according to any one of claims 1 to 6.