An artificial intelligence-based automatic identification method and system for a canal system

By introducing a self-attention mechanism to calculate long-distance dependencies between image patches, the problems of missed identification and limited field of view in canal system recognition are solved, thereby improving the accuracy and completeness of canal system recognition.

CN120673263BActive Publication Date: 2025-11-18TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511153848.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-18
Publication Date
2025-11-18
Estimated Expiration
2045-08-18

AI Technical Summary

Technical Problem

Existing technologies for canal identification suffer from omissions and limited field of view, especially when the canal system is long. Omissions are likely to occur at the connection points between different segments during segmented identification. Traditional convolutional neural networks also suffer from limited field of view due to the limited size of the convolution kernel.

Method used

A self-attention mechanism is introduced. By setting multiple independent attention heads, long-distance dependencies between image patches are calculated to generate a query matrix Q, a key matrix K, and a value matrix V. The original similarity score is calculated, and attention weights are determined based on directional weights. The value features of image patches are re-weighted and aggregated to generate a global feature vector. Finally, the channel system is identified through feature fusion.

Benefits of technology

It effectively solves the problem of missed identification in canal system recognition, improves the accuracy and completeness of canal system recognition, captures long-distance dependencies between image blocks, and enhances the accuracy of recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673263B_ABST
    Figure CN120673263B_ABST
Patent Text Reader

Abstract

The application provides a kind of based on artificial intelligence's automatic identification method and system of system, specifically includes: setting H independent attention head, each head will the local feature vector of image block respectively through linear transformation generate query matrix Q, key matrix K, value matrix V;Based on the query matrix Q and key matrix K, calculate the original correlation of a adjacent image block to target image block, recorded as original similarity score;The original similarity score is multiplied with directional weight matrix element by element, based on the multiplication result determines the attention weight of each adjacent image block to target image block, the directionality weight is determined based on the correlation of adjacent image block and channel direction;According to the attention weight, the value feature of each image block in value matrix V is reweighted aggregation, generate the global feature vector of enhanced target image block;The global feature vector of the target image block is fused with the local feature vector, to identify system according to the feature after fusion.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of artificial intelligence, in particular to a method and system for automatic identification of a canal system based on artificial intelligence, and an electronic device and a non-transitory computer-readable storage medium. BACKGROUND

[0002] With the continuous progress of aerospace technology and unmanned aerial vehicle technology, unmanned aerial vehicle remote sensing technology has become an effective means to obtain high-resolution and high-precision ground surface information. In precision agriculture, by identifying the canal system from remote sensing images, the distribution of farmland irrigation canals can be understood in detail. In newly constructed farmland water conservancy projects, such as canal lining engineering, the use of remote sensing image identification and comparison technology can monitor the progress of engineering construction in real time. For water conservancy facilities that have already been built, canal system identification is also helpful for protection and supervision. In the management of water resources in a watershed, the canal system is a key link in the allocation of water resources. By identifying the various levels of canals in the watershed from remote sensing images, a detailed water system network model can be constructed, so canal system identification is very important in agriculture and water conservancy.

[0003] Currently, satellite remote sensing images and unmanned aerial vehicle remote sensing images are mainly used for canal system identification.

[0004] Using satellite remote sensing images for canal system identification has the advantages of wide coverage and fast data acquisition. By interpreting satellite remote sensing images, the distribution information of field canal systems can be extracted. The current identification methods use the strong absorption of water bodies in the near-infrared band spectrum and other spectral characteristics to identify water canals. For dark canals and other canals with little or no water, supervised classification, self-organizing classification, support vector machines, and object-oriented methods are used to extract features such as geometry and spatial relationships.

[0005] Unmanned aerial vehicle remote sensing systems have the advantages of convenient transportation, high flexibility, short operation period, and high-resolution image data, and can obtain higher-resolution remote sensing images, which are more conducive to the identification and extraction of canals. The current method for extracting canals from unmanned aerial vehicle orthophotos in irrigation areas based on a fully convolutional neural network uses an FCN model to extract canal outlines to quickly obtain distribution information of canals in irrigation areas. High-precision orthophotos, elevation, and slope data collected by unmanned aerial vehicles can also be combined to implement overall extraction of canal networks in irrigation areas using improved Hough transform. Both of the above methods have the problem of missing identification at the connection between different segments when identifying long canals in segments. In addition, traditional convolutional neural networks (CNN) have a limited field of view due to the limited size of the convolution kernel. SUMMARY

[0006] The application provides a channel automatic identification method and system based on artificial intelligence, and an electronic device and a non-transitory computer readable storage medium, to solve the technical problems of missing identification at different segment connections in the prior art and limited field of view caused by limited convolution kernel size of a traditional convolutional neural network.

[0007] The channel automatic identification method based on artificial intelligence comprises:

[0008] H independent attention heads are set, and each head generates a query matrix Q, a key matrix K and a value matrix V through linear transformation of the local feature vector of an image block;

[0009] Based on the query matrix Q and the key matrix K, the original correlation of an adjacent image block to the target image block is calculated, and the original similarity score is recorded;

[0010] The original similarity score is multiplied element by element with a directional weight matrix, and the attention weight of each adjacent image block to the target image block is determined based on the multiplication result, and the directionality weight is determined based on the correlation between the adjacent image block and the channel direction;

