Image similarity judgment method for GUI (Graphical User Interface) test heterogeneous scene
Image features are extracted through the VGG-16 twin network and the feature-enhanced attention module, combined with the text recognition algorithm, to solve the accuracy problem of image similarity judgment in GUI test heterogeneous scenes, and realize the accuracy of image similarity judgment under rotation, scaling, font changes, etc. Highly accurate judgment.
Patent Information
- Application Number
- CN202410699974.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Existing image similarity judgment methods cannot effectively handle the rotation, scaling, font changes and color changes of images in heterogeneous GUI testing scenarios, and cannot eliminate the interference of characters, grids, icons and other elements, which affects the accuracy of judgment.
The VGG-16 twin network is used to extract the key features of the image, and is enhanced through the feature enhancement attention module. The image similarity score is calculated by combining the absolute difference function and the linear layer. The text information is extracted and the text similarity score is calculated through the string matching algorithm. Finally, it is weighted. The comprehensive similarity score is obtained by summing, and the cross-entropy loss function is used for model training.
When the image undergoes rotation, scaling, font transformation, offset, and color change, the accuracy and accuracy of image similarity judgment are guaranteed, and the reliability and user experience of GUI testing are improved.
Smart Images

Figure CN118692091A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image similarity judgment, and in particular to an image similarity judgment method for GUI testing heterogeneous scenes. Background Art
[0002] In software testing, image similarity judgment in GUI (Graphical User Interface) heterogeneous scenes is an important content. By designing an applicable image similarity calculation method, the efficiency and quality of GUI testing can be improved, and accurate and comprehensive results and decision-making basis can be provided to testers. In GUI heterogeneous scenes, image differences on different platforms, devices and environments will affect the accuracy and efficiency of testing, so accurate image similarity judgment can help discover interface differences and identify potential problems and defects. By optimizing the image similarity calculation method, the test speed can be accelerated, and the reliability and user experience of the test can be improved.
[0003] Existing methods for judging image similarity can be divided into two types, namely traditional similarity algorithms and similarity algorithms based on deep neural networks. Traditional algorithms for calculating image similarity include pixel-by-pixel comparison algorithms, histogram comparison methods, SSIM algorithms, hash algorithms, etc. As the name implies, the pixel-by-pixel comparison method is a method that compares the corresponding pixel values in two images in sequence. The histogram comparison method converts the two images to be compared into corresponding histogram data, and then normalizes the histogram data for comparison, and finally obtains a similarity index. By setting the boundary of the similarity index, the degree of similarity of the images can be judged. The SSIM algorithm attempts to simulate the characteristics of the human visual perception system and mainly works by measuring the brightness, contrast and structural similarity of the two images. Hash algorithms, such as average hashing and perceptual hashing, convert images into a string of numbers (hash values) and measure the similarity of images by comparing the differences in hash values. With the development of deep learning, research on image similarity based on deep neural networks has also gradually emerged. The twin network uses a two-branch deep neural network to model image features, inputs image pair data, extracts key image features from them, and then uses cosine similarity to determine whether the feature vectors are similar. For a three-branch deep neural network, the input data contains multiple images, and the training goal is to make the distance between the same categories as small as possible and the distance between different categories as large as possible.
[0004] In GUI testing heterogeneous scenarios, images vary widely, including minor changes such as rotation, scaling, fonts, as well as changes such as offset and color, which will affect the similarity judgment of images. Existing image similarity judgment methods cannot solve this technical problem well. In addition, images in GUI testing heterogeneous scenarios often contain elements such as characters, grids, and icons. Existing image similarity judgment methods cannot eliminate the interference of the above elements. Summary of the invention
[0005] In order to solve the above technical problems existing in the prior art, the present invention proposes an image similarity judgment method for GUI testing heterogeneous scenes.
[0006] The method specifically comprises the following steps:
[0007] Step S1: Collect images of GUI test heterogeneous scenes and classify and annotate them;
[0008] Step S2: Two VGG (Visual Geometry Group)-16 networks are used as twin networks to extract key features of image x1 and image x2 respectively;
[0009] Step S3: Enhance key features through feature enhancement attention module;
[0010] Step S4: Obtain the image similarity scores of image x1 and image x2 through absolute difference function and linear layer calculation;
[0011] P i =Linear(Abs(x1,x2));
[0012] Where Abs(·) means calculating the absolute value of the difference between two eigenvectors, and Linear means the linear layer;
[0013] Step S5: extract the text in the image and calculate the text similarity score between image x1 and image x2 through a string matching algorithm;
[0014] Step S6: performing weighted summation of the image similarity score and the text similarity score to obtain a comprehensive similarity score;
[0015] If the comprehensive similarity score is less than a preset value, it is determined that image x1 and image x2 are not similar, otherwise it is determined that image x1 and image x2 are similar.
[0016] Preferably, the VGG-16 network includes a Stem layer and several CBR layers;
[0017] The Stem layer is used to adjust the size and number of channels of the image;
[0018] The CBR layer includes convolutional layer, BatchNorm layer and ReLU layer, which are used to extract key features of the image;
[0019] The image is input into the two VGG-16 networks in the twin network to obtain the feature vectors of the two key features.
[0020] Preferably, step S3 comprises:
[0021] The key features are input into the feature enhancement attention module, the feature vectors are normalized and self-attention processed in turn, the result is residually connected with the feature vector, the result of the residual connection is normalized and then input into the multilayer perceptron, and finally the output of the multilayer perceptron is residually connected with the result of the residual connection.
[0022] Preferably, step S5 comprises:
[0023] Extract text T1 and text T2 from image x1 and image x2 respectively,
[0024]
[0025] In the formula, to is the m characters contained in the text T1, to The n characters contained in the text T2;
[0026] Through the string matching algorithm, the number of identical characters C in text T1 and text T2 is obtained.
[0027] C = Find(T1, T2);
[0028] Calculate the text similarity score of image x1 and image x2,
[0029]
[0030] Where V is the text similarity score.
[0031] Preferably, step S6 comprises:
[0032] The weighted sum of the image similarity score and the text similarity score is calculated.
[0033] MixScore = P i ×RI+V×RO;
[0034] In the formula, MixScore is the comprehensive similarity score, RI is the image similarity score weight, and RO is the text similarity score weight;
[0035] If the comprehensive similarity score MixScore is less than a preset value, it is determined that image x1 and image x2 are not similar; otherwise, it is determined that image x1 and image x2 are similar.
[0036] Furthermore, it also includes the evaluation and training methods of image similarity scores:
[0037] Based on the cross entropy loss function L, multiple image pairs are used to evaluate the image similarity scores.
[0038]
[0039] Where N is the total number of image pairs involved in calculating the loss, i is the ordinal number of the image pair, and y i is the true label of the i-th pair of images;
[0040] Among them, if y i = 0, then the image pair is not similar; if y i =1, then the image pairs are similar;
[0041] Iterate multiple times until the cross entropy loss function L converges or reaches the preset number of iterations.
[0042] The technical solution provided by the present invention can ensure the accuracy and precision of image similarity judgment when the image undergoes changes such as rotation, scaling, font change, offset, and color. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the overall model structure of VGG-16 and feature-enhanced attention module in the present invention.
[0044] Figure 2 Detailed architecture diagram of the feature enhanced attention module of the present invention. DETAILED DESCRIPTION
[0045] To meet the image similarity analysis requirements for GUI testing heterogeneous scenarios, the following aspects need to be considered:
[0046] (1) In real-world scenarios where GUI testing is heterogeneous, the image changes span a wide range, including small changes such as rotation, scaling, and fonts, as well as large changes such as offset and color. New methods need to be developed to deal with these changes.
[0047] (2) Due to the diversity of images in GUI testing heterogeneous scenarios, calculating similarity only from the image perspective may not provide sufficient accuracy, and it is necessary to add multi-dimensional considerations. Based on the above requirements, the judgment method can be further improved to improve the accuracy and applicability in GUI testing heterogeneous scenarios.
[0048] Hereinafter, the inventive concept and principle of the present invention will be further elaborated in detail with reference to the accompanying drawings.
[0049] The present invention proposes an image similarity judgment method for GUI testing heterogeneous scenes. First, VGG-16 is used as the backbone network of the twin network to extract the key features of the two images to be compared, and then the feature enhancement attention module designed by the present invention is used to semantically enrich and enhance the extracted image features, and finally an image similarity score of the two images is obtained; then OCR is used to identify the text contained in the two images, and the number of identical characters is obtained using a set function, and then a similarity ratio score is obtained as the text similarity score of the two images. Finally, the image and text scores are weightedly added to obtain a comprehensive similarity judgment score, so that the model has better robustness and can enable the model to handle the similarity comparison of highly complex graphic pairs with both complex graphics and complex text.
[0050] The proposed method is evaluated on the collected dataset and performs well compared with most of the traditional graph similarity comparison algorithms with higher accuracy and less time compared to other methods.
[0051] Step 1: Collect the corresponding data set from the corresponding software, and perform data expansion and preprocessing on the data set.
[0052] The specific implementation of data expansion and preprocessing of the training set is as follows:
[0053] The data set involved in the present invention includes three major categories, namely, only text, only graphics, and both text and graphics. It can also be further divided into a set of single images and a set of two similar images. The set of two similar images has 405 pairs, that is, a total of 810 images; the set of single images has 306 images. The maximum resolution of the image is 860x523 pixels, and the minimum resolution of the image is 8x35 pixels. Since the data that can be collected by the software itself is limited, we also used cropping on all images for data expansion. For each image, four cropped images were obtained, which are from the upper left corner, upper right corner, lower left corner and lower right corner of the original image, and the starting point of cropping is one twenty-fifth of the length and width of the image.
[0054] Finally, data augmentation is performed on all images, including:
[0055] Randomly invert and set the random factor to 0.5; transform the color gamut of the image; add gray bars to the redundant parts of the image; pad the image; and finally adjust the resolution of all images to 105x105 pixels for training.
[0056] Finally, we get 1472 images, a total of 300 sets, each set represents a category. The images in the same set belong to the same category, that is, a pair of similar images, and the two images in different sets belong to different categories, that is, they are not similar. Finally, the ratio of the training set and the validation set of the dataset is set to 9:1, that is, there are 1324 pairs of images for training and 148 pairs of images for validation.
[0057] Step 2: The specific implementation of using the Siamese network to extract key features of the GUI image is as follows:
[0058] 1) Use the Stem layer and several CBR layers to build a backbone network VGG-16 for extracting key features of images. The Stem layer is used to adjust the size and number of channels of the input feature map. Each CBR layer consists of a convolutional layer, a BatchNorm layer, and a ReLU layer to complete the extraction of key features of the image. The network structure of the backbone network VGG-16 is as follows: Figure 1 As shown in Figure 2, the key features include the contour features, color features, and texture features of the image.
[0059] 2) The twin network for input GUI image feature extraction is defined as:
[0060] Network Siamese ;
[0061] Among them, the twin network Network Siamese The two backbone networks VGG-16 used are and
[0062] 3) Define the GUI image input to the twin network as x, and input it into the two backbone networks of the twin network to obtain two image key features f respectively 1 and f 2 , expressed as follows:
[0063] f 1 , f 2 =Network Siamese (x).
[0064] Step 3: If Figure 2 As shown, two feature enhancement attention modules are introduced to semantically enrich and enhance the extracted image features.
[0065] For the image feature vectors extracted by the VGG-16 backbone network, layer normalization is first performed to ensure the scale consistency. Subsequently, the self-attention mechanism is used to model the relationship between these feature vectors to obtain a more refined feature representation. The result obtained in this process is residually connected with the original feature vector to retain the original information. Subsequently, the residual result is layer normalized again to further improve the stability of the feature. Next, this result is input into a multi-layer perceptron to introduce nonlinear transformations and capture higher-level semantic information. Finally, the output of the multi-layer perceptron is residually connected with the original residual result again to obtain a richer and higher-quality feature representation.
[0066] Step 4: Calculate the image similarity score P of image x1 and image x2 through the absolute difference function and linear layer i ;
[0067] P i =Linear(Abs(x1,x2));
[0068] Where Abs(·) means calculating the absolute value of the difference between two eigenvectors, and Linear means the linear layer.
[0069] The cross entropy loss function is used to perform supervised learning on feature similarity and obtain the similarity scores of the images.
[0070] The cross entropy loss function is used for supervised learning of feature similarity. In order to compare the similarity between the feature vectors of two images, a set of sample pairs are first defined, where each sample pair consists of two images and their similarity labels, and the similarity labels are binary (similar / dissimilar). Then, these sample pairs are used to train the model. For each sample pair, the two images are passed through the backbone network and the feature enhancement module to extract the feature vectors, and then the similarity is calculated using the cross entropy loss function, and the network parameters are updated by back-propagating the gradient. By minimizing the cross entropy loss, the model can be trained to better fit the actual feature similarity.
[0071] Specifically, based on the cross entropy loss function L, multiple image pairs are used to evaluate the image similarity scores.
[0072]
[0073] Where N is the total number of image pairs involved in calculating the loss, i is the ordinal number of the image pair, and y i is the true label of the i-th pair of images;
[0074] Among them, if y i = 0, then the image pair is not similar; if y i =1, then the image pairs are similar;
[0075] Iterate multiple times until the cross entropy loss function L converges or reaches the preset number of iterations.
[0076] Step 5: Use OCR (Optical Character Recognition) technology to determine the similarity of GUI images. The specific process is as follows:
[0077] 1) Define a pair of GUI images for similarity comparison as x1 and x2, and use open source text recognition technology to extract text information T1 and T2 from x1 and x2 respectively, which can be expressed as follows:
[0078] T1,T2=OCR(x1,x2);
[0079] OCR refers to the open source Baidu text recognition technology, which is used to extract text information of the GUI image to be compared after local deployment.
[0080] 2) The characters contained in the text information T1 and T2 extracted by OCR technology are defined as follows:
[0081]
[0082] in, is a character contained in T1, is a character contained in T2, m is the number of characters in T1, n is the number of characters in T2, a=1,2,...,m, b=1,2,...,n;
[0083] 3) According to the characters contained in T1 and T2, the number of identical characters in T1 and T2 is obtained by character matching.
[0084] C = Find(T1, T2);
[0085] Calculate the text similarity score V between image x1 and image x2, where V is calculated as follows:
[0086]
[0087] If V ≥ 0.99, then the text T1 and the text T2 are judged to be similar, otherwise they are not similar; wherein Find is a function for finding the number C of identical characters between the two texts T1 and T2. Of course, the judgment value can be adaptively adjusted according to the actual situation.
[0088] Optionally, it is also possible to determine whether the texts of image x1 and image x2 are similar by comparing the number of identical words with a preset number.
[0089] U = max(m,n) × k;
[0090] In the formula, U is the preset similarity number, and k is the preset text similarity ratio coefficient. Generally speaking, k is 0.99.
[0091] Step 6: Perform weighted summation of the image similarity score and the text similarity score to obtain the final similarity evaluation result. The specific implementation steps are as follows:
[0092] Perform a weighted sum based on the text similarity score obtained in step 5 and the image similarity score obtained in step 4. The weight ratio can be set according to the proportion of text in the data set. If the number of texts is 70%, the text similarity score weight is set to 0.7, and the image similarity score weight is set to 0.3. Finally, these two scores are multiplied by their respective weights and added to form the final similarity score. The specific process is shown in the formula:
[0093] MixScore = P i ×RI+V×RO;
[0094] Where MixScore is the comprehensive similarity score, RI is the image similarity score weight, and RO is the text similarity score weight.
[0095] Finally, the similarity threshold is set to, that is, if the final similarity score is greater than or equal to the threshold, the model considers the two images similar, and if the final similarity score is less than the threshold, the model considers the two images dissimilar. This threshold can be adjusted according to the actual situation, and is generally set to 0.99.
[0096] The technical solution provided by the present invention can ensure the accuracy and precision of image similarity judgment when the image undergoes changes such as rotation, scaling, font change, offset, and color.
[0097] Furthermore, the feature enhancement attention module semantically enriches and enhances the extracted image features, and can use the self-attention mechanism to model the relationship between feature vectors in GUI heterogeneous data sets, thereby obtaining a more refined feature representation. Combining text recognition OCR and comprehensive image similarity discrimination of deep neural networks, the deep neural network can be used to extract the features of the two images and give the similarity score at the image level, and then use OCR to identify the text contained in the two images, and use the set function to get the number of identical characters, and then get the similarity ratio score as the text similarity score of the two images. Finally, the image and text scores are weightedly added to get the comprehensive similarity discrimination score. This makes the model more robust and enables the model to handle the similarity comparison of highly complex images with both complex graphics and complex text.
Claims
1. A method for determining image similarity in GUI testing heterogeneous scenes, characterized in that: The following steps are involved: Step S1: Collect images of GUI test heterogeneous scenes and classify and annotate them; Step S2: Use two VGG-16 networks as twin networks to extract key features of image x1 and image x2 respectively; Step S3: Enhance key features through feature enhancement attention module; Step S4: Obtain the image similarity scores of image x1 and image x2 through absolute difference function and linear layer calculation; P i =Linear(Abs(x1,x2)); Where Abs(·) means calculating the absolute value of the difference between two eigenvectors, and Linear means the linear layer; Step S5: extract the text in the image and calculate the text similarity score between image x1 and image x2 through a string matching algorithm; Step S6: performing weighted summation of the image similarity score and the text similarity score to obtain a comprehensive similarity score; If the comprehensive similarity score is less than a preset value, it is determined that image x1 and image x2 are not similar, otherwise it is determined that image x1 and image x2 are similar.
2. The image similarity determination method for GUI testing heterogeneous scenes as claimed in claim 1, characterized in that: The VGG-16 network includes a Stem layer and several CBR layers; The Stem layer is used to adjust the size and number of channels of the image; The CBR layer includes convolutional layer, BatchNorm layer and ReLU layer, which are used to extract key features of the image; The image is input into the two VGG-16 networks in the twin network to obtain the feature vectors of the two key features.
3. The image similarity determination method for GUI testing heterogeneous scenes as claimed in claim 1, characterized in that: Step S3 includes: The key features are input into the feature enhancement attention module, the feature vectors are normalized and self-attention processed in turn, the result is residually connected with the feature vector, the result of the residual connection is normalized and then input into the multilayer perceptron, and finally the output of the multilayer perceptron is residually connected with the result of the residual connection.
4. The image similarity determination method for GUI testing heterogeneous scenes as claimed in claim 1, characterized in that: Step S5 includes: Extract text T1 and text T2 from image x1 and image x2 respectively, In the formula, to is the m characters contained in the text T1, to The n characters contained in the text T2; Through the string matching algorithm, the number of identical characters C in text T1 and text T2 is obtained. C = Find(T1, T2); Calculate the text similarity score of image x1 and image x2, Where V is the text similarity score.
5. The image similarity determination method for GUI testing heterogeneous scenes as claimed in claim 1, characterized in that: Step S6 includes: The weighted sum of the image similarity score and the text similarity score is calculated. MixScore=P i ×RI+V×RO; In the formula, MixScore is the comprehensive similarity score, RI is the image similarity score weight, and RO is the text similarity score weight; If the comprehensive similarity score MixScore is less than a preset value, it is determined that image x1 and image x2 are not similar; otherwise, it is determined that image x1 and image x2 are similar.
6. The method for determining image similarity of heterogeneous scenes in a GUI test according to claim 1, characterized in that: Also included is a training method for evaluating image similarity scores: Based on the cross entropy loss function L, multiple image pairs are used to evaluate the image similarity scores. Where N is the total number of image pairs involved in calculating the loss, i is the ordinal number of the image pair, and y i is the true label of the i-th pair of images; Among them, if y i = 0, the image pair is not similar; if y i =1, then the image pairs are similar; Iterate multiple times until the cross entropy loss function L converges or reaches the preset number of iterations.
Citation Information
Patent Citations
Remote sensing image small sample scene classification method based on multi-scale double-flow architecture
CN115311502A
Remote sensing image change detection system based on collaborative similarity learning
CN117994652A
Progressive verification system and methods
US20210279505A1
