Shrimp freshness classification method and system fusing rational mapping and global perception

By combining the CSP-PTB and LSCSBD modules with biochemical indicators, the limitations of visual feature lag and local feature extraction in shrimp freshness detection have been solved, enabling non-destructive and accurate grading and lightweight detection of early quality.

CN122157248APending Publication Date: 2026-06-05SOUTH CHINA SEA FISHERIES RES INST CHINESE ACAD OF FISHERY SCI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTH CHINA SEA FISHERIES RES INST CHINESE ACAD OF FISHERY SCI
Filing Date
2026-03-27
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing shrimp freshness detection technologies suffer from problems such as lag in visual feature mapping, limited local feature extraction, and lack of scale-adaptive calibration for flexible gradient features, making it difficult to accurately and non-destructively detect early quality changes.

Method used

A FreshShrimp-Net model is constructed by combining the CSP-PTB module and the LSCSBD module. The CSP-PTB module embeds some Transformer blocks in the backbone network to extract global context information, while the LSCSBD module introduces a learnable regression scaling factor in the detection head for multi-scale adaptive calibration. The model is constructed by combining total volatile basic nitrogen (TVB-N) and K value as biochemical indicators.

Benefits of technology

It achieves non-destructive and accurate grading of early shrimp quality, breaks through the technical bottlenecks of global feature perception and lightweight deployment, and improves the robustness of locating weak spoilage features and computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122157248A_ABST
    Figure CN122157248A_ABST
Patent Text Reader

Abstract

The application discloses a freshness classification method and system fusing rational mapping and global perception, first, total volatile basic nitrogen (TVB-N) and K value physical and chemical indexes sensitive to early ATP degradation are combined to establish visual feature mapping and construct a shrimp four-grade image dataset; second, a FreshShrimp-Net model is constructed, a CSP-PTB module is used in the high-level semantic stage of the backbone network of the model, global context information is injected in the partial Transformer block with a dynamic token compression mechanism to capture non-local cross-region weak features of early shrimp corruption under the control of calculation overhead; further, the model is optimized in combination with an LSCSBD detection head, a learnable regression scaling factor is used to adaptively adjust and sharpen the flexible gradual corruption features of the shrimp without obvious boundaries; finally, the model is trained by using the dataset to realize global perception and accurate positioning of weak features on the surface of the shrimp to be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary field of computer vision and non-destructive testing of food, specifically involving a freshness classification method and system that integrates physicochemical mapping and global perception. Background Technology

[0002] As a perishable aquatic product with high moisture and protein content, shrimp requires rapid, non-destructive testing for freshness, which is crucial for food safety and quality control. Currently, human sensory evaluation is highly subjective and inconsistent; while traditional laboratory physicochemical analysis, though accurate, is destructive and time-consuming, making it difficult to meet the real-time online testing needs of aquatic product processing lines. In recent years, deep learning methods based on computer vision have provided a new path for non-destructive testing, but their application in shrimp freshness classification still faces significant technical challenges. On the one hand, the characteristics of early-stage shrimp spoilage are extremely subtle, often manifesting as non-local, cross-regional diffusion on the shrimp's surface, which traditional models often struggle to capture. On the other hand, directly introducing conventional global attention mechanisms often leads to a dramatic increase in model computation, making real-time deployment on lightweight industrial edge computing devices impossible.

