Search

CN-121982373-A - Training method of image anomaly detection model, anomaly detection method of image and related equipment

CN121982373ACN 121982373 ACN121982373 ACN 121982373ACN-121982373-A

Abstract

The embodiment of the application discloses a training method of an image anomaly detection model, an image anomaly detection method and related equipment, and belongs to the technical field of image anomaly detection. The method comprises the steps of inputting a sample image and an abnormal type detection prompt word into an image abnormal detection model, outputting a first detection type of the sample image, obtaining an updated image abnormal detection model according to the first detection type, inputting the sample image and an abnormal area detection prompt word into the updated image abnormal detection model, determining target differences according to the detection areas of the output sample image and second detection types corresponding to the detection areas, obtaining a re-updated image abnormal detection model according to the target differences, and iteratively updating the image abnormal detection model until the target differences meet target preset difference conditions, so as to obtain a trained image abnormal detection model. The trained model can accurately detect the abnormal region in the image.

Inventors

  • WU ZEBIN
  • YANG FEIDIAO
  • TIAN YONGHONG

Assignees

  • 鹏城实验室

Dates

Publication Date
20260505
Application Date
20251226

Claims (11)

  1. 1. The training method of the image anomaly detection model is characterized by comprising the following steps of: Acquiring a sample image, a label area of the sample image and a label category corresponding to the label area; generating an abnormal region detection prompt word according to the tag region, and generating an abnormal category detection prompt word according to the tag category; Inputting the sample image and the abnormality category detection prompt word into an image abnormality detection model, outputting a first detection category of the sample image, and updating the image abnormality detection model according to a first category difference between the first detection category and the tag category to obtain an updated image abnormality detection model; inputting the sample image and the abnormal region detection prompt word into the updated image abnormal detection model, and outputting a detection region of the sample image and a second detection category corresponding to the detection region; Determining target differences of the updated image anomaly detection model according to the detection region, the label region, the second detection category and the label category, and updating the updated image anomaly detection model again according to the target differences to obtain a re-updated image anomaly detection model; And when the target difference does not meet the preset target difference condition, returning to the step of inputting the sample image and the abnormal category detection prompt word into an image abnormal detection model and outputting the first detection category of the sample image until the target difference meets the target preset difference condition, and obtaining the trained image abnormal detection model.
  2. 2. The training method of the image anomaly detection model according to claim 1, wherein the acquiring a sample image, a tag region of the sample image, and a tag class corresponding to the tag region, comprises: Acquiring a plurality of initial abnormal data and a plurality of initial non-abnormal data, wherein each initial abnormal data comprises an initial abnormal image, a label abnormal region corresponding to the initial abnormal image and an initial abnormal category corresponding to the label abnormal region, and each initial non-abnormal data comprises an initial non-abnormal image, a label non-abnormal region corresponding to the initial non-abnormal image and an initial non-abnormal category corresponding to the label non-abnormal region; Determining a label abnormality category corresponding to the label abnormality area according to the initial abnormality category corresponding to the label abnormality area for each label abnormality area corresponding to the initial abnormality image, and updating the corresponding initial abnormality data according to the label abnormality category to obtain updated initial abnormality data; Determining a label non-abnormal category corresponding to the label non-abnormal area according to the label non-abnormal area corresponding to the label non-abnormal area, and updating the corresponding initial non-abnormal data according to the label non-abnormal category to obtain updated initial non-abnormal data; Generating a target data set containing a plurality of initial data according to a plurality of updated initial abnormal data and a plurality of updated initial non-abnormal data, and determining a sample image, a label area of the sample image and a label category corresponding to the label area according to at least part of the initial data in the target data set.
  3. 3. The training method of the image anomaly detection model according to claim 2, wherein the determining the label anomaly category corresponding to the label anomaly region according to the initial anomaly category corresponding to the label anomaly region includes: When the initial abnormal category comprises a plurality of lemmas, merging the lemmas to obtain a target lemma; And taking the target word element as a label category corresponding to the label area.
  4. 4. The training method of the image anomaly detection model according to claim 2, further comprising, after the determining the label anomaly category corresponding to the label anomaly region according to the initial anomaly category corresponding to the label anomaly region: acquiring an initial word list and an initial embedding matrix of an image anomaly detection model; Updating the initial word list according to the label abnormality category corresponding to each initial abnormal image to obtain a target word list, and updating the initial embedding matrix according to the label abnormality category corresponding to each initial abnormal image to obtain a target embedding matrix, so that the image abnormality detection model carries out data processing on input data according to the target word list and the target embedding matrix.
  5. 5. The method according to claim 1, wherein updating the image anomaly detection model according to a first class difference between the first detection class and the tag class to obtain an updated image anomaly detection model comprises: When the first class difference between the first detection class and the label class does not meet a preset initial difference condition, updating the classification prediction network parameters of the image anomaly detection model according to the first class difference to obtain an updated image anomaly detection model; and when the first class difference between the first detection class and the label class meets a preset initial difference condition, freezing the classification prediction network parameter, and taking the image anomaly detection model as an updated image anomaly detection model.
  6. 6. The method according to claim 1, wherein determining the target difference of the updated image anomaly detection model based on the detection region, the tag region, the second detection class, and the tag class comprises: calculating a region difference between the detection region and the tag region, and calculating a second class difference between the second detection class and the tag class; When the first class difference does not meet a preset initial difference condition, determining the target difference of the updated image anomaly detection model in a combined mode according to the region difference and the second class difference; and when the first class difference meets a preset initial difference condition, determining the target difference of the updated image anomaly detection model according to the region difference.
  7. 7. The method according to claim 6, wherein the updating the updated image anomaly detection model according to the target difference to obtain a updated image anomaly detection model comprises: when the first class difference does not meet a preset initial difference condition, adjusting a classification prediction network parameter of the image anomaly detection model and an anomaly region detection network parameter of the image anomaly detection model according to the target difference to obtain a updated image anomaly detection model; and when the first class difference meets a preset initial difference condition, adjusting an abnormal region detection network parameter of the image abnormal detection model according to the target difference to obtain a re-updated image abnormal detection model.
  8. 8. An image anomaly detection method, characterized by being applied to the training method of the image anomaly detection model according to any one of claims 1 to 7, comprising: acquiring a target image to be detected and a target prompt word corresponding to the target image; and inputting the target image and the target prompt word into a trained image anomaly detection model, and outputting a target anomaly region of the target image and a target anomaly category corresponding to the target anomaly region.
  9. 9. An image anomaly detection model training device, comprising: The acquisition module is used for acquiring a sample image, a label area of the sample image and a label category corresponding to the label area; the detection prompt word generation module is used for generating an abnormal region detection prompt word according to the tag region and generating an abnormal category detection prompt word according to the tag category; The first updating module is used for inputting the sample image and the abnormal category detection prompt word into an image abnormal detection model, outputting a first detection category of the sample image, and updating the image abnormal detection model according to a first category difference between the first detection category and the label category to obtain an updated image abnormal detection model; The abnormal region detection module is used for inputting the sample image and the abnormal region detection prompt word into the updated image abnormal detection model and outputting a detection region of the sample image and a second detection category corresponding to the detection region; The second updating module is used for determining the target difference of the updated image anomaly detection model according to the detection area, the label area, the second detection category and the label category, and updating the updated image anomaly detection model again according to the target difference to obtain a re-updated image anomaly detection model; And the target training module is used for returning to the step of inputting the sample image and the abnormal category detection prompt word into the image abnormal detection model and outputting the first detection category of the sample image until the target difference meets the target preset difference condition, so as to obtain the trained image abnormal detection model.
  10. 10. An electronic device comprising a memory and a processor, the memory storing a computer program, the processor implementing the training method of the image anomaly detection model of any one of claims 1 to 7 or the anomaly detection method of the image of claim 8 when the computer program is executed.
  11. 11. A computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the training method of the image abnormality detection model according to any one of claims 1 to 7 or implements the abnormality detection method of the image according to claim 8.

