Fruit traceability anti-counterfeiting system fusing dual-stream deep network and spatiotemporal behavior verification
By integrating dual-stream deep networks with spatiotemporal behavior verification, a fruit traceability and anti-counterfeiting system has been developed, enabling real-time dynamic evaluation of fruit quality and multi-dimensional anti-counterfeiting verification. This solves the problems of dynamic quality monitoring and single anti-counterfeiting dimensions in existing traceability systems, thereby improving the reliability and security of the anti-counterfeiting system.
Patent Information
- Application Number
- CN202611259296.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-12-01
AI Technical Summary
The existing agricultural product traceability system lacks dynamic quality monitoring and cannot perceive the quality status of agricultural products in real time during the circulation process. Furthermore, the anti-counterfeiting traceability technology has only one dimension of anti-counterfeiting and cannot effectively prevent counterfeiting.
The fruit traceability and anti-counterfeiting system integrates dual-stream deep networks and spatiotemporal behavior verification. It uses a twin neural network to perform feature matching on fruit images, combines a spatiotemporal decay module to assess quality changes, and combines scanning behavior and environmental data for multi-dimensional anti-counterfeiting verification.
It enables real-time dynamic evaluation of fruit quality and multi-dimensional anti-counterfeiting verification, improving the anti-counterfeiting reliability and security of the traceability system and effectively identifying abnormal counterfeiting behavior.
Smart Images