[0003] Current research attempts to achieve non-destructive detection of shrimp freshness by optimizing conventional object detection architectures. However, these existing methods still suffer from the following insurmountable technical limitations in their underlying logic and practical applications: 1. The biochemical basis of visual feature mapping is lagging, resulting in insufficient accuracy in early freshness classification. Existing visual detection methods mostly rely on mid-to-late-stage spoilage indicators such as total colony count (TVC) or apparent melanin (grayscale value) as classification criteria. These indicators cannot sensitively reflect the core biochemical process of ATP degradation in the early post-mortem shrimp, leading to a lack of solid physical support for the model when distinguishing between early quality changes such as "first-level freshness" and "second-level freshness." 2. Feature extraction is limited by local cognition and lacks global context modeling capabilities. The conventional convolution operations used in existing models are essentially local operators within the local receptive field, unable to effectively construct long-range dependencies between features. When faced with weak, global color and texture changes on the shrimp surface in the early stages of spoilage, it is easy to miss or misjudge. 3. Multi-scale detection heads lack scale-adaptive calibration for flexible, gradual features. Most existing improved models follow the traditional detection head structure, using a large number of independent convolutions at different scale levels. This not only results in a bloated number of parameters but also fails to adaptively calibrate for the differences in feature distribution at different scales. Furthermore, although some lightweight shared convolutional architectures have emerged in the field of general computer vision object detection, the rigid physical boundaries of conventional visual detection targets, compared to the soft, gradual changes in melanin spread during the early stages of shrimp decay, make it easy for these general-purpose detection heads to be over-smoothed or lost in the shared convolutions. This significantly reduces generalization ability and robustness.

[0004] Therefore, there is an urgent need to develop a novel underlying detection network architecture to overcome the bottlenecks of existing shrimp freshness detection technologies. Specifically, this architecture not only needs to break the local limitations of traditional convolution and explore a new feature extraction mechanism that can inject global contextual information while controlling computational overhead, but also needs to coordinate with lightweight multi-scale adaptive parsing suitable for "flexible gradient features" and rely on sensitivity to early biochemical and physicochemical indicators to truly meet the non-destructive testing requirements in high-value aquatic product processing. Summary of the Invention

[0005] To address the problems existing in the prior art, this invention provides a method and system for classifying shrimp freshness by integrating physicochemical mapping and global perception.

[0006] To achieve the above objectives, the present invention provides the following solution: A method for classifying shrimp freshness by integrating physicochemical mapping and global perception includes: Step S1: Collect shrimp image dataset; specifically including: collecting shrimp sample images and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N, establishing a mapping relationship between visual features and shrimp freshness grades; based on the mapping relationship, constructing a shrimp image dataset containing four grades: "Grade 1 Freshness", "Grade 2 Freshness", "Grade 3 Freshness", and "Inedible". Step S2: Construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, a CSP-PTB module is used to replace the original feature extraction module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage. Step S3: Train the FreshShrimp-Net model based on the shrimp image dataset; Step S4: Input the shrimp image to be processed into the trained FreshShrimp-Net model to classify the freshness level of the shrimp. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of the shrimp.

[0007] Preferably, the FreshShrimp-Net model further includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction. The CSP-PTB module works in conjunction with the LSCSBD module to achieve accurate localization of weak spoilage features on the surface of shrimp.

[0008] Preferably, the processing procedure of the CSP-PTB module includes: dividing the input feature map into two branches along the channel dimension, one branch serving as a direct path that preserves local gradients and original spatial details; the other branch being processed sequentially through multiple serial PTBs; within each PTB, only the key and value are spatially downsampled to achieve token compression, while the query remains in its entirety; wherein, the token compression ratio of the PTB is set to 0.25 in stage P4 and 0.5 in stage P5.

[0009] This invention also provides a shrimp freshness classification system that integrates physicochemical mapping and global perception, comprising: The first processing module is used to collect shrimp image datasets. Specifically, it includes: collecting shrimp sample images and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N to establish a mapping relationship between visual features and shrimp freshness grades; and constructing a shrimp image dataset containing four grades: "Grade 1 Freshness", "Grade 2 Freshness", "Grade 3 Freshness", and "Inedible" based on the mapping relationship. The second processing module is used to construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, the original feature extraction module is replaced by a CSP-PTB module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage. The third processing module is used to train the FreshShrimp-Net model based on the shrimp image dataset; The fourth processing module is used to input the shrimp images to be processed into the trained FreshShrimp-Net model for shrimp freshness grade classification. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of shrimp.

[0010] Preferably, the FreshShrimp-Net model further includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction.

[0011] Preferably, the processing procedure of the CSP-PTB module in the second processing module includes: dividing the input feature map into two branches along the channel dimension, one branch serving as a direct path that preserves local gradients and original spatial details; the other branch being processed sequentially through multiple serial PTBs; within each PTB, only the key and value are spatially downsampled to achieve token compression, while the query remains in its entirety; wherein, the token compression ratio of the PTB is set to 0.25 in stage P4 and to 0.5 in stage P5.