[0011] The value features of each image block in the value matrix V are reweighted and aggregated according to the attention weight, and a global feature vector of the enhanced target image block is generated;

[0012] The global feature vector of the target image block is fused with the local feature vector, so as to identify the channel system according to the fused features.

[0013] Optionally, before the local feature vector of the image block is generated into the query matrix Q, the key matrix K and the value matrix V through linear transformation, the method comprises:

[0014] A position encoding matrix corresponding to the spatial size of the image data is constructed, and each position in the position encoding matrix stores a trainable position vector, and the position vector represents the absolute position information of the image block in the overall structure of the channel system;

[0015] The coordinates of each image block of the input image are mapped into the position encoding matrix, and the corresponding position vector P is extracted;

[0016] The position vector P and the local feature vector F of the image block are added element by element to obtain the fused local feature vector F'=F+P.

[0017] Optionally, before the local feature vector of the image block is generated into the query matrix Q, the key matrix K and the value matrix V through linear transformation by each head, the method further comprises:

[0018] The image data of the region to be identified is downloaded;

[0019] The image data is divided into rectangles of a predetermined size, each rectangle corresponding to an image block.

[0020] Optionally, the attention weight is determined by the following formula:

[0021]

[0022] wherein QK T is an original similarity score, denotes element-wise multiplication, and W is a directional weight matrix, denotes the dimensions of K and Q.

[0023] Optionally, the value features of each image block in the value matrix V are reweighted and aggregated according to the attention weight to generate a global feature vector of the enhanced target image block, including:

[0024] The value features of each image block are reweighted and aggregated to generate a global perception feature of the target image block, i.e., the enhanced attention feature of the i-th block , wherein V j is the value vector of the j-th block, j is the j-th row in the value matrix V, and the value matrix V has a total of N rows of data.

[0025] Optionally, the original local feature F is fused with the enhanced attention feature matrix to retain local details while introducing global information, the attention feature matrix being a matrix composed of all .

[0026] Optionally, the algorithm for fusing the original local feature F with the enhanced attention feature matrix is as follows:

[0027] wherein LayerNorm is a normalization layer, A is the enhanced global feature of attention, i.e., a matrix composed of all , is a learnable adjustment factor for adjusting the contribution to the global feature.

[0028] The application also provides a pipeline automatic identification system based on artificial intelligence, which comprises:

[0029] a linear transformation module for setting H independent attention heads, each head generating a query matrix Q, a key matrix K, and a value matrix V through linear transformation of the local feature vector of an image block, respectively;

[0030] an original correlation calculation module for calculating an original correlation of an adjacent image block to a target image block based on the query matrix Q and the key matrix K, denoted as an original similarity score;

[0031] The attention weight determination module is configured to multiply the original similarity score with a directionality weight matrix element by element, and determine an attention weight of each adjacent image block to the target image block based on a multiplication result, wherein the directionality weight is determined based on a correlation between the adjacent image block and a channel direction.

[0032] The attention weighted aggregation module is configured to re-weight and aggregate value features of each image block in the value matrix V according to the attention weight, and generate a global feature vector of the enhanced target image block.

[0033] The hierarchical feature fusion module is configured to fuse the global feature vector of the target image block with the local feature vector, so as to identify the channel system according to the fused features.

[0034] As a preferred embodiment, the system further comprises a position encoding matrix construction module configured to construct a position encoding matrix corresponding to a spatial size of the image data, wherein each position in the position encoding matrix stores a trainable position vector, and the position vector represents absolute position information of the image block in the overall structure of the channel system; an image block coordinate mapping module configured to map coordinates of each image block of the input image to the position encoding matrix, and extract a corresponding position vector P; and a local feature vector fusion module configured to add the position vector P and the local feature vector F of the image block element by element, to obtain a fused local feature vector F′=F+P.

[0035] As a preferred embodiment, the system further comprises a vector data downloading module configured to download image data of a region to be identified; and an image block segmentation module configured to segment the water system vector data into rectangles of a predetermined size, and each rectangle corresponds to an image block.

[0036] As a preferred embodiment, the attention weighted aggregation module re-weights and aggregates the value features of each image block according to the attention weight, to generate a global perception feature of the target image block, i.e., an enhanced attention feature of the i-th block , wherein V j is a value vector of the j-th block, j is the j-th row in the value matrix V, and the value matrix V has a total of N rows of data.

[0037] The attention weighted aggregation module fuses the original local feature F and an enhanced attention feature matrix to retain local details while introducing global information, wherein the attention feature matrix is a matrix composed of all .

[0038] The application provides an electronic device, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the above-mentioned artificial intelligence-based automatic identification method of a channel system when executing the program.

[0039] The application provides a non-transitory computer-readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement the above-mentioned artificial intelligence-based automatic identification method of a channel system.

[0040] The application provides an automatic identification method of a channel system, which introduces a self-attention mechanism to capture long-distance dependence between image blocks, thereby solving the missing identification phenomenon that occurs at the connection between different segments during segment identification due to a long channel. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.

[0042] Figure 1a is a process schematic diagram of constructing a channel system training database in the application.

[0043] Figure 1b is an example diagram of a vector diagram of channel image data collected in the process of constructing a channel system training database in the application.

