A ship target detection method and system based on patch correlation relationship learning
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SICHUAN WEIBANG XINCHUANG TECH CO LTD
- Filing Date
- 2026-07-13
- Publication Date
- 2026-08-07
AI Technical Summary
[0002]船舶目标检测普遍存在船舶长宽比跨度极大(1:1~20:1)、远距离船舶特征稀疏、海浪反光/云影/码头干扰导致目标边界模糊、船舶易出现局部遮挡等痛点
1.本发明将目标检测任务由传统的端到端边界框回归模式,拆解为Patch分类、关联关系学习、目标组装三个串行阶段,各阶段学习目标单一明确,避免了传统检测器中分类任务与定位任务强耦合导致的优化目标冲突问题,有效提升模型收敛效率与最终检测精度。
Smart Images

Figure CN122530720A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ship target detection technology, and in particular to a ship target detection method and system based on patch association learning. Background Technology
[0002] Ship target detection commonly suffers from several pain points, including a wide range of ship aspect ratios (1:1 to 20:1), sparse features of distant ships, blurred target boundaries due to wave reflections, cloud shadows, and dock interference, and the susceptibility of ships to partial occlusion. Current mainstream ship detection algorithms (YOLO, RT-DETR series) all adopt the paradigm of directly regressing bounding boxes from image features, resulting in strong coupling between classification and localization tasks and high network learning difficulty. Furthermore, these algorithms heavily rely on the complete outline features of the ship; small targets, after multiple downsampling layers, retain only a few feature points, making them highly susceptible to missed detections. Traditional detection frameworks do not model the spatial relationships between local regions such as the bow, hull, and stern of the ship, leading to a significant drop in detection recall when parts of the ship are partially occluded.
[0003] In addition, a small number of medical slides use the Patch processing solution, but ultimately still rely on bounding box prediction; pixel-level affinity algorithms rely on complex spectral clustering operations, which result in high engineering implementation costs and cannot be adapted to maritime irregular-shaped vessel inspection scenarios. Summary of the Invention
[0004] In view of this, this application provides a ship target detection method and system based on patch association learning to address the shortcomings of existing technologies.
[0005] The first aspect of this application provides a ship target detection method based on patch association learning, including: Acquire images of the ship to be inspected, and divide the image into a two-dimensional patch grid according to preset dimensions; Feature vectors are extracted from each patch in the two-dimensional patch grid using a basic visual feature extraction network. The feature vectors of each patch are semantically classified and predicted by the patch classification network to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch. The ship foreground patch set is obtained by filtering according to the preset foreground judgment threshold. The association probability prediction network is used to calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. Using each patch in the ship foreground patch set as a graph node and the association probability between adjacent patches as edge weights, a target connected graph is constructed according to a preset affinity connectivity threshold, and connected components in the target connected graph are extracted, with each connected component corresponding to a candidate ship instance. The foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance are fused to obtain the instance-level confidence. Detection boxes are generated based on the image coverage area corresponding to the patch contained in the connected component, and the ship detection results containing the detection boxes and the corresponding instance-level confidence are output.
[0006] In one possible implementation of the first aspect, the basic visual feature extraction network employs a visual Transformer backbone network.
[0007] In one possible implementation of the first aspect, the semantic classification prediction sets up a total of 6 outputs, including 1 ship foreground category and 5 marine background subcategories; the 5 marine background subcategories correspond to five marine interference areas, namely, waves, reflections, wakes, cloud shadows, and dock structures.
[0008] In one possible implementation of the first aspect, the class probability of a patch is calculated by applying a sigmoid activation function to the classification logits output by the patch classification network; the association probability of adjacent patches is calculated by applying a sigmoid activation function to the affinity logits output by the association prediction network.
[0009] In one possible implementation of the first aspect, the multi-directional adjacency patch is the 8 neighboring patches of the current patch, corresponding to the eight directions of up, down, left, right, upper left, upper right, lower left, and lower right, respectively, and the association probability of each direction is predicted and output independently.
[0010] In one possible implementation of the first aspect, when constructing the target connectivity graph, connectivity edges are established only between adjacent patches that both belong to the ship foreground patch set. When the association probability of adjacent patches is greater than or equal to the preset affinity connectivity threshold, the corresponding connectivity edge takes effect.
[0011] In one possible implementation of the first aspect, when extracting connected components from the target connected graph, a breadth-first search algorithm, a depth-first search algorithm, or a disjoint-set data structure algorithm is used.
[0012] In one possible implementation of the first aspect, the methods for fusing the probabilities of the foreground categories include average fusion, weighted fusion, maximum value fusion, or learning-based fusion.
[0013] In one possible implementation of the first aspect, the detection box is the bounding rectangle, rotated rectangle, minimum bounding box, or convex hull region of the image region corresponding to the connected component.
[0014] A second aspect of this application provides a ship target detection system based on patch association learning, the system comprising: The image input module is used to acquire images of the ship to be inspected and divide the image into a two-dimensional patch grid according to preset dimensions. The feature extraction module is used to extract feature vectors for each patch in the two-dimensional patch grid through a basic visual feature extraction network; The classification prediction module is used to perform semantic classification prediction on the feature vectors of each patch through the patch classification network, to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch, and to obtain the ship foreground patch set by filtering according to the preset foreground judgment threshold. The affinity prediction module is used to predict the network through association relationships and calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. The instance assembly module is used to construct a target connected graph based on a preset affinity connectivity threshold, using each Patch in the ship foreground Patch set as a graph node and the association probability between adjacent Patches as edge weights, and to extract the connected components in the target connected graph, with each connected component corresponding to a candidate ship instance. The result output module is used to fuse the foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance to obtain the instance-level confidence; generate detection boxes according to the image coverage area corresponding to the patch contained in the connected component, and output the ship detection results containing the detection boxes and the corresponding instance-level confidence.
[0015] Its beneficial effects are as follows: 1. This invention breaks down the target detection task from the traditional end-to-end bounding box regression model into three sequential stages: Patch classification, association learning, and target assembly. Each stage has a single and clear learning objective, avoiding the optimization objective conflict problem caused by the strong coupling between classification and localization tasks in traditional detectors, and effectively improving the model convergence efficiency and final detection accuracy.
[0016] 2. In view of the diverse shapes and large length-to-width ratios of ships, this invention generates the detection area by patch assembly. The shape and size of the detection frame are adaptively determined by the actual patch area covered by the target, without the need to force the entire target to be fitted with a fixed rectangular frame. Compared with the detection method of directly regressing the rectangular frame, the adaptability to long and narrow ships and irregularly shaped ships is significantly improved, the background redundancy in the detection frame can be reduced, and the positioning fit is better.
[0017] 3. In complex scenarios such as blurred ocean background boundaries, wave reflections, and wake interference, this invention restores target connectivity by modeling the relationship between patches, and can complete detection without relying on the complete edge information of the target; as long as the local patches of the target are visible and the relationship between the patches is identifiable, the complete target can be restored through spatial connectivity, which significantly reduces the dependence on the complete outline of the target and improves the detection recall rate in weak boundary scenarios.
[0018] 4. To address the issue of feature information loss after multiple downsampling of small-scale ships, this invention performs feature representation at the patch granularity. Each patch independently retains local structural and semantic information, avoiding the annihilation of small target features caused by the downsampling process. Compared with detection methods based on global features, it retains more complete structural information of small-scale targets, resulting in better small target detection recall and localization stability.
[0019] 5. When the target is partially occluded or there is abnormal brightness in a local area, the present invention completes target aggregation based on the spatial correlation between patches and uses the stable spatial constraints between unoccluded patches for target assembly; even if some patch information is missing, the complete target can still be recovered through neighborhood correlation, which effectively reduces the impact of local occlusion and sudden changes in local illumination on the detection results and improves the detection stability in complex scenes.
[0020] 6. Unlike two-stage detection methods that rely on candidate box generation and instance segmentation methods based on pixel-level affinity matrix + spectral clustering, this invention only needs to predict multi-directional pairwise affinity on the patch grid, and the target instance can be extracted through a simple threshold connectivity rule; it does not require complex candidate box screening, spectral clustering and other post-processing operations, has low computational overhead, simple logic, and is easier to implement in engineering and deploy in real time. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0022] Figure 1 This is a flowchart of a ship target detection method based on Patch association learning provided in an embodiment of this application; Figure 2 This is a diagram illustrating the structure of a ship target detection system based on patch association learning, as provided in an embodiment of this application. Detailed Implementation
[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0025] Example 1 This application provides a ship target detection method based on patch association learning, such as... Figure 1 As shown, it includes: Acquire images of the ship to be inspected, and divide the image into a two-dimensional patch grid according to preset dimensions; Feature vectors are extracted from each patch in the two-dimensional patch grid using a basic visual feature extraction network. The feature vectors of each patch are semantically classified and predicted by the patch classification network to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch. The ship foreground patch set is obtained by filtering according to the preset foreground judgment threshold. The association probability prediction network is used to calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. Using each patch in the ship foreground patch set as a graph node and the association probability between adjacent patches as edge weights, a target connected graph is constructed according to a preset affinity connectivity threshold, and connected components in the target connected graph are extracted, with each connected component corresponding to a candidate ship instance. The foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance are fused to obtain the instance-level confidence. Detection boxes are generated based on the image coverage area corresponding to the patch contained in the connected component, and the ship detection results containing the detection boxes and the corresponding instance-level confidence are output.
[0026] This embodiment addresses the four inherent shortcomings of existing ship detection algorithms: strong coupling between classification and localization, reliance on complete contours, loss of small target features, and poor robustness to occlusion. It reconstructs the technical approach from the bottom layer of the detection paradigm, extracting a three-stage detection principle: Patch semantic judgment, spatial association learning, and instance connectivity assembly. The core inventive logic is as follows: Task decoupling principle: The traditional coupled learning mode of detectors, which outputs category and bounding box simultaneously by a single branch, is split into two parallel tasks: "independent classification branch and independent affinity branch". The classification branch is only responsible for determining whether "a local region is a ship" and the affinity branch is only responsible for determining whether "two adjacent patches are the same ship". The two branches have a single learning objective and there is no conflict in the optimization objectives. The network converges faster and has a higher upper limit of accuracy.
[0027] Internal structure modeling principle: Abandoning the traditional algorithm's approach of "relying on the target's outer contour to regress the bounding box," this method instead models the stable spatial relationships between local regions within the target. The bow, hull, and stern of a ship have fixed adjacency relationships. Even if the edges are damaged by waves, reflections, or partially occluded, the relationships between the internal patches remain stable. By explicitly characterizing this internal structure through 8-directional affinity, a complete target can still be reconstructed even when the contour is incomplete.
[0028] The principle of connected component assembly is to transform the discrete patch prediction results into graph structure data and construct a connected graph with "foreground patches as nodes and high-confidence associations as edges". Instance splitting can be completed through simple connected component search without the need for complex operations such as candidate boxes, anchor boxes, and spectral clustering. This ensures both the boundary adaptability at the instance segmentation level and the inference speed at the detection level.
[0029] Fine-grained representation principle: Using a 16-pixel patch as the smallest detection unit, the complete features of the local area are directly preserved, avoiding the annihilation of small target features caused by multiple downsampling in traditional CNNs; even small fishing boats at a distance that only occupy 2 to 3 patches can be completely detected through the correlation of multiple patches, thus alleviating the problem of missed detection of small targets from the root.
[0030] This embodiment is applied to a maritime monitoring scenario. It acquires images of maritime targets using shipborne or shore-based camera equipment, automatically detects and locates ship targets within the images, and provides visual perception support for maritime traffic monitoring, port management, and search and rescue command. The specific steps are as follows: Step 1. Image preprocessing and 2D Patch mesh generation The original maritime images I are acquired from shipborne / shore-based / UAV images. The image size is denoted as H×W×3, where H is the image height and W is the image width. The images are three-channel RGB images.
[0031] The base side length P of the Patch is preset, and the value range of Patch is 8~32 pixels. In this embodiment, P=16 pixels is preferred. Number of grid rows , the number of grid columns In this embodiment, the preprocessed image is 640×640, and it is divided into a 40×40 two-dimensional patch grid. The grid coordinates are as follows: , , each This corresponds to a single local region in the image.
[0032] Choosing 16 pixels as the patch side length is the optimal value that balances the accuracy of small target representation with computational efficiency: if the patch is too large, small targets may not be able to occupy a complete patch, and the features will be diluted by the background; if the patch is too small, the number of grids increases dramatically, and the inference time increases significantly. A 16-pixel patch can ensure that the smallest target occupies at least 1 to 2 complete patches, retaining effective structural features, while the computational load is within the range that embedded devices can handle.
[0033] Step 2. Visual Transformer backbone extracts Patch feature vectors. The Visual Transformer (ViT) is used as the basic visual feature extraction network to extract features from each patch within the grid. Extracting feature vectors The feature vector dimension C has no limit on its range, but in this embodiment, 384 dimensions are preferred. Feature vector It fully carries the local texture, edge, and object feature information of the corresponding Patch area, providing a unified feature input for subsequent classification and affinity prediction.
[0034] The core reason for using the ViT backbone instead of the traditional CNN backbone is that ViT naturally uses patches as input units, and the feature extraction process is naturally compatible with the patch grid division, without the need for additional feature upsampling or alignment operations; at the same time, the self-attention mechanism can capture long-distance dependencies between patches, which is more conducive to the subsequent correlation modeling of the overall ship structure.
[0035] Step 3. Perform multi-class semantic classification of patches and filter the ship foreground patch set. Build an independent patch classification network and input feature vectors. Output the original logits values for each category channel. ; Symbol definition: K is the total number of categories. Example settings It includes 1 type of ship scene and 5 types of marine scene (waves, reflections, wakes, cloud shadows, and dock structures).
[0036] The probability of each class in a single patch is calculated using the sigmoid activation formula (1): In the formula: Patch Belongs to the The probability of a class This is the sigmoid function.
[0037] Set foreground detection threshold The value ranges from 0.3 to 0.7 in this embodiment. ; Only when the probability of the ship's foreground category When this occurs, the patch is determined to be a foreground patch, and all foreground patches constitute a node set V. The selection formula is (2): gather That is, all valid nodes in the subsequent construction of the connected graph are discarded, and the background patch is not included in the subsequent assembly operation.
[0038] The classification setup employs a "1 foreground + 5 fine-grained background" approach, rather than a simple foreground / background binary classification. This is a specific optimization for maritime scenarios: in marine scenes, areas such as waves, reflections, and wakes have high similarity to ship features, making binary classification networks prone to misclassification. By setting typical interference as a separate background subclass, the network can be guided to learn more discriminative features, significantly reducing false detections caused by marine interference. This step only completes local semantic determination and does not involve any boundary coordinate regression, structurally decoupling classification and localization.
[0039] Step 4.8: Predict the affinity of the patch in the direction of adjacency and generate the probability of adjacency association. An independent association prediction network was constructed to predict the 8-neighbor affinity for each patch within the grid. The 8-neighbor orientation index and coordinate offset are shown in the table below: Grid output for each patch Raw logits of affinity in 8 directions The probability of association between adjacent same instances is obtained after sigmoid activation, and the calculation formula is (3): Patch The confidence probability that a patch adjacent to a point in direction d belongs to the same ship; the probabilities of all directions constitute the complete patch association data.
[0040] The use of an 8-neighborhood design instead of a 4-neighborhood design is intended to more accurately model the oblique contours and internal structures of ships. Ships often appear in images at an angle, and a 4-neighborhood design can only capture horizontal and vertical connections, failing to accurately depict oblique boundaries. An 8-neighborhood design covers all adjacent orientations, ensuring that ships in any orientation can form continuous connected regions, avoiding breaks or fragmentations in obliquely oriented ships. The affinity branch and classification branch share core features and have independent prediction heads, reusing feature extraction computational power while ensuring that the learning of the two tasks does not interfere with each other.
[0041] Step 5. Construct the target connectivity graph based on the threshold. Set affinity connectivity threshold The value ranges from 0.3 to 0.7, and this embodiment preferably uses the value from 0.3 to 0.7. ; Only when two adjacent patches both belong to the foreground set V, and their correlation probability is... At that time, a valid connection edge is established between the two Patch nodes; all valid edges constitute the edge set E, and the edge set determination formula is (4): The undirected target connected graph is obtained by combining the foreground node set V and the effective edge set E. .
[0042] The system employs a dual filtering mechanism of "node threshold + edge threshold" to balance instance recall and instance purity: the foreground threshold filters out patches that are likely background data, reducing unnecessary computation; the affinity threshold severs weakly related adjacency pairs, preventing adjacent ships from being incorrectly connected. This dual filtering mechanism ensures target integrity with low false positives and is a core component for achieving accurate instance splitting.
[0043] Step 6. Extract connected components from the connected graph and generate candidate ship instances. On the target connected graph G, choose any one-pass graph structure from breadth-first search (BFS), depth-first search (DFS), and disjoint-set data structure to split it into several disconnected connected components. , m is the instance number; each independent connected component For a candidate ship in the corresponding image, the connected component contains the coordinate set of all foreground patches for that ship.
[0044] The choice of basic connected component algorithms such as BFS / DFS / union-set data structure, rather than complex algorithms such as spectral clustering and graph cut commonly used in instance segmentation, is primarily for lightweight engineering: This solution simplifies the problem to binary connected component extraction on a regular grid through patch-level pre-screening, allowing basic algorithms to achieve extremely high accuracy with a computational cost of less than 1 / 10 of spectral clustering, making it highly suitable for deployment on shipborne edge devices and low-computing-power monitoring terminals.
[0045] Step 7. Perform patch foreground probability fusion within connected components to obtain instance-level confidence. For a single connected component Ship prospect probabilities for all internal patches For fusion computing, the fusion methods are as follows: average fusion, weighted fusion, maximum value fusion, and learning-based fusion. This embodiment uses average fusion, calculated using formula (5): In the formula: The total number of patches included in the connected components. The overall instance confidence score for the m-th ship represents the comprehensive credibility that the target is a real ship.
[0046] Among them, the instance confidence score is obtained by multi-patch probability fusion, which is more stable and reliable than the single-point confidence score of traditional detectors: traditional detectors only rely on the center point or anchor box to output the confidence score, which is easily affected by local noise and will result in high-scoring false detections; this scheme averages the foreground probabilities of all patches within the same target, which is equivalent to multi-region voting, and can effectively suppress local outliers. The confidence score can better reflect the true credibility of the target, and the probability of false deletion or missed deletion is lower when filtering low-scoring targets in the future.
[0047] Step 8. Generate ship detection frames based on connected patch regions. Traversing connected components Get the coordinates of all patches, obtain the image pixel coverage area corresponding to all patches, and call the bounding box function to generate detection boxes. Calculation formula (6): The detection frame can be of the following types: circumscribed rectangle, rotated rectangle, minimum bounding box, or convex hull region; in this embodiment, the circumscribed rectangle is preferred for output.
[0048] The detection box is calculated and generated entirely from the actual patch area occupied by the target, rather than the coordinates being directly regressed by the network. This is one of the core features that distinguishes this solution from all traditional detectors: traditional regression boxes are constrained by the preset ratio of the anchor frame, and have poor adaptability to long ships with extreme aspect ratios; the detection box of this solution is adaptively determined by the actual contour of the target, and is not limited by the preset ratio. It can accurately fit ultra-long cargo ships with an aspect ratio of 1:20 and irregularly shaped ships, and the positioning error is significantly reduced.
[0049] Step 9. Integrate the results and output complete ship inspection information. Coordinates of the detection frame corresponding to each ship Instance confidence The paired output yields the final maritime vessel inspection results, and the output data can be directly used for downstream operations such as port monitoring, maritime search and rescue, and vessel traffic statistics.
[0050] Summary of parameters for each example (all replaceable parameter ranges + preferred positioning): Patch side length: general range 8~32px, optimal implementation value 16px; Preprocessed image size: 1920×1080 or 640×640 are optional; the example uses 640×640. Grid size: Automatically calculated based on the image and patch; a 640 image paired with a (16px) patch uses a 40×40 grid. Feature vector dimension: 384; Category General Category , Example (1 ship + 5 marine interference background); Foreground determination threshold : 0.3~0.7, fixed value 0.5; Affinity Connectivity Threshold : 0.3~0.7, fixed value 0.5; Connected component extraction algorithms: Choose one from BFS (Breadth-First Search), DFS (Depth-First Search), and disjoint-set data structure. Confidence fusion methods: average / weighted / maximum value / learning fusion; Output box type: outer rectangle / rotated rectangle / minimum bounding box / convex hull.
[0051] Example 2 Based on the ship target detection method based on patch association learning provided in Embodiment 1 of this application, correspondingly, Embodiment 2 of this application also provides a ship target detection system based on patch association learning, such as... Figure 2 As shown, the system includes: The image input module is used to acquire images of the ship to be inspected and divide the image into a two-dimensional patch grid according to preset dimensions. The feature extraction module is used to extract feature vectors for each patch in the two-dimensional patch grid through a basic visual feature extraction network; The classification prediction module is used to perform semantic classification prediction on the feature vectors of each patch through the patch classification network, to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch, and to obtain the ship foreground patch set by filtering according to the preset foreground judgment threshold. The affinity prediction module is used to predict the network through association relationships and calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. The instance assembly module is used to construct a target connected graph based on a preset affinity connectivity threshold, using each Patch in the ship foreground Patch set as a graph node and the association probability between adjacent Patches as edge weights, and to extract the connected components in the target connected graph, with each connected component corresponding to a candidate ship instance. The result output module is used to fuse the foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance to obtain the instance-level confidence; generate detection boxes according to the image coverage area corresponding to the patch contained in the connected component, and output the ship detection results containing the detection boxes and the corresponding instance-level confidence.
[0052] In this embodiment, the hardware carrier can be a shore-based server equipped with a GPU or an embedded shipborne edge computing box. The system modularization corresponds to the complete process, and the functions of each module are as follows: Image input module (input layer): As the system data entry point, it supports docking with shipborne camera equipment, shore-based high-definition cameras, UAV aerial photography links, and local image databases. It supports single-frame image and continuous video stream input. It has a built-in image preprocessing unit to complete operations such as resolution scaling, normalization, and channel alignment, and outputs a standardized 640×640 pixel image matrix.
[0053] Feature extraction module (feature layer): The built-in visual Transformer backbone network includes a patch partitioning unit and a feature encoding unit. The patch partitioning unit is responsible for regularly dividing the input image into a 40×40 patch grid, and the feature encoding unit independently encodes each patch, outputting a 384-dimensional feature vector. This module provides a unified feature base for subsequent two-branch prediction, with the two prediction branches sharing the features output here, avoiding the waste of computational power caused by repeated feature extraction.
[0054] Classification prediction module (prediction layer): It incorporates a built-in independent patch classification sub-network. Taking a patch feature vector as input, it outputs 6-class classification logits, which are then used to calculate class probabilities via an activation function. It also includes a built-in foreground filtering unit that filters foreground patches based on a preset foreground judgment threshold to obtain a set of ship foreground patches. This module is only responsible for semantic determination and does not output any boundary coordinate information.
[0055] Affinity prediction module (prediction layer): It incorporates an independent 8-directional affinity prediction sub-network. Taking the patch feature vector as input, it outputs affinity logits in eight neighborhood directions. These logits are then used to calculate the association probability of adjacent patches with the same instance. This module runs in parallel with the classification prediction module, forming a dual-branch structure in the prediction layer, thus decoupling the learning of classification and association tasks.
[0056] Instance assembly module (assembly layer): The system incorporates a graph construction unit and a connected component extraction unit. The graph construction unit receives the foreground patch set and affinity data, and constructs the target connected graph according to a dual-threshold rule. The connected component extraction unit runs a BFS algorithm to traverse the connected graph, decomposes it into independent connected components, and completes the assembly from discrete patches to a complete ship instance. This module is the core computing unit of the system, realizing the mapping from local features to global instances.
[0057] Result output module (output layer): It incorporates a confidence fusion unit and a bounding box generation unit. The confidence fusion unit averages and fuses the foreground probabilities of all patches within the same instance to obtain an instance-level confidence score. The bounding box generation unit calculates and generates bounding boxes based on the coverage area of the instance patch. Finally, it outputs structured detection results in batches, consisting of "bounding box coordinates + instance confidence score," and supports multiple output formats such as standard JSON and XML.
[0058] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computing software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0059] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0060] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A ship target detection method based on patch association learning, characterized in that, include: Acquire images of the ship to be inspected, and divide the image into a two-dimensional patch grid according to preset dimensions; Feature vectors are extracted from each patch in the two-dimensional patch grid using a basic visual feature extraction network. The feature vectors of each patch are semantically classified and predicted by the patch classification network to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch. The ship foreground patch set is obtained by filtering according to the preset foreground judgment threshold. The association probability prediction network is used to calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. Using each patch in the ship foreground patch set as a graph node and the association probability between adjacent patches as edge weights, a target connected graph is constructed according to a preset affinity connectivity threshold, and connected components in the target connected graph are extracted, with each connected component corresponding to a candidate ship instance. The foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance are fused to obtain the instance-level confidence. Detection boxes are generated based on the image coverage area corresponding to the patch contained in the connected component, and the ship detection results containing the detection boxes and the corresponding instance-level confidence are output.
2. The ship target detection method based on patch association learning according to claim 1, characterized in that, The basic visual feature extraction network adopts the visual Transformer backbone network.
3. The ship target detection method based on patch association learning according to claim 1, characterized in that, The semantic classification prediction has a total of 6 output categories, including 1 ship foreground category and 5 marine background subcategories; the 5 marine background subcategories correspond to five marine interference areas, namely waves, reflections, wakes, cloud shadows, and dock structures.
4. The ship target detection method based on patch association learning according to claim 1, characterized in that, The class probability of a patch is calculated by applying the classification logits output by the patch classification network to the sigmoid activation function; the association probability of adjacent patches is calculated by applying the affinity logits output by the association prediction network to the sigmoid activation function.
5. The ship target detection method based on patch association learning according to claim 1, characterized in that, The multi-directional adjacency patch consists of 8 neighboring patches of the current patch, corresponding to the eight directions of up, down, left, right, upper left, upper right, lower left, and lower right, respectively. The association probability of each direction is predicted and output independently.
6. The ship target detection method based on patch association learning according to claim 1, characterized in that, When constructing the target connectivity graph, connectivity edges are established only between adjacent patches that both belong to the ship foreground patch set. When the association probability of adjacent patches is greater than or equal to the preset affinity connectivity threshold, the corresponding connectivity edge takes effect.
7. The ship target detection method based on patch association learning according to claim 1, characterized in that, When extracting connected components from the target connected graph, a breadth-first search algorithm, a depth-first search algorithm, or a disjoint-set data structure algorithm is used.
8. The ship target detection method based on patch association learning according to claim 1, characterized in that, Methods for fusing foreground category probabilities include average fusion, weighted fusion, maximum value fusion, or learning-based fusion.
9. The ship target detection method based on patch association learning according to claim 1, characterized in that, The detection box is the outer rectangle, rotated rectangle, minimum bounding box, or convex hull region of the image region corresponding to the connected component.
10. A ship target detection system based on patch association learning, characterized in that, include: The image input module is used to acquire images of the ship to be inspected and divide the image into a two-dimensional patch grid according to preset dimensions. The feature extraction module is used to extract feature vectors for each patch in the two-dimensional patch grid through a basic visual feature extraction network; The classification prediction module is used to perform semantic classification prediction on the feature vectors of each patch through the patch classification network, to obtain the class probabilities of the ship foreground and multiple backgrounds corresponding to each patch, and to obtain the ship foreground patch set by filtering according to the preset foreground judgment threshold. The affinity prediction module is used to predict the network through association relationships and calculate the association probability that each patch and its multi-directional adjacent patches belong to the same ship instance. The instance assembly module is used to construct a target connected graph based on a preset affinity connectivity threshold, using each Patch in the ship foreground Patch set as a graph node and the association probability between adjacent Patches as edge weights, and to extract the connected components in the target connected graph, with each connected component corresponding to a candidate ship instance. The result output module is used to fuse the foreground class probabilities of all patches within the connected component corresponding to each candidate ship instance to obtain the instance-level confidence; generate detection boxes according to the image coverage area corresponding to the patch contained in the connected component, and output the ship detection results containing the detection boxes and the corresponding instance-level confidence.