[0012] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention innovatively proposes a novel lightweight shrimp freshness feature extraction and classification network. By deeply integrating the underlying algorithm architecture with the physical and biochemical characteristics of aquatic products, it achieves the following significant technological advancements: 1. This invention strengthens the underlying biochemical foundation of visual mapping, enabling non-destructive and precise grading of shrimp quality in the early stages. Addressing the limitations of existing visual detection methods that overly rely on "lagging" indicators such as TVC (colony count) or apparent melanin, this invention combines total volatile basic nitrogen (TVB-N) with the K value, which is highly sensitive to early post-mortem ATP degradation. Utilizing these two core physicochemical indicators as the foundation for visual feature mapping provides FreshShrimp-Net with physicochemical support, enabling the model to capture and distinguish the microscopic evolution of "primary freshness" and "secondary freshness" earlier and more sensitively than existing methods, highly meeting the non-destructive control requirements in high-value-added aquatic product processing.

[0013] 2. Overcoming the limitations of local feature recognition, this invention achieves global perception of weak, non-local, cross-regional features with extremely low computational overhead. Addressing the limitation of existing conventional convolutional and other local operators in capturing the cross-regional spread features in the early stages of shrimp spoilage, this invention innovatively designs a CSP-PTB module in the backbone network. This module retains the local gradient paths of the CSP structure to maintain the physical geometry of the shrimp's outline while serially embedding partial Transformer blocks (PTBs) with a dynamic token compression mechanism. This design not only overcomes the bottleneck of long-range dependency modeling but also effectively solves the deployment problem of the dramatically increased computational cost of the global attention mechanism by performing specific spatial downsampling on only the Key and Value (compression ratios set to 0.25 / 0.5 in stages P4 and P5, respectively).

[0014] 3. Perfectly adapts to the "soft edge" characteristics of shrimp targets, significantly improving the robustness of localization of flexible gradient features. The preferred embodiment of this invention introduces a cross-scale shared representation and independent calibration collaborative LSCSBD mechanism in the detection head. This invention does not simply adopt conventional lightweight detection heads, but fully utilizes the learnable regression scaling factor configured for them, thereby enabling dynamic calibration of discrete distance distribution and specifically adaptively adjusting the gradient intensity of the shrimp's "flexible gradient decay features without obvious boundaries." This not only significantly compresses the model size but also effectively prevents weak gradient features from being smoothed out in shared convolutions, greatly improving robustness in real industrial production line scenarios such as complex lighting and stacked occlusion. Attached Figure Description

[0015] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a flowchart of the shrimp freshness classification method according to an embodiment of the present invention; Figure 2 This is a structural diagram of the FreshShrimp-Net model. Detailed Implementation

[0017] 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 skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0019] Example 1 like Figure 1 As shown, the present invention provides a method for classifying the freshness of shrimp, including: Step S1: Collect shrimp image dataset; specifically including: collecting shrimp sample images and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N, establishing a mapping relationship between visual features and shrimp freshness grades; based on the mapping relationship, constructing a shrimp image dataset containing four grades: "Grade 1 Freshness", "Grade 2 Freshness", "Grade 3 Freshness" and "Inedible".

[0020] Step S2: Construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, a CSP-PTB module is used to replace the original feature extraction module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage.

[0021] Step S3: Train the FreshShrimp-Net model based on the shrimp image dataset.

[0022] Step S4: Input the shrimp image to be processed into the trained FreshShrimp-Net model to classify the freshness level of the shrimp. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of the shrimp.

[0023] In a preferred embodiment of the present invention, the FreshShrimp-Net model further includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction.

[0024] Basic object detection networks typically consist of three parts: a backbone network, a neck network, and a detection head. The FreshShrimp-Net model of this invention introduces two key original improvements in the backbone and detection head parts, such as... Figure 2 As shown.