[0044] Figure 1c is an example diagram of a segmented channel satellite image in the process of constructing a channel system training database in the application.

[0045] Figure 1d is an example diagram of a segmented channel satellite image after software labeling in the process of constructing a channel system training database in the application.

[0046] Figure 2 is a common architecture schematic diagram of selecting a model when using a convolutional neural network for target detection in the application.

[0047] Figure 3 is a flow schematic diagram of the artificial intelligence-based automatic identification method of a channel system provided by the application.

[0048] Figure 4 is a structural schematic diagram of the electronic device provided by the application. DETAILED DESCRIPTION

[0049] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below in combination with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the protection scope of the present application.

[0050] In order to train the channel recognition model and select the optimal channel recognition model, a channel training database needs to be constructed. As shown in Figure 1a , the process of constructing the channel training database includes:

[0051] Step 101, collecting channel image data from satellite remote sensing images or unmanned aerial vehicle remote sensing images; the vector diagram of the channel image data in this step is shown in Figure 1b ;

[0052] Step 102, equally dividing the channel image data to obtain each segment of channel image; the example of the segmented channel satellite image diagram in this step is shown in Figure 1c ;

[0053] Step 103, establishing the corresponding label data of each image; in this step, the software marking after the software marking is preferably marked, and the example of the image after the software marking is shown in Figure 1d ;

[0054] Step 104, constructing a channel training database based on the image and its corresponding label data, and dividing the image and its corresponding label data into a training set and a validation set in the training database.

[0055] On the basis of constructing the above-mentioned training database, a convolutional neural network model as a channel recognition model can be trained and its performance can be evaluated.

[0056] As shown in Figure 2 , this figure shows a common architecture for selecting a model when using a convolutional neural network for object detection. Among them, the backbone network (Backbone) is an initial convolutional neural network used to extract feature maps from input images, including C3, C4 and C5 layers, representing different stages of the backbone, and the spatial resolution of the input image is 800 1024. The feature map sizes output by C3, C4 and C5 are 100 128, 50 64 and 25 32 respectively. The backbone network gradually reduces the resolution of the input image to extract features of different scales. A feature pyramid (FPN) is constructed from the feature maps of the backbone network, which helps to detect objects of different scales. In the appendix Figure 3In the example in FIG. 4, P3, P4, P5, P6, and P7 feature maps are constructed. From bottom to top: the backbone (C3, C4, C5) generates feature maps; from top to bottom: the network starts from the coarsest feature map (C5) and upsamples. Then, lateral connections are established from the finer feature maps (C4, C3) of the backbone. These connections involve merging the upsampled feature maps with the corresponding feature maps of the backbone. This enables the network to combine high-level semantic information (from the coarser layers) with fine-grained spatial information (from the finer layers). The feature map sizes output by P3, P4, P5, P6, and P7 are 100 128, 50 64, 25 32, 13 16 and 7 8.

[0057] The FPN generates feature maps at multiple scales. Each layer of the pyramid (P3, P4, P5, P6, P7) is input into a “head”. The head is responsible for making predictions. Importantly, “shared heads” means that the same head architecture is used for each feature level, which reduces the number of parameters and helps the model generalize across different scales.

[0058] Each head has three branches, namely Classification, Regression, and Center-ness. The Classification is used to predict the class of the object, and the output is H x W x C, where H and W are the height and width of the feature map, and C is the number of classes. The Regression is used to predict the bounding box coordinates of the object, and the output is H x W x 4, where H and W are the height and width of the feature map, and 4 represents the bounding box parameters (e.g., x, y, width, height, or offsets relative to an anchor box). The Center-ness is used to predict the distance score of the object center from the predicted bounding box center, and the output is H x W x 1. This is often used to suppress predictions that are far away from the object center, which can improve the recognition accuracy. The Figure 3 As shown in FIG. 4, each branch (Classification, Regression, Center-ness) is implemented by several convolutional layers (marked as “x4” with small rectangles), each with 256 channels (H x W x 256).

[0059] Since we don't know which model is optimal before identifying canal system data, we can build different convolutional neural network models (which involves trying different backbone architectures, different FPN configurations, different head layers, etc.) and train them using the training set of the training database we built earlier. After training, we use the validation set to evaluate the performance of each model by assessing metrics such as precision and recall, and select the optimal model as the canal system identification model for target detection.

[0060] After selecting a canal system identification model, the model is used to identify irrigation canals in each image and obtain the latitude and longitude of the center of the canal identification frame. Generally, each image input into the canal system identification model is an image block of a predetermined size. The image block pre-generation process includes: downloading image data of the area to be identified; dividing the image data into rectangles of a predetermined size, with each rectangle corresponding to one image block.

[0061] This invention aims to add a step of image patch processing after generating the image patches, before the canal system identification model identifies irrigation canals in each image. Specifically, it introduces a self-attention mechanism to capture long-distance dependencies between image patches. Through this self-attention mechanism, the correlation between different images is calculated, with adjacent canal system image patches receiving higher weights. These weights are then combined with the model's identification results to ultimately determine the canal system identification result.

[0062] Figure 3 This is a flowchart illustrating the artificial intelligence-based automatic channel identification method provided by the present invention, as shown below. Figure 3 As shown, the method includes the following:

[0063] Step 301: Set up H independent attention heads. Each head generates a query matrix Q, a key matrix K, and a value matrix V from the local feature vectors of the image patch through linear transformation.

[0064] Step 302: Based on the query matrix Q and the key matrix K, calculate the original relevance of an adjacent image patch to the target image patch, denoted as the original similarity score;

[0065] Step 303: Multiply the original similarity score element by element with the directional weight matrix, and determine the attention weight of each adjacent image block to the target image block based on the multiplication result. The directional weight is determined based on the correlation between the adjacent image block and the channel direction.

[0066] Step 304: Re-weight and aggregate the value features of each image patch in the value matrix V according to the attention weights to generate the enhanced global feature vector of the target image patch;

[0067] Step 305: Fuse the global feature vector of the target image block with the local feature vector to identify the channel system based on the fused features.

[0068] By using the above method, an image preprocessing stage is added before the canal system identification model performs canal system identification. A self-attention mechanism is introduced to calculate the correlation between different image blocks. Adjacent canal system images are given higher attention weights. Thus, while preserving the local features of the image blocks, global features are introduced to capture the long-distance dependencies between image blocks. This solves the problem of missed identification at the connection points between different segments due to the excessive length of the canal system, thereby ultimately improving the accuracy of the canal system identification results.

[0069] As a specific implementation method, it can be divided into four steps: positional encoding injection, multi-head attention calculation, cross-block feature association, and hierarchical feature fusion. Each step will be explained in detail below.

[0070] 1. Position-encoded injection

[0071] Construct a position encoding matrix corresponding to the spatial size of the image data. This can be understood as each position in the matrix corresponding to the coordinates (x, y) of the original image patch. Each position in the position encoding matrix stores a trainable position vector, which represents the absolute position information of the image patch in the overall structure of the canal system.

[0072] The coordinates (which can be the center point coordinates) of each image patch in the input image are mapped into a position encoding matrix, and the corresponding position vector P is extracted. The position vector P is then added element-wise to the local feature vector F of the image patch to obtain the fused local feature vector F′ = F + P. The local feature vector F ∈ R of the image patch. D It records the texture, edges, and elevation (terrain) of each small area.

[0073] 2. Multi-head attention calculation

[0074] 1) Core Input

[0075] As the core input, the image patch embedding sequence (X) is represented as follows: Assume the image is segmented into N patches. Each patch is mapped to a D-dimensional feature vector through a linear embedding layer (or convolutional layer). Therefore, the entire input can be represented as a matrix X ∈ ^(N×D), where N is the number of blocks and D is the embedding dimension (feature vector length).

[0076] 2) Parameter settings

[0077] Number of attention heads (K): Specifies the number of independent attention heads to use.

[0078] The dimensions (d_k, d_v) of each head: Typically, d_k = d_v = D / K is set to ensure that the dimensions of the concatenated output of all heads are consistent with the input D. This means that D must be divisible by K.

[0079] 3) The specific operation process of each attention head h (h = 1, 2, ..., K) includes the following steps:

[0080] ① Define a head-specific learnable weight matrix

[0081] Each head h has its own three independent linear transformation weight matrices:

[0082] W_q^h ∈ ^(D × d_k): The weight matrix used to generate the query.

[0083] W_k^h ∈ ^(D × d_k): The weight matrix used to generate the key.

[0084] W_v^h ∈ ^(D × d_v): The weight matrix used to generate the value.

[0085] These matrices W_q^h, W_k^h, and W_v^h are parameters unique to this head h, unlike the parameters of other heads. They are parameters that the model needs to learn during training.

[0086] ② Apply a linear transformation to the input sequence to generate Q^h, K^h, V^h:

[0087] Multiply the entire input sequence matrix X by the three weight matrices of the head h respectively:

[0088] Query matrix (Q^h): Q^h = X W_q^h ∈ ^(N × d_k)

[0089] Each row corresponds to a "query vector" after the image patch is converted, indicating the role of that patch in searching for relevant information.

[0090] Bond matrix (K^h): K^h = X W_k^h ∈ ^(N × d_k)

[0091] Each row corresponds to a key vector after the image patch is converted, representing the information identifier that the patch can be queried.

[0092] Value matrix (V^h): V^h = X W_v^h ∈ ^(N × d_v)

[0093] Each row corresponds to a value vector after the image patch is converted, containing the information content that the patch actually needs to be aggregated.

[0094] Several key points need to be explained when applying linear transformations: the same input sequence X is input into all heads. Each head h projects X using its own independent W_q^h, W_k^h, W_v^h. The dimensions of the transformed Q^h, K^h, V^h are d_k (or d_v), which is smaller than the original input dimension D (because d_k = d_v = D / K).

[0095] ③ (Within the head) Self-attention is calculated, that is, attention calculation is completed within each head.

[0096] Calculate the attention output Z^h of this head using Q^h, K^h, and V^h generated by this head.

