A waterlogging detection large model training method, training device, detection method and equipment
By training a large-scale waterlogging detection model in the SAM2-Adapter model framework using both labeled and unlabeled datasets, and by using pseudo-labels to calculate the loss function and pre-defined rules to filter pseudo-labels, the high labeling cost and limited model performance of existing technologies are solved, achieving efficient waterlogging detection results.
Patent Information
- Application Number
- CN202510445471.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2025-04-09
- Filing Date
- 2025-04-10
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2045-04-10
AI Technical Summary
Existing urban flooding detection technologies rely on fully supervised semantic segmentation models, which require a large amount of labeled data and have high labeling costs. Semi-supervised algorithms lack sufficient consistency regularization constraints, and the false label confidence threshold is too high, resulting in low data utilization. Traditional adapter fine-tuning methods lack domain knowledge, which limits model performance.
The SAM2-Adapter model framework is adopted, and a large-scale waterlogging detection model is trained by combining labeled and unlabeled datasets. The model parameters are optimized by calculating the loss function through pseudo-labels, pseudo-labels are filtered by preset rules, and the consistency of prediction results of strong perturbation branches is explicitly constrained to improve the generalization and robustness of the model.
While reducing the amount of data labeling, the accuracy and generalization ability of the urban flooding detection model were improved, the negative impact of noise and false labels was reduced, and the robustness and detection effect of the model were enhanced.
Smart Images

