Image detection method and device
By blocking and abnormal detection of target images, the problem of difficulty in capturing small abnormalities on the product surface is solved by traditional methods, and high-precision and high-efficiency abnormal detection is achieved, improving product quality.
Patent Information
- Application Number
- CN202310977129.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
Traditional image anomaly detection algorithms are difficult to capture small abnormalities on the product surface, resulting in detection failure and affecting product quality.
By tiling the target image, multiple target image blocks are obtained and abnormality detection is performed based on these image blocks. This method can focus on more details, improve detection accuracy, and reduce the calculation amount through blocks and improve detection efficiency.
It improves the accuracy and efficiency of abnormal detection, can more accurately capture small abnormalities on the product surface, and effectively improves product quality.
Smart Images

Figure CN119444647A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a method and device for image detection. Background Art
[0002] Industrial anomaly detection is crucial to controlling the quality of products. With the advancement of computer technology, images are widely used in various industries. Machine learning models can be trained to detect whether images are abnormal. In this case, image anomaly detection can be used to determine the abnormality of the product.
[0003] However, sensors on the production line generally collect large-scale, high-resolution image data. Using traditional image anomaly detection algorithms may not be able to capture smaller anomalies on the product surface, resulting in detection failure. Summary of the invention
[0004] The embodiments of the present application provide a method and device for image detection, which can achieve the purpose of abnormality detection with high detection accuracy.
[0005] In a first aspect, a method for image detection is provided, the method comprising: acquiring a target image; dividing the target image into blocks to obtain a plurality of target image blocks; and performing anomaly detection on the target image based on the plurality of target image blocks.
[0006] In the embodiment of the present application, after acquiring the target image, the target image is divided into blocks and based on the multiple target image blocks obtained after the division, the target image is subjected to abnormality detection. In this way, more details can be paid attention to during the abnormality detection process, thereby improving the accuracy of abnormality detection and effectively improving product quality. Furthermore, the target image is divided into multiple target image blocks, so that for each target image block, the amount of calculation is greatly reduced, so that the purpose of abnormality detection can be quickly achieved, and the detection efficiency is improved.
[0007] In some possible implementations, at least two target image blocks among the multiple target image blocks overlap.
[0008] In the above technical solution, at least two target image blocks among the multiple target image blocks overlap, so that the abnormality of the edge of the divided target image blocks can be detected, thereby further improving the detection accuracy.
[0009] In some possible implementations, performing anomaly detection on the target image based on the multiple target image blocks includes: determining an abnormal image block among the multiple target image blocks; and performing anomaly detection on the target image block based on the abnormal image block.
[0010] In the above technical solution, since anomaly detection is performed on the target image block, an abnormal image block is determined among multiple target image blocks, and the target image block is detected based on the abnormal image block, so that anomaly detection can be performed more easily, thereby effectively improving detection efficiency.
[0011] In some possible implementations, determining the abnormal image block among the multiple target image blocks includes: inputting each target image block among the multiple target image blocks into a first model to obtain abnormal information of each target image block, wherein the first model is trained by sample image blocks and abnormal information; and determining the abnormal image block according to the abnormal information of each target image block.
[0012] In the above technical solution, since the number of sample training is generally large, the first model obtained by training the sample image blocks and abnormal information generally conforms to the abnormal information distribution, so the accuracy of determining abnormal image blocks based on the first model is relatively high.
[0013] In some possible implementations, the abnormal information includes an abnormality score, and determining the abnormal image block according to the abnormal information of each target image block includes: determining an abnormality score threshold according to a first sample and / or a second sample, the first sample including a normal sample in the image samples, and the second sample including an abnormal sample in the image samples; and determining the target image block having the abnormality score greater than or equal to the abnormality score threshold as the abnormal image block.
[0014] The above technical solution determines the abnormal score threshold according to the first sample and / or the second sample, and then determines the target image block with an abnormal score greater than or equal to the abnormal score threshold as an abnormal image block, which is not only simple to implement but also convenient to operate.
[0015] In some possible implementations, the first model is a memory-based model.
[0016] The above technical solution sets the first model as a memory-based model, so that fewer training samples are required, which can not only enhance the generalization ability of the first model but also improve the training efficiency.
[0017] In some possible implementations, performing abnormality detection on the target image block according to the abnormal image blocks includes: determining the abnormality type of each abnormal image block in the abnormal image blocks; and performing abnormality detection on the target image block based on the abnormality type of each abnormal image block.
[0018] The above technical solution classifies abnormal image blocks and performs abnormality detection on target image blocks based on the abnormality type of each abnormal image block, thereby further improving the accuracy of abnormality detection on target image blocks.
[0019] In some possible implementations, determining the abnormal type of each abnormal image block in the abnormal image blocks includes: determining the abnormal type of each abnormal image block according to each abnormal image block and a second model, wherein the second model is trained by abnormal image block samples and abnormal type samples.
[0020] In the above technical solution, since the number of sample training is generally large, the second model obtained by training the abnormal image block samples and the abnormal type samples conforms to the distribution of abnormal types as a whole, so the accuracy of the abnormal type of each abnormal image block determined based on the second model is high.
[0021] In some possible implementations, the method further includes: determining whether each abnormal image block is an abnormal block.
[0022] The above technical solution, after determining the abnormal image block among multiple target image blocks, determines again whether the previously determined abnormal image block is an abnormal block, thereby improving the reliability of abnormality detection and effectively reducing the probability of misjudging a normal block as an abnormal block.
[0023] In some possible implementations, the second model is trained by the abnormal image block samples, the abnormal type samples and the normal type samples, and the determining whether each abnormal image block is an abnormal block includes: inputting each abnormal image block into the second model respectively to determine whether each abnormal image block is the abnormal block.
[0024] In the above technical solution, since the number of sample training is generally relatively large, the second model obtained by training the abnormal image block samples, abnormal type samples and normal type samples conforms to the distribution of abnormal blocks as a whole. In this way, the accuracy of determining whether each abnormal image block is an abnormal block based on the second model is relatively high.
[0025] In some possible implementations, the performing abnormality detection on the target image block based on the abnormality type of each abnormal image block includes: integrating the abnormality type of each abnormal image block to obtain a target probability of the target image, wherein the target probability includes the probability of the target image under different abnormality types.
[0026] Since different image regions may present different anomaly detection results, for example, a sample may only have anomalies in some block regions, while other regions appear normal. Therefore, the above technical solution integrates the anomaly type of each abnormal image block, so that the final anomaly detection result is more accurate.
[0027] In some possible implementations, the abnormality type includes a first abnormality type, the target probability includes the probability of the target image under the first abnormality type, and the integrating the abnormality type of each abnormal image block to obtain the target probability of the target image includes: determining, for the first abnormality type, a first probability that the abnormality type of each abnormal image block is the first abnormality type, the number of the first probabilities being at least one; and averaging the first probabilities to obtain the probability that the abnormality type of the target image block is the first abnormality type.
[0028] The above technical solution determines the probability that the abnormal type of each abnormal image block is the abnormal type for a certain abnormal type, and then takes the average of the obtained probabilities, so as to obtain the probability that the abnormal type of the target image block is the abnormal type. It is not only simple to implement but also easy to operate.
[0029] In some possible implementations, the method further includes: weighting the first probability using the probability that each abnormal image block is a normal image block to obtain the weighted first probability; averaging the first probabilities to obtain the probability that the abnormal type of the target image block is the first abnormal type, including: averaging the weighted first probabilities to obtain the probability that the abnormal type of the target image block is the first abnormal type.
[0030] The above technical solution performs weighting based on the probability that each abnormal image block is a normal image block. In this way, the influence of the probability of the normal image block on the abnormality detection result of the target image can be reduced, thereby further improving the accuracy of abnormality detection on the target image.
[0031] In a second aspect, an image detection device is provided, comprising: an acquisition unit for acquiring a target image; a blocking unit for blocking the target image to obtain a plurality of target image blocks; and a detection unit for performing anomaly detection on the target image based on the plurality of target image blocks.
[0032] In some possible implementations, at least two target image blocks among the multiple target image blocks overlap.
[0033] In some possible implementations, the device further includes: a determination unit, configured to determine an abnormal image block among the multiple target image blocks; and the detection unit is specifically configured to: perform abnormality detection on the target image block based on the abnormal image block.
[0034] In some possible implementations, the determination unit is specifically used to: input each target image block among the multiple target image blocks into a first model to obtain abnormal information of each target image block, wherein the first model is trained by sample image blocks and abnormal information; and determine the abnormal image block according to the abnormal information of each target image block.
[0035] In some possible implementations, the anomaly information includes an anomaly score, and the determining unit is specifically configured to:
[0036] An abnormality score threshold is determined according to the first sample and / or the second sample, wherein the first sample includes normal samples in the image samples, and the second sample includes abnormal samples in the image samples; and the target image block whose abnormality score is greater than or equal to the abnormality score threshold is determined as the abnormal image block.
[0037] In some possible implementations, the first model is a memory-based model.
[0038] In some possible implementations, the determination unit is further used to: determine the abnormality type of each abnormal image block in the abnormal image blocks; and the detection unit is specifically used to: perform abnormality detection on the target image block based on the abnormality type of each abnormal image block.
[0039] In some possible implementations, the determination unit is specifically configured to: determine the abnormal type of each abnormal image block according to each abnormal image block and a second model, wherein the second model is trained by abnormal image block samples and abnormal type samples.
[0040] In some possible implementations, the determining unit is further configured to: determine whether each abnormal image block is an abnormal block.
[0041] In some possible implementations, the second model is trained by the abnormal image block samples, the abnormal type samples and the normal type samples, and the determination unit is specifically used to: input each abnormal image block into the second model respectively to determine whether each abnormal image block is the abnormal block.
[0042] In some possible implementations, the device further includes: an integration unit, configured to integrate the abnormal type of each abnormal image block to obtain a target probability of the target image, wherein the target probability includes probabilities of the target image under different abnormal types.
[0043] In some possible implementations, the abnormality type includes a first abnormality type, the target probability includes the probability of the target image under the first abnormality type, and the determination unit is specifically used to: determine, for the first abnormality type, a first probability that the abnormality type of each abnormal image block is the first abnormality type, and the number of the first probabilities is at least one; the device also includes an averaging unit, which is used to average the first probabilities to obtain the probability that the abnormality type of the target image block is the first abnormality type.
[0044] In some possible implementations, the device further includes: a weighting unit, configured to weight the first probability using the probability that each abnormal image block is a normal image block to obtain the weighted first probability; and the averaging unit is specifically configured to average the weighted first probabilities to obtain the probability that the abnormal type of the target image block is the first abnormal type.
[0045] In some possible implementations, the first model is a memory-based model.
[0046] In a third aspect, an image detection device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call the computer program to execute the method in the above-mentioned first aspect or its various implementation methods.
[0047] In a fourth aspect, a computer-readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the method in the above-mentioned first aspect or its various implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the drawings without paying creative work.
[0049] In the drawings, the drawings are not drawn to scale.
[0050] Figure 1 It is a schematic flow chart of an image detection method according to an embodiment of the present application.
[0051] Figure 2It is a schematic block diagram of an image detection device according to an embodiment of the present application.
[0052] Figure 3 It is a schematic block diagram of an image detection device according to an embodiment of the present application. DETAILED DESCRIPTION
[0053] The following detailed description and drawings of the embodiments of the present application are used to illustrate the principles of the present application, but cannot be used to limit the scope of the present application, that is, the present application is not limited to the described embodiments.
[0054] In the description of this application, it should be noted that, unless otherwise specified, "multiple" means more than two; the terms "upper", "lower", "left", "right", "inner", "outer", etc., indicating directions or positional relationships, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting this application. In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0055] Unless otherwise defined, all technical and scientific terms used in this application have the same meanings as those commonly understood by technicians in the technical field of this application; the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned drawings and any variations thereof are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order or a primary and secondary relationship.
[0056] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0057] In the industrial field, anomaly detection, especially anomaly detection for product quality inspection, covers almost all industrial production and manufacturing fields, such as semiconductors, automobiles, packaging and printing, etc. Industrial anomaly detection is crucial to controlling product quality. Traditional anomaly detection requires a large number of inspectors to perform manual inspections, which greatly increases production costs. At the same time, the accuracy of manual inspections depends on the technical level of the inspectors, which undoubtedly increases the uncertainty in anomaly detection.
[0058] With the advancement of computer technology, images are widely used in various industries. Machine learning models can be trained to detect whether images are abnormal. In this case, image anomaly detection can be used to determine product anomalies. However, sensors on production lines generally collect large-scale, high-resolution image data. Using traditional image anomaly detection algorithms may not be able to capture smaller anomalies on the product surface, resulting in detection failures and affecting product quality.
[0059] Based on this, the embodiment of the present application proposes a method for image detection, which obtains a target image, divides the target image into blocks, obtains multiple target image blocks, and performs abnormality detection on the target image based on the multiple target image blocks. In this way, more details can be paid attention to during the abnormality detection process, thereby improving the accuracy of abnormality detection and effectively improving product quality. Furthermore, the target image is divided into multiple target image blocks, so that for each target image block, the amount of calculation is greatly reduced, so that the purpose of abnormality detection can be quickly achieved and the detection efficiency is improved.
[0060] The technical solutions described in the embodiments of the present application can be applied to but not limited to battery abnormality detection. It should be understood that the battery mentioned in the embodiments of the present application refers to a single physical module including one or more battery cells to provide higher voltage and capacity. Optionally, the battery can be a power battery. In terms of the type of battery, the battery can be a lithium-ion battery, a lithium metal battery, a lead-acid battery, a nickel-cathode battery, a nickel-hydrogen battery, a lithium-sulfur battery, a lithium-air battery or a sodium-ion battery, etc., which is not specifically limited in the embodiments of the present application. In terms of battery scale, the battery in the embodiments of the present application can be a battery cell / battery cell, or a battery module or a battery pack, which is not specifically limited in the embodiments of the present application.
[0061] Figure 1 FIG. 1 is a schematic flow chart of an image detection method 100 according to an embodiment of the present application. Figure 1 As shown, method 100 may include at least part of the following contents.
[0062] S110: Acquire a target image.
[0063] S120: Divide the target image into blocks to obtain a plurality of target image blocks.
[0064] S130, performing abnormality detection on the target image based on the multiple target image blocks.
[0065] In the embodiment of the present application, after acquiring the target image, the target image is divided into blocks and based on the multiple target image blocks obtained after the division, the target image is subjected to abnormality detection. In this way, more details can be paid attention to during the abnormality detection process, thereby improving the accuracy of abnormality detection and effectively improving product quality. Furthermore, the target image is divided into multiple target image blocks, so that for each target image block, the amount of calculation is greatly reduced, so that the purpose of abnormality detection can be quickly achieved, and the detection efficiency is improved.
[0066] Optionally, the target image may be randomly divided into blocks. In this way, at least two of the obtained multiple target image blocks may have different sizes. Alternatively, the target image may be divided into multiple target image blocks of the same size.
[0067] In some embodiments, the target image may be divided into blocks by slicing. For example, for samples with relatively fixed sensor sampling angles and light sources, the target image may be divided into blocks by slicing.
[0068] In order to detect the abnormality of the slice edge, the target image block can be divided into blocks by using overlapping slices, that is, at least two target image blocks among the multiple target image blocks overlap.
[0069] In this technical solution, at least two of the multiple target image blocks overlap, so that abnormalities at the edges of the divided target image blocks can be detected, thereby further improving the detection accuracy.
[0070] Considering that the embodiments of the present application are to perform anomaly detection, therefore, in some embodiments, S130 may specifically include: determining an abnormal image block among multiple target image blocks, and performing anomaly detection on the target image block based on the abnormal image block.
[0071] Since the target image block is subjected to abnormality detection, an abnormal image block is determined among multiple target image blocks, and the target image block is detected based on the abnormal image block, so that the abnormality detection can be performed more easily, thereby effectively improving the detection efficiency.
[0072] Specifically, each target image block among the multiple target image blocks can be input into the first model to obtain abnormal information of each target image block, and then the abnormal image block is determined according to the abnormal information of each target image block. The first model is trained by the sample image blocks and the abnormal information.
[0073] Since the number of sample training is generally large, the first model obtained by training the sample image blocks and abnormal information generally conforms to the abnormal information distribution, so the accuracy of determining abnormal image blocks based on the first model is relatively high.
[0074] Optionally, the first model may be a memory-based model. In this way, fewer training samples are required, which can not only enhance the generalization ability of the first model but also improve the efficiency of training.
[0075] In addition to the memory library, the first model may also be a reconstruction-based model or a comparison-based model, etc.
[0076] Optionally, the abnormal information may include but is not limited to an abnormal score, an abnormal probability, etc. Exemplarily, the abnormal score may be a score ranging from several tens to one hundred.
[0077] In the case where the abnormal information includes an abnormal score, determining the abnormal image block according to the abnormal information of each target image block may include: determining an abnormal score threshold according to the first sample and / or the second sample, and then determining the target image block with an abnormal score greater than or equal to the abnormal score threshold as an abnormal image block.
[0078] This technical solution determines an abnormality score threshold according to the first sample and / or the second sample, and then determines a target image block with an abnormality score greater than or equal to the abnormality score threshold as an abnormal image block. This is not only simple to implement, but also convenient to operate.
[0079] The first sample may include a normal sample in the image sample, and the second sample may include an abnormal sample in the image sample.
[0080] For example, assuming that the first sample includes 3 samples, and the scores of the 3 samples are a1, b1 and c1; the second sample also includes 3 samples, and the scores of the 3 samples are a2, b2 and c2, then the scores of the 3 samples in the first sample can be averaged to obtain d1=(a1+b1+c1) / 3, and the scores of the 3 samples in the second sample can be averaged to obtain d2=(a2+b2+c2) / 3, then the anomaly score threshold can be the average of d1 and d2.
[0081] For another example, if the anomaly score threshold is determined based on the second sample, and the scores of the samples in the second sample are f1, f2, f3 and f4, the minimum value of f1, f2, f3 and f4 can be determined as the anomaly score threshold.
[0082] After the abnormal image block is determined, abnormality detection may be performed on the target image block according to the abnormal image block.
[0083] In some embodiments, the abnormal type of each abnormal image block in the abnormal image blocks may be determined, and based on the abnormal type of each abnormal image block, abnormality detection may be performed on the target image block.
[0084] The above technical solution classifies abnormal image blocks and performs abnormality detection on target image blocks based on the abnormality type of each abnormal image block, thereby further improving the accuracy of abnormality detection on target image blocks.
[0085] Exemplarily, if the object of abnormality detection is a battery, the abnormality type may include whether the battery has scratches, whether there is dirt on the battery, whether the battery has missing corners, whether the battery has extra parts, whether the battery has cracks, etc.
[0086] In the process of determining the abnormal type of each abnormal image block in the abnormal image blocks, as an example, the abnormal type of each abnormal image block can be determined according to each abnormal image block and the second model, wherein the second model is trained by the abnormal image block samples and the abnormal type samples.
[0087] That is to say, each abnormal image block may also be input into the second model, and the output of the second model is the abnormal type of the abnormal image block.
[0088] In this technical solution, since the number of sample training is generally large, the second model obtained by training the abnormal image block samples and the abnormal type samples conforms to the distribution of abnormal types as a whole, so that the accuracy of the abnormal type of each abnormal image block determined based on the second model is high.
[0089] Considering that misjudgment may occur when determining abnormal image blocks, that is, a normal image block may be misjudged as an abnormal image block, and an abnormal image block may be misjudged as a normal image block. Therefore, method 100 may further include: determining whether each abnormal image block is an abnormal block. In other words, determining again whether the abnormal image block determined previously is really an abnormal image block.
[0090] After determining the abnormal image block among multiple target image blocks, it is determined again whether the abnormal image block determined previously is an abnormal block, which improves the reliability of abnormality detection and effectively reduces the probability of misjudging a normal block as an abnormal block.
[0091] As an example, each target image block may be input into the first model again.
[0092] As another example, each target image block may be input again into other models other than the first model, where the other models are trained by sample image blocks and abnormal information different from those used to train the first model.
[0093] As another example, a normal class can be added to the second model, that is, the second model can be trained by abnormal image block samples, abnormal type samples and normal type samples. Then each abnormal image block is input into the second model to determine again whether each abnormal image block is really an abnormal block.
[0094] Then for each abnormal image block, the output of the second model can be:
[0095] (α,β1,β2,…,β n )
[0096] Among them, α is the probability that the abnormal classification block is a normal block, n is the number of abnormal types, β1,β2,…,β n The probability of different anomaly types for the anomaly classification block.
[0097] In the above technical solution, since the number of sample training is generally relatively large, the second model obtained by training the abnormal image block samples, abnormal type samples and normal type samples conforms to the distribution of abnormal blocks as a whole. In this way, the accuracy of determining whether each abnormal image block is an abnormal block based on the second model is relatively high.
[0098] After determining the abnormal type of each abnormal image block, the results of multiple target image blocks can be integrated to obtain the abnormality detection result of the target image. In other words, the abnormal type of each abnormal image block can be integrated to obtain the target probability of the target image, which includes the probability of the target image under different abnormal types.
[0099] Since different image regions may present different anomaly detection results, for example, a sample may only have anomalies in some block regions, while other regions appear normal. Therefore, the above technical solution integrates the anomaly type of each abnormal image block, so that the final anomaly detection result is more accurate.
[0100] In one implementation, the abnormality type may include a first abnormality type, and the target probability may include a probability of the target image under the first abnormality type. At this time, for the first abnormality type, a first probability that the abnormality type of each abnormal image block is the first abnormality type may be determined, and then the first probabilities may be averaged to obtain a probability that the abnormality type of the target image block is the first abnormality type. The number of the first probabilities is at least one.
[0101] For a certain abnormal type, the probability that the abnormal type of each abnormal image block is the abnormal type is determined, and then the obtained probabilities are averaged, so as to obtain the probability that the abnormal type of the target image block is the abnormal type. This method is not only simple to implement, but also easy to operate.
[0102] Furthermore, the output of the second model may be weighted, and then based on the weighted abnormal type of each abnormal image block, the target probability of the target image may be obtained.
[0103] Considering that the probability of a normal image block has a greater impact on the abnormality detection result of the target image, that is, the higher the probability of a normal image block, the less accurate the determination of the abnormal image block may be. Therefore, the weight of the normal image block can be reduced.
[0104] Specifically, the probability that each abnormal image block is a normal image block can be used to weight the first probability to obtain a weighted first probability. At this time, averaging the first probabilities to obtain the probability that the abnormal type of the target image block is the first abnormal type can include: averaging the weighted first probabilities to obtain the probability that the abnormal type of the target image block is the first abnormal type.
[0105] Therefore, the final function can satisfy:
[0106]
[0107] Among them, m is the number of abnormal image blocks, n is the number of abnormal types, j is the number of each abnormal image block, i is the number of each abnormal type, p is i is the probability that the abnormal type of the target image block is the i-th abnormal type, β i is the probability that the abnormal type of the abnormal image block is the i-th abnormal type.
[0108] The above technical solution performs weighting based on the probability that each abnormal image block is a normal image block. In this way, the influence of the probability of the normal image block on the abnormality detection result of the target image can be reduced, thereby further improving the accuracy of abnormality detection on the target image.
[0109] In the embodiments of the present application, the sequence numbers of the above processes do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0110] Furthermore, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in the present application may be arbitrarily combined with each other, and the technical solutions obtained after the combination shall also fall within the protection scope of the present application.
[0111] The above describes in detail the image detection method of the embodiment of the present application, and the following describes the image detection device of the embodiment of the present application. It should be understood that the image detection device of the embodiment of the present application can execute the image detection method of the embodiment of the present application.
[0112] Figure 2FIG. 2 is a schematic block diagram of an image detection device 200 according to an embodiment of the present application. Figure 2 As shown, the image detection device 200 may include:
[0113] The acquisition unit 210 is used to acquire a target image.
[0114] The blocking unit 220 is used to block the target image to obtain a plurality of target image blocks.
[0115] The detection unit 230 is used to perform anomaly detection on the target image based on multiple target image blocks.
[0116] Optionally, in the embodiment of the present application, at least two target image blocks among the multiple target image blocks overlap.
[0117] Optionally, in an embodiment of the present application, the image detection apparatus 200 further includes: a determination unit for determining an abnormal image block among multiple target image blocks; and the detection unit 230 is specifically configured to: perform abnormality detection on the target image block based on the abnormal image block.
[0118] Optionally, in an embodiment of the present application, the determination unit is specifically used to: input each target image block among multiple target image blocks into a first model to obtain abnormal information of each target image block, the first model being trained by sample image blocks and abnormal information; and determine the abnormal image block based on the abnormal information of each target image block.
[0119] Optionally, in an embodiment of the present application, the abnormal information includes an abnormal score, and the determination unit is specifically used to: determine an abnormal score threshold based on the first sample and / or the second sample, the first sample includes a normal sample in the image sample, and the second sample includes an abnormal sample in the image sample; determine a target image block whose abnormal score is greater than or equal to the abnormal score threshold as an abnormal image block.
[0120] Optionally, in an embodiment of the present application, the first model is a memory-based model.
[0121] Optionally, in an embodiment of the present application, the determination unit is further used to: determine the abnormality type of each abnormal image block in the abnormal image blocks; the detection unit 230 is specifically used to: perform abnormality detection on the target image block based on the abnormality type of each abnormal image block.
[0122] Optionally, in an embodiment of the present application, the determination unit is specifically used to: determine the abnormal type of each abnormal image block according to each abnormal image block and the second model, and the second model is trained by abnormal image block samples and abnormal type samples.
[0123] Optionally, in the embodiment of the present application, the determination unit is further used to: determine whether each abnormal image block is an abnormal block.
[0124] Optionally, in an embodiment of the present application, the second model is trained by abnormal image block samples, abnormal type samples and normal type samples, and the determination unit is specifically used to: input each abnormal image block into the second model respectively to determine whether each abnormal image block is an abnormal block.
[0125] Optionally, in the embodiment of the present application, the image detection device 200 further includes: an integration unit, which is used to integrate the abnormal type of each abnormal image block to obtain a target probability of the target image, and the target probability includes the probability of the target image under different abnormal types.
[0126] Optionally, in an embodiment of the present application, the abnormality type includes a first abnormality type, the target probability includes the probability of the target image under the first abnormality type, and the determination unit is specifically used to: for the first abnormality type, determine the first probability that the abnormality type of each abnormal image block is the first abnormality type, and the number of first probabilities is at least one; the image detection device 200 also includes an averaging unit, which is used to average the first probabilities to obtain the probability that the abnormality type of the target image block is the first abnormality type.
[0127] Optionally, in an embodiment of the present application, the image detection device 200 also includes: a weighting unit, used to use the probability that each abnormal image block is a normal image block to weight the first probability to obtain a weighted first probability; the averaging unit is specifically used to: average the weighted first probability to obtain the probability that the abnormal type of the target image block is the first abnormal type.
[0128] It should be understood that the image detection device 200 can implement the corresponding operations in the method 100, which will not be described in detail here for the sake of brevity.
[0129] Figure 3 3 is a hardware structure diagram of an image detection device 300 of an embodiment of the present application. The image detection device 300 includes a memory 301, a processor 302, a communication interface 303 and a bus 304. The memory 301, the processor 302, and the communication interface 303 are connected to each other through the bus 304.
[0130] The memory 301 may be a read-only memory (ROM), a static storage device, and a random access memory (RAM). The memory 301 may store a program. When the program stored in the memory 301 is executed by the processor 302, the processor 302 and the communication interface 303 are used to execute the various steps of the image detection method of the embodiment of the present application.
[0131] The processor 302 can adopt a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the functions that need to be performed by the units in the device of the embodiment of the present application, or to execute the image detection method of the embodiment of the present application.
[0132] The processor 302 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the image detection method of the embodiment of the present application may be completed by an integrated logic circuit of hardware in the processor 302 or by instructions in the form of software.
[0133] The processor 302 may also be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 301, and the processor 302 reads the information in the memory 301, and combines its hardware to complete the functions required to be performed by the units included in the image detection device 300 of the embodiment of the present application, or executes the image detection method of the embodiment of the present application.
[0134] The communication interface 303 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the image detection apparatus 300 and other devices or a communication network.
[0135] The bus 304 may include a path for transmitting information between various components of the apparatus 300 for image detection (eg, the memory 301 , the processor 302 , and the communication interface 303 ).
[0136] It should be noted that although the above-mentioned image detection device 300 only shows a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the image detection device 300 may also include other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the image detection device 300 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the image detection device 300 may also only include the devices necessary to implement the embodiments of the present application, and does not necessarily include Figure 3 All devices shown in .
[0137] The embodiments of the present application also provide a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the methods of the various embodiments of the present application described above.
[0138] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0139] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the above-mentioned image detection method.
[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein, but these modifications or replacements 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 application.
Claims
1. A method for image detection, characterized in that: The method comprises: Get the target image; Dividing the target image into blocks to obtain a plurality of target image blocks; Based on the multiple target image blocks, abnormality detection is performed on the target image.
2. The method according to claim 1, characterized in that At least two target image blocks among the multiple target image blocks overlap.
3. The method according to claim 1 or 2, characterized in that: The performing abnormality detection on the target image based on the multiple target image blocks includes: Determining abnormal image blocks among the multiple target image blocks; According to the abnormal image block, abnormality detection is performed on the target image block.
4. The method according to claim 3, characterized in that The determining of abnormal image blocks among the plurality of target image blocks comprises: Inputting each target image block of the plurality of target image blocks into a first model to obtain abnormal information of each target image block, wherein the first model is trained by the sample image blocks and the abnormal information; The abnormal image block is determined according to the abnormal information of each target image block.
5. The method according to claim 4, characterized in that The abnormal information includes an abnormality score, and determining the abnormal image block according to the abnormal information of each target image block includes: Determine an abnormality score threshold according to a first sample and / or a second sample, wherein the first sample includes a normal sample in the image sample, and the second sample includes an abnormal sample in the image sample; The target image block whose anomaly score is greater than or equal to the anomaly score threshold is determined as the abnormal image block.
6. The method according to claim 4 or 5, characterized in that: The first model is a memory-based model.
7. The method according to any one of claims 3 to 6, characterized in that The performing abnormality detection on the target image block according to the abnormal image block comprises: Determining the abnormal type of each abnormal image block in the abnormal image blocks; Based on the abnormality type of each abnormal image block, abnormality detection is performed on the target image block.
8. The method according to claim 7, characterized in that The determining the abnormality type of each abnormal image block in the abnormal image blocks comprises: The abnormal type of each abnormal image block is determined according to each abnormal image block and a second model, wherein the second model is obtained by training the abnormal image block samples and the abnormal type samples.
9. The method according to claim 8, characterized in that The method further comprises: Determine whether each abnormal image block is an abnormal block.
10. The method according to claim 9, characterized in that The second model is obtained by training the abnormal image block samples, the abnormal type samples and the normal type samples, and the determining whether each abnormal image block is an abnormal block includes: Each abnormal image block is input into the second model respectively to determine whether each abnormal image block is the abnormal block.
11. The method according to any one of claims 7 to 10, characterized in that The performing abnormality detection on the target image block based on the abnormality type of each abnormal image block includes: The abnormal type of each abnormal image block is integrated to obtain a target probability of the target image, where the target probability includes the probability of the target image under different abnormal types.
12. The method according to claim 11, characterized in that The abnormality type includes a first abnormality type, the target probability includes a probability of the target image under the first abnormality type, and integrating the abnormality type of each abnormal image block to obtain the target probability of the target image includes: For the first abnormality type, determining a first probability that the abnormality type of each abnormal image block is the first abnormality type, the number of the first probability is at least one; The first probabilities are averaged to obtain a probability that the abnormality type of the target image block is the first abnormality type.
13. The method according to claim 12, characterized in that The method further comprises: Using the probability that each abnormal image block is a normal image block, weighting the first probability to obtain the weighted first probability; The averaging the first probabilities to obtain the probability that the abnormality type of the target image block is the first abnormality type includes: The weighted first probabilities are averaged to obtain the probability that the abnormality type of the target image block is the first abnormality type.
14. An image detection device, characterized in that: include: An acquisition unit, used for acquiring a target image; A block division unit, used for dividing the target image into blocks to obtain a plurality of target image blocks; A detection unit is used to perform anomaly detection on the target image based on the multiple target image blocks.
15. The device according to claim 14, characterized in that At least two target image blocks among the multiple target image blocks overlap.
16. The device according to claim 14 or 15, characterized in that The device also includes: A determination unit, configured to determine an abnormal image block among the plurality of target image blocks; The detection unit is specifically used for: According to the abnormal image block, abnormality detection is performed on the target image block.
17. The device according to claim 16, characterized in that The determining unit is specifically used for: Inputting each target image block of the plurality of target image blocks into a first model to obtain abnormal information of each target image block, wherein the first model is trained by the sample image blocks and the abnormal information; The abnormal image block is determined according to the abnormal information of each target image block.
18. The device according to claim 17, characterized in that The abnormal information includes an abnormal score, and the determining unit is specifically used for: Determine an abnormality score threshold according to a first sample and / or a second sample, wherein the first sample includes a normal sample in the image sample, and the second sample includes an abnormal sample in the image sample; The target image block whose anomaly score is greater than or equal to the anomaly score threshold is determined as the abnormal image block.
19. The device according to claim 17 or 18, characterized in that The first model is a memory-based model.
20. The device according to any one of claims 16 to 19, characterized in that The determining unit is further configured to: Determining the abnormal type of each abnormal image block in the abnormal image blocks; The detection unit is specifically used for: Based on the abnormality type of each abnormal image block, abnormality detection is performed on the target image block.
21. The device according to claim 20, characterized in that The determining unit is specifically used for: The abnormal type of each abnormal image block is determined according to each abnormal image block and a second model, wherein the second model is obtained by training the abnormal image block samples and the abnormal type samples.
22. The device according to claim 21, characterized in that The determining unit is further configured to: Determine whether each abnormal image block is an abnormal block.
23. The device according to claim 22, characterized in that The second model is obtained by training the abnormal image block samples, the abnormal type samples and the normal type samples, and the determination unit is specifically used for: Each abnormal image block is input into the second model respectively to determine whether each abnormal image block is the abnormal block.
24. The device according to any one of claims 20 to 23, characterized in that The device also includes: The integration unit is used to integrate the abnormal type of each abnormal image block to obtain the target probability of the target image, where the target probability includes the probability of the target image under different abnormal types.
25. The device according to claim 24, characterized in that The abnormality type includes a first abnormality type, the target probability includes a probability of the target image under the first abnormality type, and the determining unit is specifically configured to: For the first abnormality type, determining a first probability that the abnormality type of each abnormal image block is the first abnormality type, the number of the first probability is at least one; The device further includes an averaging unit, configured to average the first probabilities to obtain a probability that the abnormality type of the target image block is the first abnormality type.
26. The device according to claim 25, characterized in that The device also includes: a weighting unit, configured to weight the first probability using the probability that each abnormal image block is a normal image block, to obtain the weighted first probability; The averaging unit is specifically used for: The weighted first probabilities are averaged to obtain the probability that the abnormality type of the target image block is the first abnormality type.
27. An image detection device, characterized in that: include: Memory, used to store programs; A processor, configured to execute a program stored in the memory; when the program stored in the memory is executed, the processor is configured to execute the image detection method according to any one of claims 1 to 13.
28. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program causes a computer to execute the image detection method according to any one of claims 1 to 13.
Citation Information
Cited By
Display content anomaly detection method and system
CN120451686A