[0097] First, calculate the (scaled dot product) similarity score between all image patch pairs: Attention score: AttentionScore^h = softmax( (Q^h) (K^h)^T) / sqrt(d_k) ) ∈ ^(N × N). Through (Q^h) (K^h)^T) yields an N x N matrix, where the element (i, j) represents the query-key match score of the i-th block to the j-th block. Dividing by sqrt(d_k) prevents the dot product from becoming too large and causing gradient vanishing. Softmax is calculated along each row (key / value dimension) such that the sum of the attention weights of a given block i to all blocks j is 1.

[0098] Then, perform weighted aggregation: Z^h = AttentionScore^h V^h ∈ ^(N × d_v). Apply the attention weight matrix AttentionScore^h obtained in the previous step to the value matrix V^h. The i-th row of the result Z^h represents: for the i-th image patch, the new feature vector (dimension d_v) obtained by the attention head h by focusing on all other patches (including itself).

[0099] 4) Consolidate the outputs of all heads, i.e., consolidate the outputs of the overall multi-head mechanism:

[0100] Concatenate the outputs Z^h (h=1..K) of all K attention heads along the feature dimension:

[0101] Z = Concat(Z^1, Z^2, ..., Z^K) ∈ ^(N × (K d_v)) = ^(N × D)

[0102] Since d_v = D / K, the Z dimension after concatenation is restored to N x D.

[0103] 5) Final linear projection:

[0104] The concatenated Z (dimension N x D) is typically further processed by a learnable linear projection matrix W_o ∈ If ^(D × D), then Output = Z W_o ∈ ^(N × D).

[0105] The role of this projection W_o is to fuse and transform the spliced ​​multi-head information to generate the final multi-head self-attention output sequence, whose dimension (N x D) is consistent with the input sequence X, and can be input into subsequent layers (such as feedforward neural network layers).

[0106] Below is a specific example of applying a multi-head attention mechanism to an image patch (with dimensional examples):

[0107] Assume the parameters are as follows:

[0108] N = Number of image patches (e.g., 196)

[0109] D = Input feature dimension / Embedding dimension (e.g., 768)

[0110] K = Number of attention points (e.g., 12)

[0111] d_k = d_v = D / K (e.g., 768 / 12 = 64)

[0112] The specific steps include:

[0113] Input image patch: X ∈ ^(196×768)

[0114] For each head h (h=1..12), calculate the attention output Z^h of that head using the Q^h, K^h, and V^h generated by that head:

[0115] Q^h = X W_q^h (W_q^h ∈ ^(768×64)) → Q^h ∈ ^(196×64)

[0116] K^h = X W_k^h (W_k^h ∈ ^(768×64)) → K^h ∈ ^(196×64)

[0117] V^h = X W_v^h (W_v^h ∈ ^(768×64)) → V^h ∈ ^(196×64)

[0118] AttnScore^h = softmax( (Q^h (K^h)^T) / sqrt(64) ) ∈ ^(196×196)

[0119] Z^h = AttnScore^h V^h ∈ ^(196×64)

[0120] Concatenate all Z^h: Z = Concat(Z^1, Z^2, ..., Z^12) ∈ ^(196×768) (because 12) 64 = 768)

[0121] Output projection: Output = Z W_o (W_o ∈ ^(768×768)) → Output ∈ ^(196×768)

[0122] In the process of applying the multi-head attention mechanism to the image patches described above, each attention head is independent, and the weight matrices W_q^h, W_k^h, and W_v^h of each head are independent and different. This is the core of the "multi-head" design. Different heads learn to focus on different aspects of the input (such as contours, textures, colors, spatial relationships, etc.) in different representation subspaces (defined by these projections). Each head performs dimensionality reduction projection separately, that is, each head first projects the D-dimensional features of the input onto a lower-dimensional d_k / d_v-dimensional subspace for computation (reducing complexity and allowing attention to different features). Information aggregation is performed in each head's own space, that is, each head calculates the association between blocks (attention score, expressing the association weight between blocks) through Q^h, K^h, and V^h in its own subspace, and aggregates the information of V^h accordingly to obtain a new representation Z^h from that head's perspective. Finally, the results of all heads are concatenated and (optionally) projected to fuse the different information learned by all heads, forming a richer and more robust feature representation Output.

[0123] The above process learns the relationships between image patches simultaneously in multiple different subspaces or "viewpoints", which greatly enhances the model's ability to capture complex patterns and long-range dependencies.

[0124] As a second specific implementation, the process for determining the attention span between image blocks includes:

[0125] 1) Set up H independent attention heads and adopt a multi-head parallel mechanism. Each head generates a query matrix Q, a key matrix K, and a value matrix V from the fused local feature vector F′ through linear transformation. V is another linear mapping of the input features, which preserves the semantic information of the original features and is used for subsequent feature aggregation.

[0126] 2) Calculate attention weights (attention scores) to reflect the similarity between image patches.

[0127] The attention weight is determined by the following formula:

[0128]

[0129] Where w ij QK represents the attention weight of the i-th block to the j-th block. T It is the original similarity score, which reflects the original correlation between the original image patches. This indicates element-wise multiplication, where W is the directional weight matrix. This represents the dimensions of K and Q. By scaling QK... T Operation (i.e., division by) This ensures a stable training process. W is determined as follows:

[0130] ① Convert to planar coordinates and calculate the offset

[0131] Δx i =R·(x i -x c )·cos(y c ·π / 180)·π / 180