Figure CN120356034B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, and in particular to a waterlogging detection large model training method, a training device, a detection method and equipment. BACKGROUND
[0002] City waterlogging detection is an important means to deal with modern urban flood disasters and an important part of smart city management. Current city waterlogging detection technologies mainly include physical sensor-based (such as water level gauges) and vision image-based. Waterlogging detection methods based on images can be mainly divided into target detection-based methods and semantic segmentation-based methods. The target detection-based method gives a detection box (Bounding Box) for the waterlogging area, while the semantic segmentation-based method can give a pixel-level segmentation mask for the waterlogging area, which belongs to the binary classification semantic segmentation task.
[0003] Current image-based city waterlogging detection methods mainly rely on fully supervised semantic segmentation models, which require a large amount of labeled data and have high labeling costs. Existing semi-supervised algorithms (such as UniMatch V2) have problems such as insufficient consistency regularization constraints, too high pseudo-label confidence thresholds, and low data utilization. In addition, although visual base models (such as SAM2, SegmentAnything in Images and Videos) have general segmentation capabilities, they lack domain knowledge for waterlogging scenes, and traditional adapter fine-tuning methods (such as SAM2-Adapter) only use fully supervised learning, which limits the model performance. SUMMARY
[0004] The present application aims to at least solve the technical problems existing in the prior art, and provides a waterlogging detection large model training method, a training device, a detection method and equipment.
[0005] In a first aspect, the present application provides a waterlogging detection large model training method, which comprises:
[0006] Obtaining a training data set, the training data set comprising a labeled data set and an unlabeled data set; the labeled data set comprising labeled waterlogging images and mask labels corresponding to the labeled waterlogging images, and the unlabeled data set comprising unlabeled waterlogging images;
[0007] Constructing a network structure of a waterlogging detection large model;
[0008] The network of the waterlogging detection large model is trained by using the labeled data set and the unlabeled data set, at each time of training, a prediction of the labeled waterlogging image is obtained by using the waterlogging detection large model, and a pseudo label of the unlabeled waterlogging image is obtained by processing the unlabeled waterlogging image according to a preset rule; a loss function of the waterlogging detection large model is calculated by using the prediction of the labeled waterlogging image and the pseudo label of the unlabeled waterlogging image, the network parameters of the waterlogging detection large model are optimized by using the loss function, and finally, the waterlogging detection large model is obtained.
[0009] In a second aspect, the present application provides a waterlogging detection large model training device, comprising:
[0010] The acquisition module is configured to acquire a training data set, wherein the training data set comprises a labeled data set and an unlabeled data set; the labeled data set comprises labeled waterlogging images and mask labels corresponding to the labeled waterlogging images; and the unlabeled data set comprises unlabeled waterlogging images.
[0011] The construction module is configured to construct a network structure of the waterlogging detection large model.
[0012] The training module is configured to train the network of the waterlogging detection large model by using the labeled data set and the unlabeled data set, at each time of training, a prediction of the labeled waterlogging image is obtained by using the waterlogging detection large model, and a pseudo label of the unlabeled waterlogging image is obtained by processing the unlabeled waterlogging image according to a preset rule; a loss function of the waterlogging detection large model is calculated by using the prediction of the labeled waterlogging image and the pseudo label of the unlabeled waterlogging image, the network parameters of the waterlogging detection large model are optimized by using the loss function, and finally, the waterlogging detection large model is obtained.
[0013] In a third aspect, the present application provides a waterlogging detection method, comprising:
[0014] Acquiring a waterlogging image to be processed;
[0015] Inputting the waterlogging image into the final waterlogging detection large model trained by using the waterlogging detection large model training method, to obtain a waterlogging detection result.
[0016] In a fourth aspect, the present application provides an electronic device, comprising:
[0017] At least one processor; and
[0018] A memory in communication connection with the at least one processor; wherein
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the waterlogging detection large model training method.
[0020] In summary, the present application includes the following beneficial technical effects:
[0021] Data labeling is a labor-intensive task that requires a lot of manpower and time cost. The present application can fully utilize limited labeled data sets and easily obtain unlabeled data sets to train the inland flood detection large model, which can reduce the workload of the staff while ensuring the accuracy of the inland flood detection large model; before calculating the loss function using the pseudo label, the pseudo label is screened using the preset rule, the pseudo label pixels that do not meet the threshold condition do not participate in model training, and only the pseudo labels that meet the condition are used to update the network parameters of the inland flood detection large model, which can reduce the negative effects of noise pseudo labels and improve the accuracy of the inland flood detection large model.
[0022] The present application explicitly constrains the prediction results (second prediction result and third prediction result) of the two strong disturbance branches (branches corresponding to the first strong augmented image and the second strong augmented image), and constrains the consistency of the prediction results of the two strong disturbance branches, which promotes the inland flood detection large model to learn and extract disturbance-invariant discriminative features, and helps to improve the generalization and robustness of the inland flood detection large model. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 The flowchart of the inland flood detection large model training method provided by an embodiment of the present application is shown.
[0024] Figure 2 The network architecture diagram of the inland flood detection large model provided by an embodiment of the present application is shown.
[0025] Figure 3 The overall framework diagram of the semi-supervised algorithm provided by an embodiment of the present application is shown.
[0026] Figure 4 The comparison diagram of the inland flood detection large model trained by the inland flood detection large model training method provided by an embodiment of the present application and the inland flood detection large model trained by the existing training method for the inland flood area segmentation effect in the urban inland flood image is shown.
[0027] Figure 5 The structural schematic diagram of the electronic device for implementing the inland flood detection large model training method provided by an embodiment of the present application is shown.
[0028] The figure legend: 10, processor; 11, memory; 12, communication bus; 13, communication interface.
[0029] The implementation of the present application, the functional characteristics and advantages will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0030] Embodiments of the present application are described below in detail with reference to the accompanying drawings, examples of which are shown in the drawings, wherein the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as a limitation of the present application.
[0031] In the description of the present application, it should be understood that the terms "longitudinal", "transverse", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer" and the like indicate the orientation or positional relationship shown in the drawings, which are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation of the present application.
[0032] In the description of the present application, unless otherwise specified and limited, it should be noted that the terms "mounting", "connection", "connection" should be understood broadly, for example, it can be mechanical connection or electrical connection, it can be the communication between two elements, it can be direct connection or indirect connection through intermediate medium, and the specific meaning of the above terms can be understood by those skilled in the art according to the specific circumstances.
[0033] Referring to Figure 1 Fig. 1 shows a flowchart of an internal flooding detection large model training method provided by an embodiment of the present application. In this embodiment, the internal flooding detection large model training method comprises:
[0034] S1, obtaining a training data set.
[0035] The training data set includes a plurality of images related to urban internal flooding scenes, and the training data set includes a labeled data set and an unlabeled data set; the labeled data set includes a plurality of labeled internal flooding images and mask labels corresponding to the labeled internal flooding images, and the unlabeled data set includes a plurality of unlabeled internal flooding images. In this embodiment, the labeled data set is represented as The unlabeled data set is represented as Wherein, represents the i-th labeled internal flooding image, represents the corresponding true value mask label; represents the i-th unlabeled internal flooding image, and during training, each batch (batch) is composed of B l labeled internal flooding images and B u unlabeled internal flooding images.
[0036] The labeled data set can adopt an existing data set (for example, the UW-Bench data set), and the UW-Bench data set includes 5584 images, wherein the v2 test set of the UW-Bench includes 2124 images, including 1069 general samples and 1055 hard samples; the unlabeled data set can be collected by itself or selected from other unlabeled data sets related to the urban waterlogging scene, and the embodiment is not limited. Data labeling is a labor-intensive work, which consumes a large amount of manpower and time cost, and by using limited labeled data and a large amount of easily obtained unlabeled data, the data labeling amount can be reduced while ensuring the performance of the waterlogging detection large model.
[0037] S2, constructing a network structure of the waterlogging detection large model.
[0038] With reference to Figure 2 In the embodiment, the framework of the waterlogging detection large model adopts a SAM2-Adapter model framework, the English full name of SAM2 is Segment Anything in Images and Videos, and the Chinese interpretation is a model for segmenting everything in images and videos 2; the SAM2 includes an encoder, a decoder and a prompt encoder. The SAM2 has strong zero-shot generalization capability, can accept points, frames and masks as prompts (used to indicate objects to be segmented), and realizes segmentation of an input image. The zero-shot generalization capability refers to the capability of the model to complete a task only by a given instruction or prompt on a specific task or data set that has never been seen before.
[0039] The SAM2-Adapter model framework is further designed on the basis of the SAM2, and an adapter module is added to the encoder to inject task-specific information into the encoder to realize downstream task adaptation of the SAM2 architecture; in the SAM2-Adapter framework of the embodiment, the task-specific information adopted is high-frequency information of an image, the high-frequency information of the input image is extracted, the task-specific information is injected into a large model (i.e., a vision foundation model) through several simple MLP (multi-layer perceptron) modules to realize downstream task fine-tuning of the large model; the high-frequency information can reflect texture details, edges and other information, so as to realize segmentation of the waterlogging detection large model on the image.
[0040] With reference to Figure 2 The processing steps of the SAM2-Adapter model on the input image include:
[0041] S201, respectively processing the input image by using a plurality of adapters (Adapters), and the plurality of adapters respectively extract task-specific information (high-frequency information) and inject the task-specific information into a SAM2 image encoder.
[0042] S202, input the input image into the SAM2 image encoder (SAM2 Image Encoder), the SAM2 image encoder extracts the features of the input image, and fuses the features of the input image and the task-specific information extracted by the plurality of adapters to obtain an image embedding.
[0043] S203, input the image embedding into the mask decoder (SAM2 Mask Decoder) to obtain a final segmentation mask.
[0044] It should be noted that in the overall framework of the SAM2-Adapter model, the adapter (Adapter) and the mask decoder (SAM2 Mask Decoder) part are trainable, and the image encoder part is frozen.
[0045] S3, training the network of the waterlogging detection large model using the labeled data set and the unlabeled data set, at each training, obtaining the prediction of the labeled waterlogging image using the waterlogging detection large model, and processing the unlabeled waterlogging image according to a preset rule to obtain the pseudo label of the unlabeled waterlogging image; calculating the loss function of the waterlogging detection large model using the prediction of the labeled waterlogging image and the pseudo label of the unlabeled waterlogging image, optimizing the network parameters of the waterlogging detection large model using the loss function, and obtaining the final waterlogging detection large model.
[0046] The prediction of the labeled waterlogging image refers to the prediction result of the target object existing in the labeled waterlogging image after the network of the waterlogging detection large model analyzes the labeled waterlogging image; by comparing the prediction of the labeled waterlogging image with the mask label corresponding to the labeled waterlogging image, the loss related to the labeled waterlogging image of the waterlogging detection large model can be determined.
[0047] Specifically, the loss function of the waterlogging detection large model is calculated using the prediction of the labeled waterlogging image and the pseudo label of the unlabeled waterlogging image, including:
[0048] S31, analyzing the unlabeled waterlogging image to obtain a prediction result, and generating a pseudo label according to the prediction result;
[0049] Specifically, the prediction result includes a plurality of prediction categories. The step of analyzing the unlabeled waterlogging image to obtain a prediction result and generating a pseudo label according to the prediction result includes:
[0050] S311, processing the unlabeled waterlogging image according to a first preset rule to obtain a weakly augmented image of the unlabeled waterlogging image.
[0051] Referring to Figure 3 In this embodiment, the weakly augmented image x is obtained by weakly augmented method A w obtain the corresponding weakly augmented image xw The weak augmentation manner includes random resizing, random cropping, random horizontal flipping, etc., and can be determined according to actual requirements; and a processing process of the weak augmentation manner is expressed by the following formula:
[0052] x w =A w (x u )
[0053] S312, processing the unlabeled waterlogging image according to a second preset rule to obtain a first strong augmented image and a second strong augmented image of the unlabeled waterlogging image.
[0054] Referring to Figure 3 , in the embodiment, the first strong augmented image s and the second strong augmented image are obtained by a strong augmentation manner A The strong augmentation manner includes color jittering, grayscaling, gaussian blurring, etc., and can be determined according to actual requirements; and a processing process of the strong augmentation manner is expressed by the following formula:
[0055]
[0056] S313, inputting the weak augmented image into the teacher model, outputting a first prediction result by the teacher model, and generating a first pseudo label according to the first prediction result.
[0057] Referring to Figure 3 , in the embodiment, the teacher model is obtained by using an exponential moving average manner. It is assumed that a teacher parameter is θ t , a student model parameter is θ s , and an updating manner of the teacher model is: θ t ← γ × θ t + (1-γ) × θ s ,
[0058] wherein, γ is a hyperparameter, and γ is dynamically set as γ ← indicates that the left side is updated by the right side, that is, the new teacher parameter is calculated and updated by the related old parameter on the right side, and the left side of ← is updated by the right side of ←; “iter” means iteration, which means that the process of training a batch of data is an iteration. The process of obtaining the prediction of the weak augmented image by using the teacher model can be expressed as This function is denoted as a teacher model, which is used to obtain pseudo labels. Specifically, The teacher model is obtained by using the EMA (Exponential Moving Average) method, which is better than the student model in performance and more reliable in predicting the results of unlabeled images. The obtained prediction p w is the first pseudo label. The first pseudo label p w is obtained in this embodiment. The post-processing using the argmax operator becomes a one-hot label
[0059] S314, extracting the features of the first strongly augmented image to obtain a first intermediate feature, performing feature-level augmentation processing on the first intermediate feature to obtain a first target feature, and determining a second prediction result according to the first target feature.
[0060] S315, generating a second pseudo label according to the second prediction result.
[0061] S316, extracting the features of the second strongly augmented image to obtain a second intermediate feature, performing feature-level augmentation processing on the second intermediate feature to obtain a second target feature, and determining a third prediction result according to the second target feature.
[0062] S317, generating a third pseudo label according to the third prediction result.
[0063] Referring to Figure 3 , for a strongly augmented image x s , its prediction result p sf The acquisition process can be represented as:
[0064] e s = g(x s ), p sf = h(F(e s )),
[0065] where g(.) is an encoder, h(.) is a decoder, e s represents the extracted intermediate feature, and F represents feature-level augmentation, i.e., complementary channel Dropout. Specifically, for the features e extracted from the first strongly augmented image x we sample a binary Dropout mask M with the same dimension as the first intermediate feature e from a binomial distribution with a probability of 0.5, half of the channels of which are set to all 1 and the other half to 0. The binary Dropout mask M is used to perform complementary channel Dropout on the first intermediate feature e and the second intermediate feature e , and the expression of the specific operation is:
[0066]
[0067] wherein, ⊙ represents Hadamard product, ← represents that the value on the left side is updated by the operation on the right side, and × represents multiplication operation. In this embodiment, the operation of multiplying 2 is to ensure that the expectation of the processed feature is consistent with the normal feature.
[0068] The expression of the second prediction result is The expression of the third prediction result is h(.) is a decoder.
[0069] The use of two strong augmented images (the first strong augmented image and the second strong augmented image) can more fully explore the preset image-level perturbation space; in addition, the constraint that the two strong augmented branches approach the same weak augmented branch can be regarded as minimizing the distance between the two strong augmented branches, which learns more discriminative representations by drawing on the idea of contrastive learning.
[0070] In addition, in this embodiment, only plays a supervisory role, and does not participate in the update of the loss function when p w is converted into ; the network parameters of the waterlogging detection large model are updated using the second pseudo label and the third pseudo label.
[0071] S32, determining whether the pseudo label corresponding to the prediction result meets the preset condition according to the confidence of the predicted category in the prediction result, to obtain the pseudo label meeting the preset condition.
[0072] The filtering step of the pseudo label meeting the preset condition includes:
[0073] S321, obtaining a confidence preset value.
[0074] S322, comparing the maximum confidence of the predicted category in the prediction result with the confidence preset value:
[0075] If the maximum confidence of the predicted category in the prediction result is greater than or equal to the confidence preset value, the pseudo label of the pixel corresponding to the preset result is put into the supervision set, and the pseudo label in the supervision set is the pseudo label meeting the preset condition;
[0076] If the maximum confidence of the predicted category in the prediction result is less than the confidence preset value, the pseudo label will not be used to update the loss function.
[0077] S33, calculating the loss function of the waterlogging detection large model according to the pseudo label meeting the preset condition.
[0078] The loss function of the waterlogging detection large model comprises a labeled waterlogging image loss and an unlabeled waterlogging image loss, and the unlabeled waterlogging image loss comprises a first supervision loss and a second supervision loss; the first supervision loss is used to quantify the error between the weak augmented image and the first strong augmented image, and is used to quantify the error between the weak augmented image and the second strong augmented image; and the second supervision loss is used to quantify the error between the first strong augmented image and the second strong augmented image.
[0079] The loss function of the waterlogging detection large model is denoted as L, and the expression of the loss function of the waterlogging detection large model is as follows:
[0080] L=L l +λL u ,
[0081] L l is the labeled waterlogging image loss, and L u is the unlabeled waterlogging image loss, and λ is a parameter for balancing the effect of unannotated data.
[0082] The expression of the labeled waterlogging image loss is as follows:
[0083]
[0084] wherein B l represents the total number of labeled waterlogging images, is the prediction result of the i-th labeled waterlogging image by the network of the waterlogging detection large model, is the true value mask corresponding to the i-th labeled waterlogging image. H(.) represents the cross-entropy loss.
[0085] In this embodiment, the expression of the unlabeled waterlogging image loss is as follows
[0086]
[0087] wherein B u represents the total number of unlabeled waterlogging images, and i represents the index of the unlabeled waterlogging image, represents the second prediction result, represents the third prediction result, represents the first pseudo label, represents the second pseudo label, represents the third pseudo label, and H(.) represents the cross-entropy loss.
[0088] represents the maximum confidence in the predicted class corresponding to the first prediction result; τ represents a first confidence preset value, and τ s represents a second confidence preset value, and II(.) represents 1 when the judgment condition in the bracket is met; The operator is used to obtain a 0 or 1 binary mask, and the positions of pixels meeting the conditions in the brackets are assigned a value of 1, otherwise a value of 0, so as to obtain a binary mask. The specific meaning is that the pixels meeting the conditions in the brackets participate in the loss calculation, and the pixels not meeting the conditions do not participate in the loss calculation. The II(.) operator can avoid the negative effects of noise pseudo-labels, and it predefines a confidence threshold (τ / τ s ), and the pseudo-label pixels not meeting the threshold condition do not participate in the training (that is, the loss is not calculated). The specific meaning of the II(.) operator is that if the maximum confidence in all categories is greater than the preset threshold, it is multiplied by 1, that is, it participates in the loss calculation of the unlabeled waterlogging image, and if the maximum confidence in all categories is less than the preset threshold, it is multiplied by 0, that is, it does not participate in the loss calculation, τ / τ s The value of can be set according to actual conditions, and the present application does not make any limitation.
[0089] The present application explicitly constrains the prediction results (the second prediction result and the third prediction result) of the two strong disturbance branches, narrows the distance between the two strong disturbance branches, promotes the learning of the waterlogging detection large model to extract discriminative features that are invariant to disturbances, and helps to improve the generalization and robustness of the waterlogging detection large model.
[0090] Referring to Table 1 and Figure 4 Table 1 is a comparison table of performance parameters of a waterlogging detection large model trained by the waterlogging detection large model training method of the present application and performance parameters of a model trained by an existing semi-supervised learning algorithm UniMatch V2;
[0091] Figure 4 Fig. 1 is a comparison chart of segmentation effects of a city waterlogging image by a waterlogging detection large model trained by the waterlogging detection large model training method of the present application and a city waterlogging image by a model trained by an existing semi-supervised learning algorithm UniMatch V2;
[0092] Table 1 Comparison table of performance of the waterlogging detection large model training method of the present application and the UniMatch V2 training method
[0093]
[0094]
[0095] It can be seen that the waterlogging detection large model training method corresponding to the present application has better performance than UniMatch V2, and can achieve better IoU (that is, intersection over union) and F1-score (that is, F1 score). It can be seen that the waterlogging detection large model training method of the present application can bring performance gain.
[0096] Based on the same inventive concept, an embodiment of the present application provides a waterlogging detection large model training device.
[0097] The flooding detection large model training device can be loaded in an electronic device. According to the functions implemented, the flooding detection large model training device comprises an acquisition module, a construction module and a training module. The acquisition module can acquire a labeled data set and an unlabeled data set as training data sets of the flooding detection large model. The labeled data set comprises labeled flooding images and mask labels corresponding to the labeled flooding images, and the unlabeled data set comprises unlabeled flooding images. The construction module can construct a network structure of the flooding detection large model. The training module can train the network of the flooding detection large model by using the labeled data set and the unlabeled data set. In each training, a prediction of the labeled flooding images is obtained by using the flooding detection large model, and a pseudo label of the unlabeled flooding images is obtained by processing the unlabeled flooding images according to a preset rule. A loss function of the flooding detection large model is calculated by using the prediction of the labeled flooding images and the pseudo label of the unlabeled flooding images. The network parameters of the flooding detection large model are optimized by using the loss function, and a final flooding detection large model is obtained.
[0098] The module can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete a fixed function, and is stored in the memory of the electronic device.
[0099] The various changes and specific examples of the flooding detection large model training method provided in the above embodiments are also applicable to the flooding detection system of the present embodiment. Through the foregoing detailed description of the flooding detection large model training method, those skilled in the art can clearly understand the implementation method of the flooding detection system in the present embodiment. In order to make the description brief, the flooding detection system will not be described in detail here.
[0100] Based on the same inventive concept, the present application also provides a flooding detection method, which comprises:
[0101] S101, acquiring a flooding image to be processed.
[0102] S102, inputting the flooding image into the final flooding detection large model obtained by the flooding detection large model training method, to obtain a flooding detection result.
[0103] The present application also discloses an electronic device, such as Figure 5 As shown in the figure, it is a structural schematic diagram of an electronic device of the flooding detection large model training method or / and the flooding detection method provided by an embodiment of the present application. The electronic device can comprise at least one processor 10, a memory 11 in communication connection with the at least one processor, a communication bus 12 and a communication interface 13, and can further comprise a computer program stored in the memory 11 and executable on the processor 10, such as a flooding detection large model training method program.
[0104] The processor 10 can be composed of integrated circuits in some embodiments, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connects various components of the entire electronic device through various interfaces and lines, executes programs or modules stored in the memory 11 (such as executing the method for training an inland flood detection large model, etc.), and calls data stored in the memory 11 to perform various functions and process data of the electronic device.
[0105] The memory 11 includes at least one type of readable storage medium, including flash memory, mobile hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory 11 can be an internal storage unit of the electronic device in some embodiments, for example, a mobile hard disk of the electronic device. The memory 11 can also be an external storage device of the electronic device in other embodiments, for example, a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 11 can include both the internal storage unit and the external storage device of the electronic device. The memory 11 can be used not only to store application software and various data installed on the electronic device, such as the code of the method for training an inland flood detection large model, but also to temporarily store data that has been output or will be output.
[0106] The communication bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize the connection and communication between the memory 11, the processor 10, etc.
[0107] The communication interface 13 is used for communication between the electronic device and other devices, including a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the electronic device and other electronic devices. The user interface can be a display, an input unit (such as a keyboard), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. Among them, the display can also be appropriately called a display screen or a display unit, which is used to display information processed in the electronic device and to display a visualized user interface.
[0108] Figure 5 Only the electronic device with components is shown, and those skilled in the art can understand that, Figure 5 The structure shown does not constitute a limitation on the electronic device, and can include fewer or more components than shown, or combine certain components, or different component arrangements. For example, although not shown, the electronic device can also include a power supply (such as a battery) for powering each component. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, so that functions such as charge management, discharge management, and power consumption management can be realized through the power management device. The power supply can also include one or more direct current or alternating current power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components. The electronic device can also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which are not described here.
[0109] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by this structure.
[0110] Further, the modules / units integrated in the electronic device, if realized in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. The computer readable storage medium can be volatile or non-volatile.
[0111] In the description of the specification, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", "one implementation", "a preferred implementation" or "some examples" etc. means that the particular feature, structure, material or characteristic being described in connection with the embodiment or example is included in at least one embodiment or example of the application. The illustrative appearances of the above-mentioned terms in various places in the specification are not necessarily intended to refer to the same embodiment or example. Moreover, the particular features, structures, materials or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0112] Although embodiments of the present application have been shown and described, it would be appreciated by those skilled in the art that changes, modifications, alternatives and variations to these embodiments could be made without departing from the principles and spirit of the application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for training an inland flooding detection large model, characterized in that, The method comprises: obtaining a training data set, the training data set comprising a labeled data set and an unlabeled data set; the labeled data set comprising labeled waterlogging images and mask labels corresponding to the labeled waterlogging images, and the unlabeled data set comprising unlabeled waterlogging images; constructing a network structure of a waterlogging detection large model; training the network of the waterlogging detection large model using the labeled data set and the unlabeled data set; at each training, obtaining a prediction of the labeled waterlogging images by using the waterlogging detection large model, processing the unlabeled waterlogging images according to a preset rule to obtain pseudo labels of the unlabeled waterlogging images, calculating a loss function of the waterlogging detection large model using the prediction of the labeled waterlogging images and the pseudo labels of the unlabeled waterlogging images, optimizing network parameters of the waterlogging detection large model using the loss function, and obtaining a final waterlogging detection large model; the processing of the unlabeled waterlogging images according to the preset rule to obtain the pseudo labels of the unlabeled waterlogging images comprises: processing the unlabeled waterlogging images according to a first preset rule to obtain weak augmented images of the unlabeled waterlogging images; processing the unlabeled waterlogging images according to a second preset rule to obtain first strong augmented images and second strong augmented images of the unlabeled waterlogging images; inputting the weak augmented images into a teacher model, the teacher model outputting a first prediction result, and generating a first pseudo label according to the first prediction result; extracting features of the first strong augmented images to obtain first intermediate features, performing feature-level augmentation processing on the first intermediate features to obtain first target features, and determining a second prediction result according to the first target features; generating a second pseudo label according to the second prediction result; extracting features of the second strong augmented images to obtain second intermediate features, performing feature-level augmentation processing on the second intermediate features to obtain second target features, and determining a third prediction result according to the second target features; generating a third pseudo label according to the third prediction result; Utilizing binary dropout masks respectively for the first intermediate feature and the second intermediate feature complementary channel dropout, the expression of which is: ; wherein, denotes a Hadamard product, denotes that the value on the left is updated by the operation on the right, denotes a multiplication operation; the loss function of the waterlogging detection large model comprises a labeled waterlogging image loss and an unlabeled waterlogging image loss; the expression of the unlabeled waterlogging image loss is ; wherein, denotes the number of unlabeled waterlogging images, denotes the index of the unlabeled waterlogging image, denotes the maximum confidence in the prediction category corresponding to the first prediction result; denotes the first confidence preset value, denotes the second confidence preset value, denotes 1 when the judgment condition in the parentheses is met. represents a second prediction result, represents a third prediction result, represents a first pseudo label, represents a second pseudo label, represents a third pseudo label, represents a cross-entropy loss.
2. The training method of claim 1, wherein, the calculation of the loss function of the waterlogging detection large model using the prediction of the labeled waterlogging images and the pseudo labels of the unlabeled waterlogging images comprises: analyzing the unlabeled waterlogging images to obtain a prediction result, and generating a pseudo label according to the prediction result, the prediction result comprising a plurality of prediction categories; determining whether the pseudo label corresponding to the prediction result satisfies a preset condition according to a confidence of the prediction category in the prediction result, to obtain a pseudo label satisfying the preset condition; calculating the loss function of the waterlogging detection large model according to the pseudo label satisfying the preset condition.
3. The training method of claim 2, wherein, the filtering step of the pseudo label satisfying the preset condition comprises: obtaining a confidence preset value; comparing a maximum confidence of the prediction category in the prediction result with the confidence preset value: if the maximum confidence of the prediction category in the prediction result is greater than or equal to the confidence preset value, the pseudo label of the pixel corresponding to the preset result is put into a supervision set, and the pseudo label in the supervision set is the pseudo label satisfying the preset condition.
4. The training method of claim 1, wherein, The loss function of the waterlogging detection large model comprises a labeled waterlogging image loss and an unlabeled waterlogging image loss, and the unlabeled waterlogging image loss comprises a first supervision loss and a second supervision loss; the first supervision loss is used to quantify the error between the weak augmented image and the first strong augmented image and the error between the weak augmented image and the second strong augmented image; and the second supervision loss is used to quantify the error between the first strong augmented image and the second strong augmented image.
5. The training method of claim 3, wherein, The network parameters of the waterlogging detection large model are updated by using the second pseudo label and the third pseudo label.
6. An apparatus for training a waterlogging detection large model, characterized in that, Comprise: An acquisition module is configured to acquire a training data set, the training data set comprising a labeled data set and an unlabeled data set; The labeled data set comprises labeled waterlogging images and mask labels corresponding to the labeled waterlogging images, and the unlabeled data set comprises unlabeled waterlogging images; A construction module is configured to construct a network structure of a waterlogging detection large model; A training module is configured to train the network of the waterlogging detection large model by using the labeled data set and the unlabeled data set, obtain a prediction of the labeled waterlogging images by using the waterlogging detection large model at each time of training, process the unlabeled waterlogging images according to a preset rule to obtain pseudo labels of the unlabeled waterlogging images, calculate a loss function of the waterlogging detection large model by using the prediction of the labeled waterlogging images and the pseudo labels of the unlabeled waterlogging images, optimize the network parameters of the waterlogging detection large model by using the loss function, and obtain a final waterlogging detection large model; The processing of the unlabeled waterlogging images according to the preset rule to obtain the pseudo labels of the unlabeled waterlogging images comprises: processing the unlabeled waterlogging images according to a first preset rule to obtain weak augmented images of the unlabeled waterlogging images; processing the unlabeled waterlogging images according to a second preset rule to obtain first strong augmented images and second strong augmented images of the unlabeled waterlogging images; inputting the weak augmented images into a teacher model, the teacher model outputting a first prediction result, and generating a first pseudo label according to the first prediction result; extracting features of the first strong augmented images to obtain first intermediate features, performing feature-level augmentation processing on the first intermediate features to obtain first target features, and determining a second prediction result according to the first target features; generating a second pseudo label according to the second prediction result; extracting features of the second strong augmented images to obtain second intermediate features, performing feature-level augmentation processing on the second intermediate features to obtain second target features, and determining a third prediction result according to the second target features; generating a third pseudo label according to the third prediction result; Utilizing binary dropout masks respectively on the first intermediate feature and the second intermediate feature complementary channel dropout, the expression of which is: ; wherein, denotes a Hadamard product, denotes that the value on the left is updated by the operation on the right, denotes a multiplication operation; The loss function of the waterlogging detection large model comprises a labeled waterlogging image loss and an unlabeled waterlogging image loss; The expression of the unlabeled waterlogging image loss is ; wherein, denotes the number of unlabeled waterlogging images, denotes the index of the unlabeled waterlogging image, denotes the maximum confidence in the prediction category corresponding to the first prediction result; denotes a first confidence preset value, denotes a second confidence preset value, denotes 1 when the condition in the parentheses is met. represents a second prediction result, represents a third prediction result, represents a first pseudo label, represents a second pseudo label, represents a third pseudo label, represents a cross-entropy loss.
7. A waterlogging detection method characterized by, Comprise: Acquire a waterlogging image to be processed; input the waterlogging image into the final waterlogging detection large model trained by the waterlogging detection large model training method in any one of claims 1 to 5 to obtain a waterlogging detection result.
8. An electronic device, comprising: The electronic device comprises: at least one processor (10); and a memory (11) connected in communication with the at least one processor (10); The memory (11) stores a computer program which can be executed by the at least one processor (10). The computer program is executed by the at least one processor (10) to enable the at least one processor (10) to perform the method according to claim 1 or 2 or 3 or 4 or 5 or 7.
Citation Information
Patent Citations
Semi-supervised semantic segmentation method guided by high-density representative prototype
CN117437426A