Figure CN123200218A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fruit anti-counterfeiting extraction technology, and in particular to a fruit traceability and anti-counterfeiting system that integrates dual-stream deep networks and spatiotemporal behavior verification. Background Technology
[0002] Current mainstream agricultural product traceability systems are centered on static information traceability, recording only fixed historical data such as the origin, batch, and distribution trajectory of agricultural products. This results in a significant lack of dynamic quality monitoring. Agricultural products are highly time-sensitive and prone to quality fluctuations. Their freshness, moisture content, and physiological state continuously deteriorate with changes in logistics time, environmental temperature, and humidity. High-value fresh fruits, in particular, experience rapid quality degradation and significant fluctuations in commodity value. However, existing traceability solutions only provide outdated, static traceability information, failing to perceive and update the dynamic quality status of agricultural products throughout their distribution process in real time. This makes it difficult to demonstrate the real-time quality of products at the point of sale to consumers, and thus cannot meet consumers' core verification needs for the freshness and safety of agricultural products. Consequently, the practical value of traceability systems is significantly limited.
[0003] Meanwhile, existing agricultural product anti-counterfeiting and traceability technologies suffer from significant shortcomings, including a single anti-counterfeiting dimension and a lack of spatiotemporal security verification mechanisms, resulting in obvious vulnerabilities in overall anti-counterfeiting reliability and security. Current mainstream fruit anti-counterfeiting solutions rely solely on static product visual features for single-dimensional comparison and verification, leading to a one-sided anti-counterfeiting verification logic that fails to form a comprehensive and multi-dimensional traceability security verification system. Furthermore, existing traceability systems are completely detached from user verification behavioral and spatiotemporal data, failing to incorporate multi-dimensional information such as the geographical location, time trajectory, and access frequency of consumer scanning for cross-verification. This makes it impossible to identify abnormal counterfeiting behaviors such as simultaneous scanning in different locations or high-frequency repeated scanning within a short period, and to effectively prevent typical counterfeiting methods such as label recycling and reuse, label cloning, and product substitution. The single visual anti-counterfeiting model lacks dynamic security verification logic, has weak anti-attack capabilities, and cannot adapt to the complex anti-counterfeiting needs of large-scale fruit circulation scenarios, making it difficult to truly achieve accurate and reliable individual fruit anti-counterfeiting and traceability verification. Summary of the Invention
[0004] To overcome the shortcomings of the existing technologies, such as the lack of a dynamic quality assessment mechanism and the single anti-counterfeiting dimension, this invention proposes a fruit traceability and anti-counterfeiting system that integrates dual-stream deep networks and spatiotemporal behavior verification.
[0005] To achieve the above objectives, the present invention adopts the following technical solution, including: The fruit traceability and anti-counterfeiting system integrates dual-stream deep network and spatiotemporal behavior verification, including a registration terminal, user terminal, cloud database module, anti-counterfeiting module and quality assurance module; Registration end: Staff at the production site input the original image of the fruit, preprocess the original image of the fruit and configure a unique QR code ID for the original image of the fruit, generate the latitude and longitude coordinates of the production site and the time stamp of the warehouse exit, and automatically plan the optimal route and set the temperature according to the fruit type. After binding the preprocessed original image of the fruit, QR code ID, latitude and longitude coordinates, time stamp of the warehouse exit, optimal route and set temperature, the data is sent to the cloud database module. User-side: The user inputs a fruit image, which is preprocessed and automatically generates a barcode scanning event and real-time temperature data. The preprocessed fruit image, barcode scanning event, and real-time temperature data are then transmitted to the cloud database module, quality assurance module, and anti-counterfeiting module. The barcode scanning event includes the latitude and longitude coordinates and timestamp at the time of scanning. The user-side has a built-in decision engine module, which converts the output results of the anti-counterfeiting module and quality assurance module into fruit quality and authenticity determination results and displays them to the user. The cloud database module includes a twin neural network architecture. It retrieves the original fruit image with the same ID as the fruit image from the database storage module and uses the fruit image and the original fruit image as input to the trained twin neural network architecture. These are converted into original feature vectors and barcode feature vectors, respectively. The two sets of feature vectors are then mapped to the same hypersphere embedding space through a linear mapping layer. Within the hypersphere embedding space, feature vectors of the same fruit are close to each other, while feature vectors of different fruits are far apart. The quality assurance module includes a spatiotemporal decay module and a health assessment module. It calls upon data stored in the cloud database module and fruit images transmitted from the user terminal. The spatiotemporal decay module estimates the degree of fruit quality decay based on transportation time, trajectory deviation, and environmental factors, outputs a quality score, and sends the quality score to the user terminal's decision engine. The health assessment module labels each pixel, judges the health level of the fruit skin received by the user terminal by statistically analyzing the labels, outputs a health estimate, and sends the health estimate to the user terminal's decision engine. The anti-counterfeiting module includes a QR code conflict probability module and an identity verification module. The QR code conflict probability module outputs a spatiotemporal hard conflict marker and a counterfeiting probability based on the scanning event of the QR code ID. The spatiotemporal hard conflict marker determines whether the fruit conforms to the physical movement law. The identity verification module compares the similarity of the fruit before and after transportation through the feature vector output by the twin neural network architecture, and outputs the identity confidence score after normalization. The spatiotemporal hard conflict marker, counterfeiting probability, and identity confidence score are sent to the decision engine on the user end.
[0006] Preferably, the twin neural network architecture includes the same two branches, the original fruit image. Images of fruits Each input is used as a branch input, and the inputs are processed by an encoder to extract texture features, global average pooling, linear projection mapping to a fixed length, and normalization, respectively, outputting the original feature vectors. and QR code feature vector Furthermore, a linear projection layer is added to map the two feature vectors to the same hypersphere embedding space.
[0007] Preferably, an authentication stream training set and a health assessment stream training set are constructed separately. The authentication stream training set includes images uploaded by the registration client and the user client, and includes original fruit images. Images of fruits Image-level label pairing is performed to determine whether the images are from the same fruit; the health assessment stream training set mainly includes images uploaded by users, in which the proportion of damaged sample images is not less than a set percentage, and the images are labeled at the pixel level.
[0008] Preferably, the Siamese neural network architecture uses a triplet loss function for training convergence, and triples are selected from the authentication stream training set. , , ),in, This represents the registration image uploaded by the registration client; This indicates a positive sample, which is a scanned image of the same fruit uploaded by the user and registered as the sample. This represents a negative sample, which is a scanned image of a fruit uploaded by the user that is different from the registered sample. Triplet Loss:
[0009] in, This represents the encoding of a twin neural network; Represents the square of the L2 norm; This is a margin parameter for the forced class spacing. ; i is the index of the registered sample in the authentication stream training set, and N is the total number of registered samples in the authentication stream training set.
[0010] Preferably, the spatiotemporal decay module constructs a quality estimation function based on the Arrhenius equation:
[0011] in, The initial quality score of the fruit upon leaving the warehouse; For transportation time, , For the scan timestamp, This is the timestamp for when the item was shipped out. This is a function of hourly temperature along the transportation route; Based on the rate of corruption, This is the temperature sensitivity coefficient.
[0012] Preferably, the cloud database module also includes an external data retrieval module; the Haversine spherical distance deviation between the actual transportation path and the planned optimal path is defined as... Preset threshold ; when At that time, it was determined that the transportation was within the planned temperature range. Use planned temperature settings; when When the system determines that the transport section has left the temperature-controlled environment, it automatically retrieves the actual surface temperature of the road section from the meteorological data interface using an external data retrieval module, replacing the planned set temperature. .
[0013] Preferably, the health assessment module processes the input fruit image. First, the encoder downsamples to expand the receptive field and extracts multi-scale features of tiny spots and large lesions layer by layer. After encoding, the image is upsampled step by step by the decoder to restore the image resolution. Each upsampling step introduces a self-attention mechanism to suppress background noise and enhance the response to tiny mold spots and browning areas. The decoder outputs a five-channel probability map, with each channel corresponding to a label of healthy, moldy, browning, mechanical damage, and occlusion. The five-channel probability map is then converted into a binary damage mask. Post-damage area statistics and visible surface area Damage area The sum of pixels for labels with mold, browning, and mechanical damage, representing the visible surface area. Calculate the damaged area based on the total number of pixels excluding occlusions. Occupying visible surface area The ratio: Health assessment score: .
[0014] Preferably, the health assessment module is trained based on the health assessment stream training set, using a weighted loss function of Dice Loss and Focal Loss:
[0015] Where X represents the damage region predicted by the network; Y represents the ground truth damage region annotated manually. To prevent smoothing terms from being divided by zero; The Dice Loss value is responsible for fitting the macroscopic shape of the overall contour of the lesion area; For focusing parameters; This represents the model's predicted probability of the true class of this pixel. The category balancing weights take values of (0,1); FocalLoss is the loss value used to combat the imbalance of pixel area between different labels within an image; Loss due to dice The weight.
[0016] Preferably, the QR code conflict probability module uses two consecutive QR code scanning events from the user's end as the basis for the probability. , Input: Spatiotemporal hard collision marker and the probability of forgery ;in and These are the latitude and longitude coordinates of the mobile phone used when scanning the QR code. and These are the timestamps from the two separate scans; Preset physical displacement limit velocity The great circle distance between the two scans is calculated using the Haversine formula. and apparent movement speed ; like Then the spacetime hard conflict marker Probability of forgery ; like Then the spacetime hard conflict marker Count the number of times N is scanned within 24 hours for the unique QR code ID of the fruit, and set a maximum scanning frequency. ;like Probability of forgery ;like Probability of forgery 0.
[0017] Preferably, the authentication module compares the original feature vectors. and QR code feature vector The cosine similarity is normalized to output the identity confidence score. , .
[0018] The advantages of this invention are: (1) Based on the quality assurance module and the anti-counterfeiting module, this invention fully considers the natural changes in fruit peel texture and surface features caused by the physiological decay of fruit, and divides the differential feature matching judgment threshold according to the degree of decay. For fruits with severe decay and large changes in peel features, the identity feature matching constraints are relaxed to avoid misjudgment of genuine products due to normal physiological loss of fruit, greatly improve the robustness of visual anti-counterfeiting identification under complex circulation cycle, and take into account the authenticity of traceability and the objective law of fruit physiological changes.
[0019] (2) The quality assurance module, which includes a spatiotemporal decay module and a health assessment module, constructs a complete dynamic quality assessment mechanism for fruits, breaking through the limitations of traditional traceability systems that can only record static origin and batch information. The spatiotemporal decay module combines outbound time, circulation trajectory deviation, and environmental compensation factors to quantitatively calculate the degree of quality decay in the entire circulation chain of fruits; the health assessment module uses pixel-level lesion labels to statistically quantify the health level of fruits, and can output the current freshness and decay status of fruits in real time, solving the pain point that traditional static traceability cannot reflect the dynamic deterioration of fruits over time and in the storage and logistics environment, allowing consumers to intuitively grasp the real-time quality of fruits.
[0020] (3) Triple verification basis of anti-counterfeiting module: Based on twin neural network, the identity matching of fruit skin texture features is completed; the rationality of scanning time and space trajectory is verified by relying on physical movement law; and the feature matching judgment threshold is adaptively adjusted in combination with the fruit quality decay law. This realizes the cross-joint verification of image biological features, time and space behavior and physiological decay features, makes up for the shortcomings of traditional schemes in missing time and space trajectory verification, greatly improves the overall anti-swapping and anti-label cloning capabilities, and breaks through the traditional single-dimensional anti-counterfeiting method. Attached Figure Description
[0021] Figure 1 This is a diagram of the module architecture of this system; Figure 2 for Processing flowchart; Figure 3 This is a flowchart of the decision engine's decision process. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0023] Example 1
[0024] A fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification, such as Figure 1 As shown, it includes a registration client, a user client, a cloud database module, a quality assurance module, and an anti-counterfeiting module: Registration end: Staff at the production site input the original image of the fruit. Original images of fruit Preprocessing and original fruit images Configure a unique QR code ID and generate the latitude and longitude coordinates of the place of origin. and outbound timestamp It automatically plans the optimal path and set the temperature based on the type of fruit, and then processes the pre-processed original fruit images. QR code ID, latitude and longitude coordinates Outbound timestamp After the optimal path is planned and the set temperature is bound together, it is sent to the cloud database module. User-side: User inputs a fruit image images of fruits The preprocessed fruit image is then automatically generated with scanning event C(L,T) and real-time temperature data. The scanning event C(L,T) and real-time temperature data are transmitted to the cloud database module, quality assurance module, and anti-counterfeiting module, where L is the latitude and longitude coordinates at the time of scanning and T is the scanning timestamp; the user terminal has a built-in decision engine module, which will... Defend The outputs of the pseudo-module and the quality assurance module are converted into the quality and authenticity determination results of the fruit and displayed to the user.
[0025] Cloud database module: includes a twin neural network architecture, a database storage module, and an external data retrieval module; The original fruit images input from the registration and user terminals. Images of fruits As input, the trained Siamese neural network architecture processes the original fruit image... Images of fruits Transform into original feature vector and QR code feature vector The original feature vector is transformed through a linear mapping layer. and QR code feature vector Mapping to the same hypersphere embedding space makes the feature vectors of the same fruit closer together and the feature vectors of different fruits farther apart; original feature vectors and QR code feature vector The input is stored in the database storage module.
[0026] Original feature vector Containing the semantics of natural fruit peel texture, corresponding one-to-one with a single fruit, this feature vector is robust to different shooting angles (within ±15°) for the same fruit; it has high distinguishability for different individual fruits, serving as an irreproducible "natural biological characteristic" of the fruit.
[0027] The database storage module is used to store data input from the registration end and the user end; all data uploaded by the registration end is converted into hash values through SHA-256 hash operation to complete data binding and storage.
[0028] Preferably, the hash value is written to the consortium blockchain storage node to ensure that the original registration data cannot be tampered with.
[0029] The external data retrieval module can retrieve environmental data along the route; Quality Assurance Module: Includes Spatiotemporal Decay Module and Health Assessment Module; The spatiotemporal decay module accesses data stored in the cloud database module, including QR code IDs and latitude / longitude coordinates. Outbound timestamp The system plans the optimal route, sets the temperature, collects environmental data along the route, scans the code event C(L,T), and collects real-time temperature data. Based on the timestamp, it calculates the transportation time, estimates the degree of fruit quality degradation based on the trajectory deviation between the actual transportation route and the planned optimal route and environmental factors, outputs a quality score, and sends the quality score to the user's decision engine. The health assessment module uses fruit images transmitted from the user's device. Each pixel is labeled, and the current health score of the scanned fruit is obtained by statistically analyzing the labels. The health score is then sent to the decision engine on the user's end. Anti-counterfeiting module: includes a barcode collision probability module and an identity verification module; it judges whether the fruit meets the physical movement law based on the user terminal barcode scanning event C(L,T) sequence, and calls the feature vector of the cloud database module to compare the similarity of the same ID of the fruit before and after transportation, and judges whether the fruit is genuine from multiple dimensions.
[0030] Specifically, the QR code collision probability module outputs a spatiotemporal hard collision marker and a forgery probability based on the historical QR code ID of the fruit scanned by the historical QR code event sequence C(L,T). The spatiotemporal hard collision marker determines whether the fruit conforms to the physical movement law. The authentication module compares the original feature vectors output by the Siamese neural network architecture. and QR code feature vector The similarity is normalized, and the identity confidence score is output. Set a threshold to determine the confidence level of the identity. Fruits exceeding the threshold are classified as genuine products; Using spatiotemporal hard conflict markers, forgery probability, and identity confidence levels The decision engine sent to the user's device.
[0031] Preferably, the Sigmoid function is used for normalization calculation.
[0032] Both the registration and user terminals have a built-in lightweight object detection network that processes the original fruit images. Images of fruits Preprocessing: Original fruit image Images of fruits A lightweight object detection network is used to locate the main fruit region, which is then cropped and scaled for alignment. Low-frequency illumination components are then filtered out using a bandpass filter, while high-frequency details representing the texture are preserved. This is then reconstructed into a destylized intrinsic layer. The interference of lighting and background on texture extraction in uncontrolled environments is mitigated. Finally, the pixel values are normalized by mean and standard deviation to make them conform to a normal distribution, thus accelerating model convergence.
[0033] Preferably, the lightweight object detection network uses the YOLOv8-nano or MobileNet-SSD detection model.
[0034] The twin neural network architecture consists of two identical branches, each of which includes an encoder, a pooling layer, a linear projection layer, a normalization layer, and a hypersphere embedding space.
[0035] The twin neural network architecture retrieves fruit images from the database storage module. Original fruit images with the same ID .
[0036] Original fruit image after preprocessing Images of fruits Each feature is used as input to one branch of the image. The encoder extracts the fruit-specific texture features from the image, then compresses them into one-dimensional intermediate feature vectors through global average pooling to eliminate interference from factors such as shooting distance and size. The two sets of one-dimensional intermediate feature vectors are mapped to a fixed length through linear projection, and after normalization, the original feature vectors are output. and QR code feature vector And add a linear projection layer to the original feature vector and QR code feature vector Mapped into the same hypersphere embedding space, feature vectors of the same fruit are close to each other, while feature vectors of different fruits are far apart; original feature vectors and QR code feature vector The input is stored in the database storage module.
[0037] Preferably, the encoder uses a residual network ResNet-50.
[0038] A Siamese neural network architecture is trained using a triplet loss function based on an authentication stream training set.
[0039] Triples were selected from the authentication stream training set. , , ),in This represents the i-th registration image uploaded by the registration client; This indicates a positive sample, which is a scanned image of the same fruit uploaded by the user and registered as the sample. This represents a negative sample, which is a scanned image of a fruit uploaded by the user that is different from the registered sample. Training is performed using the triplet loss function:
[0040] Where f(·) represents the encoding function of the Siamese neural network; The squared L2 norm is used to calculate the Euclidean distance between two feature vectors in the embedding space. The margin parameter for forced class spacing is a fixed hyperparameter that is preset by the user. ; i is the index of the registered sample in the authentication stream training set, and N is the total number of registered samples in the authentication stream training set.
[0041] Hyperparameters for forced class spacing The distance control values for "anchor point-negative sample" distance and "anchor point-positive sample" distance are specified, requiring that the "anchor point-negative sample" distance be at least greater than the "anchor point-positive sample" distance. Preferred .
[0042] The triplet loss is converged through training. The inversely constrained twin neural network architecture ensures that the original feature vectors of the same fruit... and QR code feature vector In the hypersphere embedding space, the original feature vectors of different fruits are close to each other. and QR code feature vector They are far apart in the space embedded in the hypersphere.
[0043] This results in the original feature vector output by the Siamese neural network architecture. and QR code feature vector The identity verification module can directly compare similarities and output the identity confidence score. Credible.
[0044] Spatiotemporal decay module: The physical nature of fruit quality degradation is determined by a single pathway: cumulative temperature exposure. This invention constructs a quality estimation function based on the Arrhenius equation, widely used in food science.
[0045] in, This is the initial quality score for the fruit when it leaves the warehouse; the default value is 100. The shipping time is calculated as the consumer's scan timestamp T and the warehouse departure timestamp. Time difference between them: ; The hourly temperature function along the transportation route, in °C; The physiological spoilage coefficient of this fruit variety was pre-fitted. After determining the fruit type and storage temperature range, the logarithmic linearized least squares method of the Arrhenius equation was used to determine the spoilage coefficient. , Perform fitting; after fitting , Constant values: The rate of basal decay is directly determined by the type of fruit; at the same temperature, The larger the fruit, the less resistant it is to storage, and the faster its quality deteriorates. For temperature sensitivity coefficient, The larger the size, the more severe the spoilage effect caused by increased temperature, and the faster the quality declines; Q represents the timestamp of the consumer's scan. The quality score of the fruit at that time.
[0046] The transportation route itself does not directly cause corruption, but if the logistics trajectory deviates from the planned transportation route, it will prolong transportation time and worsen temperature exposure, thus affecting the consumer's scan timestamp. and hourly temperature function .
[0047] Define the Haversine spherical distance deviation between the actual transportation path and the planned optimal path as: The unit is kilometers; preset threshold , This indicates how far the actual path deviates from the planned path before it is considered to have left the temperature-controlled environment. : when At that time, it was determined that the transportation was within the planned temperature range. Use planned temperature settings; when If the system determines that the transport segment has deviated from the temperature-controlled environment, and if abnormal detours, temporary open-air transshipment, or incorrect storage occur, the system will automatically retrieve the actual surface temperature of the route from the meteorological data interface using the external data retrieval module, replacing the planned set temperature. .
[0048] like This could lead to frequent misjudgments due to normal navigation detours and GPS errors; if This could lead to delays in identifying actual detours and incorrect warehousing.
[0049] Meteorological data interfaces can be obtained using the China Meteorological Administration's CMA public API or OpenWeatherMap.
[0050] The health assessment module takes the input fruit image as input. First, the encoder downsamples to expand the receptive field and extracts multi-scale features of tiny spots and large lesions in layers. After encoding, the image is upsampled step by step in the decoder to restore the image resolution. Each upsampling step introduces a self-attention mechanism to suppress background noise and enhance the response to tiny mold spots and browning areas.
[0051] The network categorizes each pixel of an image into five types of tags: healthy skin, mold, browning, mechanical damage, and occlusion.
[0052] The decoder outputs a five-channel probability map, with each channel corresponding to one of the five categories of labels mentioned above. The value of each pixel in each of the five channels is normalized using Softmax (the sum of the probabilities of the five channels is 1), representing the probability that the pixel belongs to each category. ; Taking argmax along the channel dimension of the five-channel probability map, we obtain five single-channel classification mask images, where the value of each pixel is an integer class label from 0 to 4. To statistically analyze the damage area, a binary damage mask is further generated. When a pixel's classification label belongs to any of the following: mold, browning, or mechanical damage, The pixel value is 1 if it is not 0 otherwise.
[0053] Calculate the damaged area separately and visible surface area Damage area The sum of pixels for labels with mold, browning, and mechanical damage, representing the visible surface area. It is the total number of all pixels excluding those with occlusion, i.e., the sum of pixels labeled "health," "mold," "browning," and "mechanical damage."
[0054] Calculate the damaged area Occupying visible surface area The ratio:
[0055] A health assessment score was obtained: Health assessment score This is used to determine whether the current quality of the fruit meets the normal sales standards.
[0056] Preferably, the encoder has 4 levels of downsampling, with the number of channels being 64, 128, 256, and 512 respectively.
[0057] In fruit images, damaged pixels constitute a very small percentage of the overall image—healthy pixels often account for over 95%, while early, tiny lesions may only account for a few percent or even a few thousandths. This leads to an imbalance in pixel area among different labels within a single image. If left unaddressed, the model will tend to predict all pixels as "healthy" to minimize overall loss, resulting in missed detection of tiny lesions.
[0058] To ensure that the health assessment module accurately labels and outputs highly reliable health assessment scores. The health assessment module is trained using a weighted loss function of Dice Loss and Focal Loss, based on the health assessment stream training set.
[0059]
[0060] Where X represents the damage region predicted by the network, i.e., the binary damage mask. The damaged pixel region in the training set; Y is the manually labeled ground truth damaged region, that is, the manually labeled damaged pixel region in the health assessment stream training set. To prevent smoothing terms from being divided by zero, ; This represents the Dice Loss value. For focusing parameters; This represents the model's predicted probability of the true class of this pixel. The category balancing weights take values of (0,1); The Focal Loss value; Loss due to dice The weight, preferred, .
[0061] Preferred, .
[0062] Dice Loss optimizes from the perspective of region overlap, responsible for the macroscopic shape fitting of the overall contour of the lesion region, ensuring the integrity of the segmented region shape, accurate boundaries, and avoiding fragmentation; Focal Loss, through... The factor reduces the weight of a large number of easily classifiable healthy pixels, focusing on early, minor damaged pixels that are difficult to classify, thus resisting the aforementioned pixel-level imbalance problem.
[0063] The QR code collision probability module calculates the spatiotemporal consistency of the user-side QR code scanning event sequence for the unique QR code ID of the fruit, and outputs two core variables: spatiotemporal hard collision markers. and the probability of forgery .
[0064] Spacetime Hard Conflict Marker : Two consecutive QR code scanning events on the user's end , For input, where and These are the latitude and longitude coordinates of the mobile phone's GPS when scanning the code, respectively. and These are the timestamps from the two QR code scans.
[0065] Preset physical displacement limit velocity The great circle distance between the two scans is calculated using the Haversine formula. Calculate the apparent moving speed .
[0066] like If the physical movement speed does not conform to the laws of physical movement, there will be a physical conflict due to synchronous scanning in different locations, resulting in a spatiotemporal hard conflict marker. ;like Then the spacetime hard conflict marker .
[0067] Preferred, The maximum cruising speed for civil aviation is 920 km / h.
[0068] Probability of forgery
[0069] like , Preferred A margin of 0.01 uncertainty is reserved to cope with extreme situations such as GPS drift or timestamp tampering.
[0070] like 0. Count the cumulative number of scans N for the unique QR code ID of this fruit within 24 hours, with a preset maximum scanning frequency. .
[0071] like , The more times a QR code is scanned, the higher the probability of counterfeiting. like ,but 0. This fruit is genuine.
[0072] Preferred maximum number of scans .
[0073] Preferably, the authentication module uses the standard cosine similarity algorithm to compare the original feature vectors. and QR code feature vector The similarity.
[0074] Identity confidence .
[0075] The user-side decision engine is based on spatiotemporal hard conflict markers. Probability of forgery The identity confidence level output by the identity verification module The health assessment module outputs a health assessment score. Based on the quality score (Q), the following evaluation criteria are used to comprehensively evaluate and output the three-color code of the scanned result.
[0076] Set confidence threshold , Health assessment score threshold and Quality score threshold , .
[0077] , , .
[0078] The three-color code is determined step by step according to the following steps: Step A (Red Code Interception): Check if any of the following conditions are met: (Hard conflict in simultaneous QR code scanning in different locations, suspected of being counterfeit); (Low confidence in identity, serious discrepancy between fruit pattern and appearance, identity abnormal); (The skin is severely rotten and deteriorated.) SCP>0.95 (High-frequency scanning, high probability of counterfeiting, suspected of being a copycat counterfeit).
[0079] If any condition is met, the system will immediately output a "red code" and mark the specific reason: "Abnormal identity", "Severely deteriorated" or "Suspected counterfeiting"; Preferred, , .
[0080] Step B (Yellow Code Triage): Excluding red codes, if any of the following conditions are met: (Minor mold or mechanical damage detected); (Near the expiration date); If any condition is met, the system will immediately output a "yellow code".
[0081] Preferred, , , .
[0082] Step C (Green Code Release): If all of the following conditions are met simultaneously: (Extremely high level of confidence in the identity); (Healthy epidermis); (Excellent quality); (Low probability of forgery); ==0 (No cross-regional conflict); If a colleague meets all the conditions, the system will output a "green code".
[0083] Preferred, , , .
[0084] Example 2
[0085] The following details the process of constructing the training set: First, to preserve the original image of the fruit The texture is clear, and the original feature vector is... To ensure semantic integrity, a uniformly diffused light source array is deployed during on-site filming to guarantee consistent imaging illumination.
[0086] The authentication stream training set includes no less than 15,000 sample images and no less than 10,000 images of different varieties of fruit, covering at least 6 major varieties such as apples, oranges, strawberries, and grapes. For each fruit, 3-5 standard images from different angles are collected at the registration end, and 5-8 images are collected at the user end under simulated different lighting and background conditions, totaling approximately 80,000-130,000 image pairs. Original image of the fruit Images of fruits Perform image-level pairing tags for "same fruit / different fruit".
[0087] The training set for the health assessment stream mainly includes damaged images uploaded by users. No less than 15,000 of these images are pixel-level annotated, with damaged sample images accounting for no less than 40% to ensure the model's sensitivity to damaged areas. Pixel-level annotations are pre-annotated using LabelMe or CVAT tools, and then corrected by agricultural quality inspection professionals.
[0088] Example 3
[0089] Log-linearized least squares method for the Arrhenius equation , Fitting method description: 200 samples were divided into 5 groups and placed in constant temperature environments of 4℃, 8℃, 15℃, 25℃, and 30℃ respectively. Hardness (puncture method), color difference, and total bacterial count (TPC) were measured every 12 hours for 7 consecutive days. The spoilage rate at each temperature was inferred from the slope of the decrease in quality indicators at each temperature point. Corruption rate model Logarithmic linearization is For 5 temperature points Perform least squares linear regression on the data to obtain... , goodness of fit .
[0090] Taking strawberries as an example, the basic spoilage rate coefficient is anchored by the commercial value half-life of approximately 48 hours at room temperature (25°C). Temperature sensitivity coefficient Substitute into the quality estimation function ; At the standard cold chain temperature of 4°C, Q≈95 after 72 hours, with slow decay and good preservation; at room temperature of 25°C, Q≈65 after 48 hours.
[0091] Example 4
[0092] The processing flow of the fruit traceability and anti-counterfeiting system based on fusion dual-stream deep network and spatiotemporal behavior verification includes the following steps: User uploads images of fruit taken by the user. The twin neural network architecture includes one branch and a health assessment module, which processes fruit images. Convert into QR code feature vector .
[0093] Original fruit image uploaded during registration The scanning event during node scanning is transmitted to another branch of the Siamese neural network architecture, which then transmits the fruit image... Transform into original feature vector and the original feature vector Stored in the database storage module.
[0094] The spatiotemporal decay module calls the timestamps from the user end and the registration end. and The system retrieves environmental data and route information from the external data retrieval module, real-time temperature data from the user terminal, and mobile phone location coordinates L, and outputs the fruit quality score Q. The health assessment module analyzes fruit images. The damaged area is used to output a health assessment score. .
[0095] The twin neural network architecture outputs the original feature vector. and QR code feature vector The data is transmitted to the authentication module, which compares the original feature vectors. and QR code feature vector The similarity is normalized, and the identity confidence score is output. ; The QR code collision probability module retrieves user-side QR code scanning event information from the database storage module and outputs spatiotemporal hard collision markers. and the probability of forgery ; The user scans the unique QR code ID of the fruit to invoke the decision engine, which then outputs a three-color code for the scanned fruit based on evaluation criteria.
[0096] Of course, those skilled in the art will recognize that the present invention is not limited to the details of the exemplary embodiments described above, but also includes the same or similar structures that can be implemented in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0097] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
[0098] The technologies, shapes, and structures not described in detail in this invention are all known technologies.
Claims
1. A fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification, characterized in that: This includes a registration module, a user module, a cloud database module, an anti-counterfeiting module, and a quality assurance module; Registration end: Staff at the production site input the original image of the fruit, preprocess the original image of the fruit and configure a unique QR code ID for the original image of the fruit, generate the latitude and longitude coordinates of the production site and the time stamp of the warehouse exit, and automatically plan the optimal route and set the temperature according to the fruit type. After binding the preprocessed original image of the fruit, QR code ID, latitude and longitude coordinates, time stamp of the warehouse exit, optimal route and set temperature, the data is sent to the cloud database module. User-side: The user inputs a fruit image, which is preprocessed and automatically generates a barcode scanning event and real-time temperature data. The preprocessed fruit image, barcode scanning event, and real-time temperature data are then transmitted to the cloud database module, quality assurance module, and anti-counterfeiting module. The barcode scanning event includes the latitude and longitude coordinates and timestamp at the time of scanning. The user-side has a built-in decision engine module, which converts the output results of the anti-counterfeiting module and quality assurance module into fruit quality and authenticity determination results and displays them to the user. The cloud database module includes a twin neural network architecture. It retrieves the original fruit image with the same ID as the fruit image from the database storage module and uses the fruit image and the original fruit image as input to the trained twin neural network architecture. These are converted into original feature vectors and barcode feature vectors, respectively. The two sets of feature vectors are then mapped to the same hypersphere embedding space through a linear mapping layer. Within the hypersphere embedding space, feature vectors of the same fruit are close to each other, while feature vectors of different fruits are far apart. The quality assurance module includes a spatiotemporal decay module and a health assessment module. It calls upon data stored in the cloud database module and fruit images transmitted from the user terminal. The spatiotemporal decay module estimates the degree of fruit quality decay based on transportation time, trajectory deviation, and environmental factors, outputs a quality score, and sends the quality score to the user terminal's decision engine. The health assessment module labels each pixel, judges the health level of the fruit skin received by the user terminal by statistically analyzing the labels, outputs a health estimate, and sends the health estimate to the user terminal's decision engine. Anti-counterfeiting module: includes a barcode collision probability module and an identity verification module; The QR code collision probability module outputs a spatiotemporal hard collision marker and a forgery probability based on the scanning event of the QR code ID. The spatiotemporal hard collision marker determines whether the fruit conforms to the physical movement law. The identity verification module compares the similarity of the fruit before and after transportation through the feature vector output by the twin neural network architecture, and outputs the identity confidence score after normalization. The spatiotemporal hard collision marker, forgery probability, and identity confidence score are sent to the decision engine on the user end.
2. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, The twin neural network architecture includes the same two branches, the original image of the fruit. Images of fruits Each input is used as a branch input, and the inputs are processed by an encoder to extract texture features, global average pooling, linear projection mapping to a fixed length, and normalization, respectively, outputting the original feature vectors. and QR code feature vector Furthermore, a linear projection layer is added to map the two feature vectors to the same hypersphere embedding space.
3. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, Separate training sets were constructed for the authentication stream and the health assessment stream. The authentication stream training set included images uploaded by the registration client and the user client, and also included original fruit images. Images of fruits Image-level label pairing is performed to determine whether the images are from the same fruit; the health assessment stream training set mainly includes images uploaded by users, in which the proportion of damaged sample images is not less than a set percentage, and the images are labeled at the pixel level.
4. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 3, characterized in that, The Siamese neural network architecture uses a triplet loss function for training convergence, selecting triples from the authentication stream training set. , , ),in, This represents the registration image uploaded by the registration client; This indicates a positive sample, which is a scanned image of the same fruit uploaded by the user and registered as the sample. This represents a negative sample, which is a scanned image of a fruit uploaded by the user that is different from the registered sample. Triplet Loss: in, This represents the encoding of a twin neural network; Represents the square of the L2 norm; This is a margin parameter for the forced class spacing. ; i is the index of the registered sample in the authentication stream training set, and N is the total number of registered samples in the authentication stream training set.
5. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, The spatiotemporal decay module constructs a quality estimation function based on the Arrhenius equations: in, The initial quality score of the fruit upon leaving the warehouse; For transportation time, , For the scan timestamp, This is the timestamp for when the item was shipped out. This is a function of hourly temperature along the transportation route; Based on the rate of corruption, This is the temperature sensitivity coefficient.
6. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 5, characterized in that, The cloud database module also includes an external data retrieval module; the Haversine spherical distance deviation between the actual transportation path and the planned optimal path is defined as... ; Preset threshold ; when At that time, it was determined that the transportation was within the planned temperature range. Use planned temperature settings; when When the system determines that the transport section has left the temperature-controlled environment, it automatically retrieves the actual surface temperature of the road section from the meteorological data interface using an external data retrieval module, replacing the planned set temperature. .
7. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, The health assessment module takes the input fruit image as input. First, the encoder downsamples to expand the receptive field and extracts multi-scale features of tiny spots and large lesions in layers. After encoding, the image is upsampled step by step in the decoder to restore the image resolution. Each upsampling step introduces a self-attention mechanism to suppress background noise and enhance the response to tiny mold spots and browning areas. The decoder outputs a five-channel probability map, with each channel corresponding to a different label: healthy, moldy, browning, mechanical damage, and occlusion. This five-channel probability map is then converted into a binary damage mask. Post-damage area statistics and visible surface area Damage area The sum of pixels for labels with mold, browning, and mechanical damage, representing the visible surface area. Calculate the damaged area based on the total number of pixels excluding occlusions. Occupying visible surface area The ratio: Health assessment score: .
8. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 7, characterized in that, The health assessment module is trained using a weighted loss function of Dice Loss and Focal Loss, based on the health assessment stream training set. Where X represents the damage region predicted by the network; Y represents the ground truth damage region annotated manually. To prevent smoothing terms from being divided by zero; The Dice Loss value is responsible for fitting the macroscopic shape of the overall contour of the lesion area; For focusing parameters; This represents the model's predicted probability of the true class of this pixel. The category balancing weights take values of (0,1); Focal Loss is used to combat the imbalance of pixel area between different labels within an image; Loss due to dice The weight.
9. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, The QR code conflict probability module uses two consecutive QR code scans by the user as the basis for its calculation. , Input: Spatiotemporal hard collision marker and the probability of forgery ;in and These are the latitude and longitude coordinates of the mobile phone used when scanning the QR code. and These are the timestamps from the two separate scans; Preset physical displacement limit velocity The great circle distance between the two scans is calculated using the Haversine formula. and apparent movement speed ; like Then the spacetime hard conflict marker Probability of forgery ; like Then the spacetime hard conflict marker Count the number of times N is scanned within 24 hours for the unique QR code ID of the fruit, and set a maximum scanning frequency. ;like Probability of forgery ;like Probability of forgery 0.
10. The fruit traceability and anti-counterfeiting system integrating dual-stream deep networks and spatiotemporal behavior verification as described in claim 1, characterized in that, The authentication module compares the original feature vectors. and QR code feature vector The cosine similarity is normalized to output the identity confidence score. , .