[0025] The FreshShrimp-Net model construction process is as follows: (1) Input preprocessing: Acquire 640×640 RGB images I ∈R 640×640×3 , representing a single or stacked shrimp sample; (2) Backbone feature extraction: The original feature module is replaced by CSP-PTB, and global attention is injected in stages P4 (stride=16) and P5 (stride=32); (3) Feature fusion: PAN-FPN fuses P3–P5 multi-scale features and outputs {F 3, F4,F5}; (4) Freshness target detection: The LSCSBD detection head predicts bounding boxes B for each layer of features. l And freshness, etc. l ∈{First, Second, Third, inedible}; (5) Post-processing: Non-maximum suppression (NMS) is used to merge overlapping predictions and output the final detection result set. .

[0026] The CSP-PTB module works as follows: To enhance the model's global perception of subtle spoilage features on the surface of shrimp, this embodiment of the invention introduces a CSP-PTB module in the high-level semantic stages (P4 and P5) of the backbone network. This module, while preserving the stability of the CSP structural gradient path, embeds serially stacked Transformer blocks (PTBs) to inject non-local contextual information with controllable computational overhead.

[0027] Specifically, the input feature map is first compressed to 2c dimensions (c is half the number of output channels) via a 1×1 convolution, achieving the best balance between efficiency and information preservation. It is then divided into two branches along the channel dimension: one branch (Z0) serves as a direct path, ensuring stable propagation of local features and the original gradient; the other branch (Z1) processes n PTB sub-blocks sequentially (n=6 in stage P4, n=3 in stage P5). Each PTB employs a token compression strategy—only 25% (P4) or 50% (P5) of the spatial location is selected for calculating the Key and Value, while the Query remains fully processed, thus reducing the computational complexity of self-attention from O(N²) to approximately O(rN²). All branch outputs are finally concatenated along the channels and aggregated back to the target number of channels via a 1×1 convolution. This design decouples local stability from global semantic modeling.

[0028] The design motivation stems from the fact that shrimp spoilage often exhibits a non-local diffusion pattern (such as spreading from the tail to the head), and traditional local convolution is difficult to model such long-range dependencies.

[0029] Structure and Data Flow: Given input features X∈R B×Cin×H×W (Corresponding to P4 or P5), CSP-PTB performs the following operations: 1. Channel Compression and Splitting (CSP Splitting): Z=Conv 1×1 (X)∈R B×2c×H×W [Z0,Z1]=chunk(Z,2,dim=1).

[0030] Where c = ⌊ e ⋅Cout⌋, e =0.5, C out The number of output channels for the module is (P4: 512, P5: 1024). Z 0 is used as a local gradient fast path to preserve the original spatial details (shrimp edge sharpness); Z1 enters the PTB serial processing.

[0031] 2. PTB serial processing (global context injection): Let T0 = Z 1. For i =1,…, n (P4:) n =6, P5: n =3):T i =PTB(T i−1 ; r ),T i ∈R B×c×H×W .

[0032] The PTB internal execution part of self-attention: will Ti−1 Flattened into a token sequence X′∈R B×N×c (N=H⋅W), token compression is performed only on the Key and Value: Compression ratio rr is dynamically set according to resolution (P4: r =0.25, P5: r =0.5), to balance computational overhead and information integrity. Attention output is: Finally, T is obtained by connecting FFN with the residual. i .

[0033] 3. Channel aggregation: U=concat(Z0,Z1,T1,…,T) n )∈R B×(2+n)c×H×W Y = Conv 1×1 (U)∈R B×C out ×H×W Among them, Z0 preserves the local geometry of the shrimp (such as the complete outline) to prevent excessive smoothing by attention; Ti gradually injects global spoilage semantics (such as "if the tail turns black, the freshness of the whole shrimp decreases"); low r value ensures fine modeling in the high-resolution region of the shrimp (P4), and high r value efficiently aggregates semantics at the layer (P5).