[0132] Δy i =R·(y i -y c )·π / 180 where x i and y i Let x be the latitude and longitude of the center of the i-th image patch, and let x be the latitude and longitude of the center of the entire image (containing all patches). c and y c R = 6371000m (Earth's radius).

[0133] ② Calculate the relative distance between the map blocks

[0134] Δx ij =∣Δx i -Δx j |

[0135] Δy ij =∣Δy i -Δy j |

[0136] ③ Calculate W by combining distance and direction parameters

[0137]

[0138] Where Dr is a parameter representing the direction, if Δy ij ≤1 and Δx ij If Δx > 0, then Dr = 0.7. ij ≤1 and Δy ij If >0, then Dr=0.7, if |Δx ij -Δy ij If |≤1, then Dr=0.5.

[0139] 3. Cross-block feature association (generating new features)

[0140] Based on the attention weights, the value features of each image patch in the value matrix V are re-weighted and aggregated to generate a global feature vector of the enhanced target image patch, including:

[0141] The value features of each image patch are reweighted and aggregated to generate the global perceptual features of the target image patch, i.e., the enhanced attention features of the i-th patch. , , where V jLet be the value vector of the j-th block, where j is the j-th row in the value matrix V, which has a total of N rows of data.

[0142] 4. Hierarchical feature fusion (original features and globally perceived features)

[0143] The original local features F (which record the texture, edges, and elevation (terrain) of each small region) are fused with the enhanced attention feature matrix A to preserve local details while introducing global information. The attention feature matrix A is composed of all... The resulting matrix uses directional weights (W) to focus on regions along the canal system direction (e.g., horizontal / vertical channels), ignoring irrelevant regions.

[0144] The algorithm for fusing the original local features F with the enhanced attention feature matrix is ​​as follows: Where LayerNorm is the normalization layer, and A is the global feature after attention enhancement, i.e., all The matrix consists of a learnable adjustment factor α, used to adjust the contribution to the global features. The original local features F can be channel edge details extracted by the CNN, and A is the attention-enhanced global feature (i.e., all...). The matrix is ​​composed of [various elements]. A learnable adjustment factor α is used to dynamically control the contribution of global features. For example, α is an adaptive adjustment factor responsible for feature fusion weights. In areas with obvious channel systems, α is increased, making the model more confident in the attention feature matrix A, which reflects global information, thus maintaining channel coherence. In cases of ordinary terrain or noise, α is decreased, relying more on local features F that express local details, avoiding being misled by incorrect directions. LayerNorm is a normalization layer used to stabilize the training process.

[0145] The present invention also provides an artificial intelligence-based automatic canal system identification system, the system comprising:

[0146] The linear transformation module is used to set up H independent attention heads, each of which generates a query matrix Q, a key matrix K, and a value matrix V from the local feature vectors of the image patch through linear transformation.

[0147] The original relevance calculation module is used to calculate the original relevance of a neighboring image patch to a target image patch based on the query matrix Q and the key matrix K, which is denoted as the original similarity score.

[0148] The attention weight determination module is used to multiply the original similarity score with the directional weight matrix element by element, and determine the attention weight of each adjacent image block to the target image block based on the multiplication result. The directional weight is determined based on the correlation between the adjacent image block and the channel direction.

[0149] The focus weighted aggregation module is used to re-weight and aggregate the value features of each image block in the value matrix V according to the focus weight, so as to generate a global feature vector of the enhanced target image block.

[0150] The hierarchical feature fusion module is used to fuse the global feature vector of the target image block with the local feature vector to identify the channel system based on the fused features.

[0151] In a preferred embodiment, the system further includes a position encoding matrix construction module for constructing a position encoding matrix corresponding to the spatial size of the image data, wherein each position in the position encoding matrix stores a trainable position vector, and the position vector represents the absolute position information of the image patch in the overall structure of the channel system; an image patch coordinate mapping module for mapping the coordinates of each image patch of the input image to the position encoding matrix and extracting the corresponding position vector P; and a local feature vector fusion module for adding the position vector P to the local feature vector F of the image patch element by element to obtain the fused local feature vector F′=F+P.

[0152] In a preferred embodiment, the system further includes a vector data download module for downloading image data of the area to be identified; and an image block segmentation module for segmenting the water system vector data into rectangles of a predetermined size, with each rectangle corresponding to an image block.

[0153] In a preferred embodiment, the attention-weighted aggregation module re-weights and aggregates the value features of each image block according to the attention weights to generate the global perception features of the target image block, i.e., the enhanced attention features of the i-th block. , , where V j Let be the value vector of the j-th block, where j is the j-th row in the value matrix V, which has a total of N rows of data.

[0154] The attention-weighted aggregation module fuses the original local features F with the enhanced attention feature matrix to preserve local details while introducing global information. The attention feature matrix is ​​composed of all... The matrix formed.

[0155] The present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the aforementioned artificial intelligence-based automatic channel identification method.

[0156] The present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the aforementioned artificial intelligence-based automatic channel identification method.

[0157] The automatic canal system identification method and system provided by the present invention introduces a self-attention mechanism to capture long-distance dependencies between image blocks, thereby solving the problem of missed identification at the connection points of different segments during segmented identification due to the long length of the canal system.

[0158] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communications bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other through the communications bus 440. The processor 410 can call logical instructions in the memory 430 to execute an artificial intelligence-based automatic channel identification method. This method includes: setting H independent attention heads, each head generating a query matrix Q, a key matrix K, and a value matrix V from the local feature vectors of image patches through linear transformations; calculating the original relevance of a neighboring image patch to a target image patch based on the query matrix Q and the key matrix K, denoted as the original similarity score; multiplying the original similarity score element-wise with a directional weight matrix, determining the attention weight of each neighboring image patch to the target image patch based on the multiplication result, wherein the directional weight is determined based on the relevance of the neighboring image patch to the channel direction; re-weighting and aggregating the value features of each image patch in the value matrix V according to the attention weight, generating an enhanced global feature vector of the target image patch; and fusing the global feature vector of the target image patch with the local feature vector to identify the channel system based on the fused features.

[0159] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0160] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the artificial intelligence-based automatic channel identification method provided by the above methods.