Description

Training method of image anomaly detection model, anomaly detection method of image and related equipment Technical Field The application relates to the technical field of image anomaly detection, in particular to a training method of an image anomaly detection model, an image anomaly detection method and related equipment. Background In recent years, with the rapid development of artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) technology, the generation efficiency of AI images has been greatly improved, and for example, human body images can be generated by using an artificial intelligence model, but abnormal phenomena such as limb proportion imbalance, joint dislocation, finger or toe loss and the like easily occur in AI images, so that it is necessary to perform abnormality detection on AI images generated by the model to screen out unreasonable images. In the related art, an AI image is abnormal-detected by a visual model such as a target detection model and an abnormality detection result is output. However, the visual model performs abnormality detection based on the image itself only, and some abnormal regions that are contrary to human cognition cannot be detected, so that the pre-training model trained on the visual model based on the AI image only cannot accurately detect some abnormal regions in the AI image. Therefore, there is a technical problem in the related art that abnormality detection in AI images is inaccurate. Disclosure of Invention The embodiment of the application provides a training method of an image anomaly detection model, an image anomaly detection method and related equipment, wherein the trained model can accurately detect an anomaly region in an image. In order to achieve the above object, an aspect of an embodiment of the present application provides a training method for an image anomaly detection model, including: acquiring a sample image, a label area of the sample image and a label category corresponding to the label area; Generating an abnormal region detection prompt word according to the tag region, and generating an abnormal category detection prompt word according to the tag category; Inputting the sample image and the abnormal category detection prompt word into an image abnormal detection model, outputting a first detection category of the sample image, and updating the image abnormal detection model according to a first category difference between the first detection category and the label category to obtain an updated image abnormal detection model; Inputting the sample image and the abnormal region detection prompt word into the updated image abnormal detection model, and outputting a detection region of the sample image and a second detection category corresponding to the detection region; Determining target differences of the updated image anomaly detection model according to the detection area, the label area, the second detection category and the label category, and updating the updated image anomaly detection model again according to the target differences to obtain a re-updated image anomaly detection model; And when the target difference does not meet the preset target difference condition, returning to execute the step of inputting the sample image and the abnormal category detection prompt word into the image abnormal detection model and outputting the first detection category of the sample image until the target difference meets the target preset difference condition, so as to obtain the trained image abnormal detection model. In some embodiments, acquiring a sample image, a label region of the sample image, and a label category corresponding to the label region, includes: Acquiring a plurality of initial abnormal data and a plurality of initial non-abnormal data, wherein each initial abnormal data comprises an initial abnormal image, a label abnormal region corresponding to the initial abnormal image and an initial abnormal category corresponding to the label abnormal region, and each initial non-abnormal data comprises an initial non-abnormal image, a label non-abnormal region corresponding to the initial non-abnormal image and an initial non-abnormal category corresponding to the label non-abnormal region; For the label abnormal region corresponding to each initial abnormal image, determining the label abnormal category corresponding to the label abnormal region according to the initial abnormal category corresponding to the label abnormal region, and updating the corresponding initial abnormal data according to the label abnormal category to obtain updated initial abnormal data; Determining the label non-abnormal type corresponding to the label non-abnormal region according to the label non-abnormal type corresponding to the label non-abnormal region aiming at the label non-abnormal region corresponding to each initial non-abnormal image, and updating the corresponding initial non-abnormal data according to the label non-abnormal type to ob