[0034] The LSCSBD module works as follows: LSCSBD is a detection head structure that balances parametric efficiency with the ability to adaptively represent multi-scale features. For example... Figure 2 As shown, its core ideas include three points: (i) sharing two 3×3 convolutional kernels across the three detection scales of P3, P4 and P5 to enhance the general expressive power of cross-scale features; (ii) configuring independent batch normalization (BN) layers for each scale; and (iii) introducing a learnable layer-by-layer scaling factor (Scale) in the regression branch, and performing dynamic amplitude calibration on the logits output by DFL.

[0035] For the first Layer features ( The calculation logic is as follows: 1. Channel alignment (not shared): 2. Shared convolution stack (shared weights): in Shared between P3 / P4 / P5, but Independent to adapt to statistical characteristics at different scales (e.g., P3 contains high-frequency textures, P5 contains low-frequency semantics).

[0036] 3. Predicted output: Regression Branch (DFL): ,in A learnable scaling factor; Classification branches: .

[0037] 4. Freshness Decoding: For each predicted location, DFL outputs a four-directional discrete distribution. ( The expected distance is: Physical scale distance is Ultimately decoded into bounding boxes .

[0038] Explanation of the principle behind the LSCSBD module's specific adaptation to "flexible gradient features": The FreshShrimp-Net model proposed in this invention fully incorporates the physical evolution patterns of aquatic products in its detection head design. Melanin deposition and tissue softening caused by shrimp spoilage often appear visually as "soft, gradual edges without clear boundaries." Conventional multi-scale shared convolutions are prone to over-smoothing or losing feature distributions when processing such subtle gradual changes. This invention creatively introduces a learnable regression scaling factor into the LSCSBD module, enabling dynamic calibration of the discrete distance distribution, thereby adaptively adjusting and sharpening the gradient intensity of the soft, gradual spoilage features of shrimp. This mechanism significantly compresses the number of model parameters while overcoming the technical bottleneck of accurately locating subtle gradual changes in aquatic products, achieving excellent non-destructive detection results.

[0039] As one embodiment of the present invention, the parameters for training the FreshShrimp-Net model in step S3 are shown in Table 1: Table 1 This invention proposes an intelligent classification method for shrimp freshness grades based on the FreshShrimp-Net architecture. By constructing a high-fidelity RGB image acquisition system and innovatively combining TVB-N with key physicochemical indicators such as the K value, which is sensitive to early ATP degradation, a reliable mapping relationship between visual representation and freshness grade is established. Based on this, a uniquely designed PTB feature extraction mechanism and a lightweight LSCSBD detection head work synergistically to effectively overcome the technical barriers between insufficient perception of early subtle changes on the shrimp surface and lightweight deployment in industrial settings.

[0040] Example 2 This invention also provides a shrimp freshness classification system that integrates physicochemical mapping and global perception, comprising: The first processing module is used to collect shrimp image datasets. Specifically, it includes: collecting shrimp sample images and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N to establish a mapping relationship between visual features and shrimp freshness grades; and constructing a shrimp image dataset containing four grades: "Grade 1 Freshness", "Grade 2 Freshness", "Grade 3 Freshness", and "Inedible" based on the mapping relationship. The second processing module is used to construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, the original feature extraction module is replaced by a CSP-PTB module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage. The third processing module is used to train the FreshShrimp-Net model based on the shrimp image dataset; The fourth processing module is used to input the shrimp images to be processed into the trained FreshShrimp-Net model for shrimp freshness grade classification. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of shrimp.

[0041] In a preferred embodiment of the present invention, the FreshShrimp-Net model further includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction.

[0042] As one embodiment of the present invention, the processing procedure of the CSP-PTB module in the second processing module includes: The input feature map is divided into two branches along the channel dimension, with one branch serving as a direct path that preserves local gradients and original spatial details. Another branch is processed sequentially through multiple serial PTBs; within each PTB, only the key and value are spatially downsampled to achieve token compression, while the query remains in its full form; Specifically, the token compression ratio of the PTB is set to 0.25 in stage P4 and 0.5 in stage P5.

[0043] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for classifying shrimp freshness by integrating physicochemical mapping and global perception, characterized in that, include: Step S1: Collect shrimp image dataset; Specifically, this includes: collecting images of shrimp samples and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N to establish a mapping relationship between visual features and shrimp freshness grades; and constructing a shrimp image dataset containing four grades: "Grade 1 Freshness," "Grade 2 Freshness," "Grade 3 Freshness," and "Inedible" based on the mapping relationship. Step S2: Construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, a CSP-PTB module is used to replace the original feature extraction module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage. Step S3: Train the FreshShrimp-Net model based on the shrimp image dataset; Step S4: Input the shrimp image to be processed into the trained FreshShrimp-Net model to classify the freshness level of the shrimp. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of the shrimp.

2. The shrimp freshness classification method integrating physicochemical mapping and global perception as described in claim 1, characterized in that, The FreshShrimp-Net model also includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction. The CSP-PTB module works in conjunction with the LSCSBD module to achieve accurate localization of weak spoilage features on the surface of shrimp.

3. The shrimp freshness classification method integrating physicochemical mapping and global perception as described in claim 1 or 2, characterized in that, The processing procedure of the CSP-PTB module includes: The input feature map is divided into two branches along the channel dimension, with one branch serving as a direct path that preserves local gradients and original spatial details. Another branch is processed sequentially through multiple serial PTBs; within each PTB, only the key and value are spatially downsampled to achieve token compression, while the query remains in full. Specifically, the token compression ratio of the PTB is set to 0.25 in stage P4 and 0.5 in stage P5.

4. A shrimp freshness classification system integrating physicochemical mapping and global perception, characterized in that, include: The first processing module is used to collect shrimp image datasets. Specifically, it includes: collecting shrimp sample images and simultaneously acquiring the total volatile basic nitrogen (TVB-N) and K value physicochemical indicators of the corresponding samples; using the early ATP degradation characteristics reflected by the K value and the physicochemical changes reflected by TVB-N to establish a mapping relationship between visual features and shrimp freshness grades; and constructing a shrimp image dataset containing four grades: "Grade 1 Freshness", "Grade 2 Freshness", "Grade 3 Freshness" and "Inedible" based on the mapping relationship. The second processing module is used to construct a FreshShrimp-Net model, which includes a backbone network. In the high-level semantic stages P4 / P5 of the backbone network, the original feature extraction module is replaced by a CSP-PTB module. The CSP-PTB module retains the local gradient path of the CSP structure and embeds multiple partial Transformer blocks (PTBs) serially. Each PTB uses a token compression mechanism, and the compression ratio is dynamically adjusted according to the feature map resolution to inject global contextual information while controlling computational overhead, thereby capturing the non-local cross-regional weak features of early shrimp spoilage. The third processing module is used to train the FreshShrimp-Net model based on the shrimp image dataset; The fourth processing module is used to input the shrimp images to be processed into the trained FreshShrimp-Net model for shrimp freshness grade classification. The CSP-PTB module realizes global perception and localization of weak spoilage features on the surface of shrimp.

5. The shrimp freshness classification system integrating physicochemical mapping and global perception as described in claim 4, characterized in that, The FreshShrimp-Net model also includes a detection head, in which an LSCSBD module is set. The LSCSBD module shares 3×3 convolution weights across the three feature scales P3-P5 to compress the number of parameters, while configuring independent batch normalization layers and learnable regression scaling factors for each scale. The learnable regression scaling factor is used to dynamically calibrate the discrete distance distribution of the Distributed Focal Loss (DFL) output to adaptively adjust the gradient intensity of the flexible, gradual spoilage features of shrimp without obvious boundaries, adapting to the statistical distribution differences of shrimp feature maps at different scales to achieve multi-scale prediction.

6. The shrimp freshness classification system integrating physicochemical mapping and global perception as described in claim 4 or 5, characterized in that, The processing procedure of the CSP-PTB module in the second processing module includes: The input feature map is divided into two branches along the channel dimension, with one branch serving as a direct path that preserves local gradients and original spatial details. Another branch is processed sequentially through multiple serial PTBs; within each PTB, only the key and value are spatially downsampled to achieve token compression, while the query remains in full. Specifically, the token compression ratio of the PTB is set to 0.25 in stage P4 and 0.5 in stage P5.