[0161] In remote sensing imagery, canal system identification has a variety of important applications.

[0162] In precision agriculture, canal system identification through remote sensing imagery provides a detailed understanding of the distribution of irrigation canals in farmland. For example, in large irrigation areas, accurate canal system identification helps agricultural managers determine the delivery paths of irrigation water. This allows them to develop reasonable irrigation plans based on the water requirements of crops and the water supply capacity of the canals. In winter wheat growing areas of the North China Plain, for instance, after identifying irrigation canals using remote sensing technology, irrigation can be precisely carried out through the canals according to the water requirements of wheat at different growth stages, improving irrigation efficiency and reducing water waste. Simultaneously, canal system identification is indispensable for assessing canal utilization efficiency. By combining information such as canal flow rate and velocity with data such as the canal geometry in remote sensing imagery, it is possible to analyze which canals have problems such as poor water delivery or leakage, allowing for timely maintenance and renovation. In newly constructed farmland water conservancy projects, such as canal lining projects, remote sensing imagery identification and comparison technology allows for real-time monitoring of project construction progress. For example, during the construction of seepage-proof channels, remote sensing images are regularly acquired to compare changes in channel morphology before and after construction, checking whether the channel lining is completed according to design requirements and ensuring that the project quality meets standards. For existing water conservancy facilities, channel identification also helps in protection and supervision. Once illegal occupation or damage to channels is discovered, such as the unauthorized construction of livestock farms near channels, it can be detected promptly and measures taken to stop it, ensuring the normal operation of farmland water conservancy facilities.

[0163] Canal systems play a vital role in farmland ecosystems. By identifying canals through remote sensing imagery, we can study their interactions with surrounding farmland ecological elements such as soil and vegetation. For example, the flow of water in canals carries nutrients to the farmland, influencing crop growth. Simultaneously, the growth status of vegetation surrounding the canals can affect their stability. Long-term remote sensing monitoring allows us to analyze the dynamic changes in these interactions, providing data support for maintaining farmland ecological balance.

[0164] In watershed water resource management, the canal system is a crucial link in water resource allocation. Identifying canals at various levels within a watershed using remote sensing imagery allows for the construction of detailed water network models. For example, in the Yellow River Basin, accurate canal system identification helps to rationally allocate limited water resources to different irrigation areas and water users through the canals, achieving optimal water resource allocation. In the event of drought or a sudden surge in water demand, a clear understanding of the canal system allows for rapid adjustments to water resource allocation plans. For instance, during peak summer agricultural irrigation periods, controlling canal gates can prioritize water allocation to areas urgently needing irrigation, improving emergency water resource allocation capabilities. The water quality in the canals has a significant impact on agricultural production and the ecological environment. Although remote sensing technology cannot directly measure the chemical indicators of water quality, identifying changes in the water's state, such as turbidity and color, can provide a preliminary assessment of whether water quality is abnormal. For example, if the water in a section of the canal suddenly turns black or contains a large amount of suspended solids, timely on-site testing can be arranged to quickly locate the source of water pollution and implement appropriate remediation measures.

[0165] In regional water resource comprehensive assessments, canals, as water resource transmission and distribution facilities, have their distribution and scale as important evaluation indicators. By identifying and analyzing canal systems in remote sensing imagery, and considering factors such as regional precipitation and evaporation, the role and shortcomings of existing canal systems in water resource utilization can be assessed. This provides a basis for long-term water resource planning, such as determining whether new canals need to be built or existing canals expanded to meet the water resource demands of regional economic and social development.

[0166] In areas surrounding wetlands, numerous channels connect to the wetland water system. Identifying these channels through remote sensing imagery allows for the study of their impact on wetland hydrological processes. For example, some channels may drain water from the wetland, leading to its shrinkage; while others may replenish the water supply, maintaining the health of the wetland ecosystem. Accurate channel identification facilitates appropriate measures, such as adjusting the direction of water flow and installing ecological flow control devices, to protect the wetland ecosystem. Channels can also serve as part of ecological corridors, connecting different ecosystems. In ecological corridor planning, identified canal systems can help determine the direction and layout of the corridors. Furthermore, regularly monitoring changes in channels and their surrounding environment using remote sensing imagery allows for the assessment of the connectivity and ecological functions of the ecological corridors, such as their facilitation of species migration and dispersal.

[0167] In summary, canal system identification has a very wide range of applications and is used to solve specific technical problems in these scenarios. Therefore, research and innovation in canal system identification has significant practical implications.

[0168] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0169] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An automatic canal system identification method based on artificial intelligence, characterized in that, include: H independent attention heads are set up, and each attention head generates a query matrix Q, a key matrix K, and a value matrix V from the local feature vectors of the image patch through linear transformation. Based on the query matrix Q and the key matrix K, the original relevance of an adjacent image patch to the target image patch is calculated and denoted as the original similarity score. The original similarity score is multiplied element by element by the directional weight matrix, and the attention weight of each adjacent image block to the target image block is determined based on the multiplication result. The directional weight matrix is ​​determined based on the correlation between the adjacent image blocks and the channel direction, specifically including: calculating the offset between the center position of each adjacent image block and the center position of the whole image containing the adjacent image blocks in the plane coordinates. The relative distance between adjacent image blocks is calculated based on the offset; the directional weight is calculated by combining the distance and the orientation parameter. Based on the attention weights, the value features of each image block in the value matrix V are re-weighted and aggregated to generate a global feature vector of the target image block after weighted aggregation; The global feature vector of the target image patch is fused with the local feature vector to preserve local details while introducing global information, and the channel system is identified based on the fused features.

2. The automatic canal system identification method based on artificial intelligence according to claim 1, characterized in that, Before generating the query matrix Q, key matrix K, and value matrix V from the local feature vectors of the image patch through linear transformations, this method includes: Construct a position encoding matrix corresponding to the spatial size of the image data. Each position in the position encoding matrix stores a trainable position vector, and the position vector represents the absolute position information of the image patch in the overall structure of the canal system. The coordinates of each image patch in the input image are mapped to the position encoding matrix, and the corresponding position vector P is extracted. The position vector P is added element by element to the local feature vector F of the image block to obtain the fused local feature vector F′=F+P.

3. The automatic canal system identification method based on artificial intelligence according to claim 1, characterized in that, Before each header generates the query matrix Q, key matrix K, and value matrix V from the local feature vectors of the image patch through linear transformation, the method also includes: Download the image data of the area to be identified; The image data is divided into rectangles of a predetermined size, with each rectangle corresponding to an image block.

4. The automatic canal system identification method based on artificial intelligence according to claim 1, characterized in that, The attention weight is determined by the following formula: ; QK T This is the original similarity score, ⊙ denotes element-wise multiplication, and W is the directional weight matrix. Indicates the dimensions of K and Q.

5. The automatic canal system identification method based on artificial intelligence according to claim 4, characterized in that, Based on the attention weights, the value features of each image patch in the value matrix V are re-weighted and aggregated to generate a weighted and aggregated global feature vector of the target image patch, including: The value features of each image patch are reweighted and aggregated to generate the global perceptual features of the target image patch, i.e., the enhanced attention features of the i-th target image patch. , , where Vj is the value vector of the j-th target image patch, j is the j-th row in the value matrix V, and the value matrix V has a total of N rows of data.

6. The automatic canal system identification method based on artificial intelligence according to claim 5, characterized in that, The step of fusing the global feature vector and the local feature vector of the target image patch includes: fusing the original local feature vector with the enhanced attention feature matrix to preserve local details while introducing global information, wherein the attention feature matrix is ​​composed of all The matrix formed.

7. The artificial intelligence-based automatic canal system identification method according to claim 6, characterized in that, The algorithm for fusing the original local features F with the enhanced attention feature matrix is ​​as follows: Where LayerNorm is the normalization layer, and A is the global feature after attention enhancement, i.e., all The matrix consists of α, a learnable adjustment factor used to adjust the contribution to the global features, and Z, the fused features.

8. An artificial intelligence-based automatic canal system identification system, characterized in that, The system includes: The linear transformation module is used to set up H independent attention heads, each of which generates a query matrix Q, a key matrix K, and a value matrix V from the local feature vectors of the image patch through linear transformation. The original relevance calculation module is used to calculate the original relevance of a neighboring image patch to a target image patch based on the query matrix Q and the key matrix K, which is denoted as the original similarity score. The attention weight determination module is used to multiply the original similarity score element-wise with the directional weight matrix, and determine the attention weight of each adjacent image patch to the target image patch based on the multiplication result. The directional weight matrix is ​​determined based on the correlation between the adjacent image patches and the channel direction, specifically including: calculating the offset between the center position of each adjacent image patch and the center position of the entire image containing the adjacent image patch in the planar coordinates; calculating the relative distance between adjacent image patches based on the offset; and calculating the directional weight by combining the distance and the direction parameter. The focus weighted aggregation module is used to re-weight and aggregate the value features of each image block in the value matrix V according to the focus weight, so as to generate a global feature vector of the enhanced target image block. The hierarchical feature fusion module is used to fuse the global feature vector of the target image block with the local feature vector to retain local details while introducing global information, and to identify the channel system based on the fused features.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the artificial intelligence-based automatic channel identification method as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the artificial intelligence-based automatic channel identification method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • MROCNet model construction and multi-source remote sensing image change detection method and system

    CN116363526A

  • Method and system for registering electric wires among aerial images of unmanned aerial vehicle based on deep learning

    CN119672078A