A method, device, electronic device and storage medium for identifying page changes

Through the parallel dual-model training method of the target page attention module, the problem of poor page change recognition accuracy is solved, the accuracy and efficiency of APP automated operations are improved, and the burden of content review is reduced.

CN118503571BActive Publication Date: 2024-10-18E SURFING VISION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410954948.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-10-18
Estimated Expiration
2044-07-17

AI Technical Summary

Technical Problem

The accuracy of page change recognition in the existing technology is poor, resulting in the inability of automated APP operations to jump out of the page, resulting in repeated acquisition of information on the same page, and burden on content review.

Method used

Using the parallel dual-model training method of the target page attention module, the model to be tested is obtained by training the page training data, and the page test data is tested according to the test model to obtain the target recognition model, and then through serial single target recognition The model performs page change recognition.

Benefits of technology

It improves the accuracy and efficiency of page change recognition, avoids misjudgments, ensures that automated APP operations can effectively jump out of the page, and reduces the burden of content review.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503571B_ABST
    Figure CN118503571B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, electronic device and storage medium for identifying page changes, wherein the method for identifying page changes includes: obtaining page training data of a mobile device, inputting the page training data into a preset first model to be trained and a second model to be trained respectively for training to obtain a model to be tested; the initialization parameters of the first model to be trained and the second model to be trained are different. Inputting the page test data of the mobile device into the model to be tested to test the model to be tested and obtain a target recognition model; the first model to be trained, the second model to be trained and the model to be trained all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel. Inputting the page to be identified into the target recognition model to identify whether the page has changed. Through the present application, it is helpful to improve the accuracy of page change recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method, device, electronic device and storage medium for identifying page changes. Background Art

[0002] The APP content dialing project is to test hundreds of related APPs to detect whether there is any illegal content on the APP page information. The general process of dialing is to perform automated operations on the APP, then obtain the page text content and screenshots of the page, and finally conduct content audits on the text content and page screenshots through the audit model. Among them, in the APP automated operation, how to judge whether the page has changed before and after a certain operation is crucial. If it is impossible to effectively judge whether the APP page has changed, the automated operation will be stuck in a certain page and unable to jump out, resulting in repeated acquisition of information on the same page. This situation is fatal in APP content dialing. On the one hand, it is impossible to dial a new page, and on the other hand, it will bring a great burden to the subsequent content audit.

[0003] At present, the main way to judge whether an APP page has changed is to compare whether the page source code is consistent before and after an operation by appium, and to compare the hash similarity of the page image before and after an operation by appium, so as to judge whether the page has changed. However, the method of judging whether a page has changed by comparing the page source code and hash similarity may result in misjudgment, which makes the accuracy of page change recognition poor.

[0004] With regard to the problem of poor accuracy in identifying page changes in related technologies, no effective solution has been proposed so far. Summary of the invention

[0005] In this embodiment, a method, device, electronic device and storage medium for identifying page changes are provided to solve the problem of poor accuracy in identifying page changes in the related art.

[0006] In a first aspect, a method for identifying page changes is provided in this embodiment, which is applied to a terminal device, and the method includes:

[0007] Obtain page training data of a mobile terminal device, and input the page training data into a preset first model to be trained and a second model to be trained respectively for training to obtain a model to be tested; the first model to be trained and the second model to be trained have different initialization parameters;

[0008] Input the page test data of the mobile terminal device to the model to be tested to test the model to be tested and obtain a target recognition model; the first model to be trained, the second model to be trained and the model to be tested all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel;

[0009] The page to be identified is input into the target identification model to identify whether the page has changed.

[0010] In some embodiments, the step of acquiring page training data of a mobile device and inputting the page training data into a preset first model to be trained and a preset second model to be trained for training respectively includes:

[0011] Get the attribute data of page training data;

[0012] Preset a page change rate, and determine a page change area according to the page change rate and the attribute data;

[0013] The page change area is filled to obtain first target page training data, and the first target page training data is input into the first model to be trained.

[0014] In some embodiments, the step of acquiring page training data of a mobile device and inputting the page training data into a preset first model to be trained and a preset second model to be trained for training respectively includes:

[0015] Performing a deep copy of the page training data to obtain second target page training data;

[0016] Input the second target page training data into the second model to be trained.

[0017] In some embodiments, the step of acquiring page training data of a mobile terminal device and inputting the page training data into a preset first model to be trained and a second model to be trained for training to obtain a model to be tested includes:

[0018] Inputting the first target page training data to the first model to be trained to obtain first training output data, and inputting the second target page training data to the second model to be trained to obtain second training output data;

[0019] Determining a cosine distance between the first training output data and the second training output data;

[0020] A model loss is determined according to the cosine distance and the page change rate, and the first model to be trained and the second model to be trained are updated according to the model loss to obtain a model to be tested.

[0021] In some embodiments, the step of inputting the page test data of the mobile terminal device into the model to be tested to test the model to be tested and obtain the target recognition model includes:

[0022] Preprocessing the page test data according to a preset page change rate to obtain first page test data and second page test data;

[0023] Inputting the first page test data and the second page test data into the model to be tested respectively, and obtaining a first page test result and a second page test result;

[0024] Determine a cosine distance between the first page test result and the second page test result, and obtain a test similarity according to the cosine distance;

[0025] Determining the test accuracy of the model to be tested according to whether the difference between the page change rate and the test similarity exceeds a preset tolerance threshold range;

[0026] The target recognition model is determined according to the test accuracy.

[0027] In some embodiments, inputting the page to be identified into the target identification model to identify whether the page has changed includes:

[0028] Acquire the characteristics of the page to be identified, and determine whether the characteristics are consistent with preset initialization parameter characteristics;

[0029] If they are consistent, it is determined that the page to be identified has changed; if they are inconsistent, the cosine distance between the feature and the initialization parameter feature is determined, and whether the page has changed is determined based on the cosine distance.

[0030] In some embodiments, the step of inputting the page to be identified into the target identification model to identify whether the page has changed further includes:

[0031] The preset initialization parameter characteristics are updated according to the characteristics of the page to be identified.

[0032] In a second aspect, a device for identifying page changes is provided in this embodiment, the device comprising: a training module, a testing module and an identification module;

[0033] The training module is used to obtain page training data of the mobile terminal device, and input the page training data into a preset first model to be trained and a second model to be trained respectively for training to obtain a model to be tested; the initialization parameters of the first model to be trained and the second model to be trained are different;

[0034] The test module is used to input the page test data of the mobile terminal device to the model to be tested to test the model to be tested and obtain a target recognition model; the first model to be trained, the second model to be trained and the model to be trained all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel;

[0035] The recognition module is used to input the page to be recognized into the target recognition model to recognize whether the page has changed.

[0036] In a third aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the page change recognition method described in the first aspect when executing the computer program.

[0037] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the method for identifying page changes described in the first aspect is implemented.

[0038] Compared with the related art, a page change recognition method, device, electronic device and storage medium provided in this embodiment trains page training data through a training model of a parallel dual model including a target page attention module to obtain a model to be tested, and then tests the page test data according to the model to be tested to obtain a target recognition model, and then recognizes page changes according to the serial single target recognition model, which is beneficial to improving the accuracy of page change recognition.

[0039] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0041] Figure 1 It is a hardware structure block diagram of a terminal of the page change recognition method according to an embodiment of the present application;

[0042] Figure 2 is a flow chart of a method for identifying page changes provided by an embodiment of the present application;

[0043] Figure 3 is a flow chart of a page change recognition method based on deep learning provided in an embodiment of the present application;

[0044] Figure 4 It is a schematic diagram of a hardware structure provided by this specific embodiment;

[0045] Figure 5 is a structural diagram of a page attention structure provided by this specific embodiment;

[0046] Figure 6 is a schematic diagram of a model training method provided in this specific embodiment;

[0047] Figure 7 It is a schematic diagram of an APP page change identification method provided in this specific embodiment;

[0048] Figure 8 It is a structural block diagram of the device for identifying page changes in this embodiment. DETAILED DESCRIPTION

[0049] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0050] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0051] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1is a hardware structure block diagram of a terminal of the page change recognition method of the embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0052] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the page change recognition method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0053] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0054] The APP content dialing project mainly tests hundreds of related APPs to detect whether there is any illegal content on the APP page information. The general process of dialing is to perform automated operations on the APP, then obtain the page text content and screenshots of the page, and finally conduct content audits on the text content and page screenshots through the audit model. Among them, in the APP automated operation, how to judge whether the page has changed before and after a certain operation is crucial. If it is impossible to effectively judge whether the APP page has changed, the automated operation will be stuck in a certain page and unable to jump out, resulting in repeated acquisition of information on the same page. This situation is fatal in APP content dialing. On the one hand, it is impossible to dial a new page, and on the other hand, it will bring a great burden to the subsequent content audit.

[0055] In order to determine whether the APP page has changed, the existing technology mainly includes the following methods.

[0056] The first method is to obtain the page source code through the driver.page_source property of appium, and the page source code is a string. By comparing whether the page source code is consistent before and after appium performs a certain operation, it can be determined whether the page has changed. However, this method is incorrect for dynamic pages, because the page source code of dynamic pages is also constantly changing. For example, a page has a time display function, and the time is constantly changing. If appium fails to perform a certain operation (such as clicking, sliding, or returning, etc.), then judging whether the page is updated by using the page source code will result in a misjudgment, causing the system to mistakenly believe that the operation is successful and not take effective measures to jump out of the current page, which will cause appium to be trapped in the page and unable to jump out.

[0057] Another method is to take a screenshot of the APP page to obtain a page image, and then compare the hash similarity of the page image before and after appium performs a certain operation to determine whether the page has changed. This method solves the interference problem of local minor changes in dynamic pages to a certain extent, and is more reliable than the first method. However, this method has poor robustness and generalization ability, and it will be difficult to judge in dynamic pages with large changes in page content. The method based on the hash similarity of APP page images will also cause the automated operation to stay on these pages with large changes, and cannot automatically jump to the next page.

[0058] In addition, there are some methods that determine whether a page has been updated by judging whether a specific element on the page exists. However, this method needs to be adapted to a specific APP and a specific page to be effective, otherwise it will fail if a dynamic page element is selected. Therefore, it is not universal and is not applicable to the scenario of dialing hundreds of APPs.

[0059] Therefore, the present application provides a method for identifying page changes, which is applied to terminal devices, and then identifies APP page changes on mobile devices to improve the accuracy and efficiency of page change identification. Among them, terminal devices include servers, computers or PCs, etc., and mobile devices include mobile phones, tablets, etc.; one terminal device can control multiple mobile devices, and multiple terminal devices can also control multiple mobile devices, which is not specifically limited here.

[0060] In this embodiment, a method for identifying page changes is provided. Figure 2 is a flow chart of a method for identifying page changes provided by an embodiment of the present application, such as Figure 2 As shown, the method is applied to a terminal device, where the terminal device is equivalent to Figure 1 The process includes the following steps:

[0061] Step S210, obtaining page training data of the mobile device, inputting the page training data into a preset first model to be trained and a second model to be trained respectively for training to obtain a model to be tested; the first model to be trained and the second model to be trained have different initialization parameters.

[0062] Among them, the processor obtains page training data of the mobile terminal device; specifically, the page training data mainly includes page screenshot image data of multiple APPs of the mobile terminal device; illustratively, the page training data is obtained by taking screenshots of APP pages through open source tools such as appium, and page training data of different APPs provided on the network can also be obtained. Afterwards, the terminal device inputs the page training data into the first model to be trained and the second model to be trained with different initialization parameters, and obtains the output of the first model to be trained and the second model to be trained, and then predicts the loss of the model through the output of the model, and updates the parameters of the first model to be trained and the second model to be trained to realize the training of the model to be trained. When the model to be trained meets the preset conditions, the model to be tested is obtained. Furthermore, the preset adjustment can be whether the accuracy of the model to be trained meets the preset conditions, and can also be whether the number of iterations of the model to be tested reaches the preset number threshold, which is not specifically limited here.

[0063] Step S220, input the page test data of the mobile device to the model to be tested to test the model to be tested and obtain the target recognition model; the first model to be trained, the second model to be trained and the model to be tested all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel.

[0064] Among them, the processor obtains page test data of the mobile terminal device, and the method for obtaining the page test data is consistent with the method for obtaining the above-mentioned page training data. Furthermore, the difference between page test data and page training data lies in their different uses. After the processor obtains the page test data, the page test data is input into the model to be tested, and the page test data is preprocessed. Thereafter, the preprocessed page test data is input into the model to be tested, and the model to be tested is tested to obtain the test result, and whether the test of the data to be tested is accurate is determined based on the test result, and then the model to be tested with an accurate test result is determined as the target recognition model. Furthermore, since both the model to be trained and the model to be tested include a target page attention module, the target recognition model obtained based on the model to be trained and the model to be tested also includes a target page attention module.

[0065] Furthermore, since the information on the APP page is generally arranged horizontally, the model to be trained and the model to be tested both include a target page attention module that can integrate horizontal features. At the same time, in order to reduce the amount of calculation, the output channels of the convolution kernel need to be compressed; specifically, when integrating the horizontal features of the page, the number of output channels of the convolution kernel is first compressed to half of the number of input channels, and then normalized and nonlinear operations are performed, which is conducive to improving the nonlinear fitting ability of the target page attention module.

[0066] Step S230, inputting the page to be identified into the target identification model to identify whether the page has changed.

[0067] Among them, the processor obtains the data of the page to be identified, and inputs the page to be identified into the target recognition model so that the target recognition model can identify whether the page has changed. Furthermore, the page to be identified is the current page of the APP. After the page to be identified is input into the target recognition model, the characteristic parameters of the page to be identified are obtained, and it is determined whether the characteristic parameters are consistent with the preset parameters, and then whether the page to be identified has changed is determined based on the characteristic parameters. Exemplarily, the characteristic parameters of the page to be identified include but are not limited to channel parameters, width parameters, and height parameters.

[0068] Through the above steps, the page training data is trained through the training model of the parallel dual model including the target page attention module to obtain the model to be tested, and then the page test data is tested according to the model to be tested to obtain the target recognition model; then, page change recognition is performed according to the serial single target recognition model, which is beneficial to improve the accuracy of page change recognition.

[0069] In some embodiments, step S210 includes steps S211 to S214.

[0070] Step S211, obtaining attribute data of page training data.

[0071] The processor assumes that the page of the page training data changes, and the changed page area in the page training data can be rectangular, circular, or elliptical, which is not specifically limited here. Further, when the changed page area is rectangular, the attribute data of the page training data includes the width and height of the page.

[0072] Step S212, preset the page change rate, and determine the page change area according to the page change rate and attribute data.

[0073] The page change rate is a randomly generated value within a preset range. For example, the page change rate can be generated by using the random module of the Python standard library, the Math.random() function in JavaScript, and the random() function in C++. <random>The processor calculates the page change region according to the page change rate and the attribute data; further, the processor calculates the area, width, height and coordinate values ​​of the page change region.

[0074] In one of the embodiments, the preset page change rate is updated according to the information of the page change area, and then when iteratively training the model to be trained, the updated page change rate is used to determine the page change area, which is beneficial to further improve the accuracy of the first model to be trained and the second model to be trained.

[0075] Step S213, filling the page change area to obtain first target page training data, and inputting the first target page training data into the first model to be trained.

[0076] Among them, after the page change area is determined, the page change area is filled; specifically, the page change area is filled with pixel values. Exemplarily, when the page change area is filled with pixel values, it can be filled according to actual needs, including but not limited to filling black pixels with a pixel value of 0, filling white pixels with a pixel value of 255, or filling other pixel values; a picture block of the same size can also be intercepted from other page images and copied to the page change area. After filling the page change area, the first target page training data is obtained, and then the first page training data is input into the first to-be-trained model for training to obtain the first training output data.

[0077] Step S214, deep copy the page training data to obtain second target page training data; input the second target page training data into the second model to be trained.

[0078] The processor performs a deep copy of the page training data to obtain the second target page training data, and then inputs the second page training data into the second model to be trained for training to obtain the second training output data. Furthermore, the page training data is deeply copied to create the second target page training data which is consistent with the page training data in content but different in memory location, which provides independence and integrity for the page training data, and is conducive to realizing the parallel dual-model training method, and further helps to improve the accuracy and integrity of data training.

[0079] Through the above steps, the processor processes the page training data differently to obtain the first target page training data and the second target page training data respectively, and then inputs them into the first model to be trained and the second model to be trained for training respectively, which is conducive to realizing the parallel dual-model training method, further conducive to improving the accuracy and completeness of data training, and conducive to improving the accuracy of page change recognition based on the above-mentioned model to be trained.

[0080] In some embodiments, step S210 includes steps S215 to S216.

[0081] Step S215 , inputting the first target page training data into the first model to be trained to obtain first training output data, and inputting the second target page training data into the second model to be trained to obtain second training output data.

[0082] The processor inputs the first target page training data and the second target page training data into two models to be trained, and obtains the first training output data and the second training output data. Furthermore, the model structures of the first model to be trained and the second model to be trained are completely consistent, and the network configuration and training configuration are also completely consistent, and only the model parameter initialization is different.

[0083] Step S216, determining the cosine distance between the first training output data and the second training output data, determining the model loss according to the cosine distance and the page change rate, and updating the first model to be trained and the second model to be trained according to the model loss to obtain a model to be tested.

[0084] Among them, after the processor obtains the first training output data and the second training output data, it calculates the cosine distance between the first training output data and the second training output data, and then determines the predicted model loss based on the cosine distance and the page change rate; specifically, the model loss is determined based on the cosine distance and the Euclidean distance of the page change rate, and the parameters of the two models to be trained are updated based on the model loss, so as to obtain the model to be tested.

[0085] Through the above steps, the first target page training data and the second target page training data processed by the processor are used to train the two models to be trained respectively, and the first and second training output data are obtained; then the model loss is determined according to the training output data and the page change rate, and then the parameters of the model to be trained are iteratively updated to obtain the model to be tested whose accuracy and number of iterations are within the preset range, which is conducive to improving the accuracy of determining the model to be tested. Furthermore, the model to be tested obtained from each training is saved.

[0086] In some embodiments, step S220 includes steps S221 to S223.

[0087] Step S221 , pre-processing the page test data according to a preset page change rate to obtain first page test data and second page test data.

[0088] Among them, the processor preprocesses the page test data according to the method of preprocessing the page training data to obtain the first target page training data and the second target page training data, and obtains the first page test data and the second page test data, which provides independence and integrity for the page training data, and further helps to improve the accuracy and integrity of data testing.

[0089] Step S222: input the first page test data and the second page test data to the model to be tested respectively, obtain the first page test result and the second page test result, determine the cosine distance between the first page test result and the second page test result, and obtain the test similarity according to the cosine distance.

[0090] The processor tests the model to be tested by using the first page test data and the second page test data to obtain the first page test result and the second page test result, and then calculates the cosine distance between the above test results, and the cosine distance is the value of the test similarity. Testing the same model to be tested by using different test data and then obtaining the test similarity between different test results is conducive to determining the test accuracy of the model to be tested according to the test similarity.

[0091] Step S223, determining the test accuracy of the model to be tested according to whether the difference between the page change rate and the test similarity exceeds a preset tolerance threshold range; and determining the target recognition model according to the test accuracy.

[0092] The processor calculates the real-time updated page change rate and the difference of the test similarity, and presets a tolerance threshold range, determines whether the difference exceeds the preset tolerance threshold range, and then determines whether the page test result of the model to be tested is accurate, which is conducive to improving the test accuracy of the model to be tested. Further, the model to be tested with the highest test accuracy is determined as the target recognition model.

[0093] Through the above steps, when the processor tests the model to be tested, it first preprocesses the page test data to obtain two different page test data, and then inputs them into the model to be tested for testing to obtain test results. Finally, the test similarity is determined according to the test results, and the target recognition model is obtained by combining the page change rate screening, which is beneficial to improve the recognition accuracy and efficiency of the target recognition model.

[0094] In some embodiments, step S230 includes steps S231 to S232.

[0095] Step S231, obtaining the characteristics of the page to be identified, and determining whether the characteristics are consistent with the preset initialization parameter characteristics.

[0096] When the processor identifies the page to be identified through the target recognition model, it first determines the features of the page to be identified through the target recognition model; specifically, the features include the channel features, width features and height features of the page. The initialization parameter features are preset to determine whether the features of the page to be identified are consistent with the initialization parameter features. Generally, the preset initialization parameter features are None.

[0097] Step S232, if they are consistent, it is determined that the page to be identified has changed; if they are inconsistent, the cosine distance between the feature and the initialization parameter feature is determined, and whether the page has changed is determined based on the cosine distance.

[0098] Among them, if they are consistent, it is determined that the current page to be identified is a new page, and the preset initialization parameter features are updated according to the current page to be identified, and the current page of the APP is screenshoted again to obtain a new page to be identified; if they are inconsistent, the cosine distance between the features of the page to be identified and the initialization parameter features, that is, the feature similarity, is calculated to determine whether the feature similarity exceeds the preset page change rate critical value, and then determine whether the page to be identified has changed.

[0099] Through the above steps, when the page to be identified is identified, the features of the page to be identified are extracted through the target recognition model, and the features of the page to be identified are compared with the preset initialization parameter features to see whether they are consistent, and whether the feature similarity exceeds the preset page change rate critical value, thereby determining whether the page to be identified has changed, which is beneficial to improving the accuracy and efficiency of page change identification.

[0100] Furthermore, the preset initialization parameter characteristics are updated according to the characteristics of the page to be identified.

[0101] The present embodiment is described and illustrated by means of specific examples below.

[0102] This embodiment also provides a page change recognition method based on deep learning. Figure 3 is a flow chart of a page change recognition method based on deep learning provided in an embodiment of the present application, such as Figure 3 As shown, the process includes the following steps:

[0103] Step S301, data collection.

[0104] Specifically, Figure 4 This is a schematic diagram of a hardware structure provided by this specific embodiment, refer to Figure 4 , the hardware structure includes a terminal device and a mobile device, and the terminal device is connected to the mobile device by wired or wireless means; one terminal device can be connected to multiple mobile devices, and multiple mobile devices can also be connected through multiple terminal devices. In one embodiment, the terminal device is a computer, and the mobile device is a mobile phone. The computer is connected to the mobile phone by a wired method, i.e., a USB cable. The specific connection mode selects a non-charging model. At the same time, a software environment is set up on the computer and the mobile phone respectively so that the page data can be collected and processed on the computer. The data collection process is mainly that the computer sends action instructions that simulate real-person operations, such as clicking, sliding, etc., and then the mobile phone automatically executes the operation instructions to operate the corresponding APP. In each page of the APP, page text and image data will be collected. The whole process is fully automated and no human intervention is required.

[0105] Furthermore, the data collection step includes step S11 to step S13.

[0106] Step S11, collecting APP page screenshot image data.

[0107] The APP page screenshot image data is recorded as dataset_origin. This step is mainly used to collect page screenshot images of the APP that needs to be tested to create a training data set. Furthermore, you can use open source tools such as appium to implement APP page screenshots. You can use Selenium's save_screenshot method in Python to save screenshots, and you can also use the TakesScreenshot interface in Java to implement screenshots.

[0108] Step S12, clean the dataset_origin, remove duplicate or invalid images, and obtain the dataset dataset_clean.

[0109] Step S13, divide dataset_clean into three data sets, namely, a training data set dataset_train, an evaluation data set dataset_eval, and a test data set dataset_test, and the data ratio of the above three data sets is generally 8:1:1.

[0110] Among them, the training data set includes the page training data in the aforementioned embodiment, and the test data set includes the page test data in the aforementioned embodiment. After the model to be trained is trained using the page training data in the training data set, the evaluation data set is used to verify the model obtained after each training, and then the number of iterations epoch and the accuracy of the model on the evaluation data set dataset_eval are recorded.

[0111] Step S302: data preprocessing.

[0112] Specifically, data preprocessing is to obtain model input data and label label. The model input data here is the first target page training data, the second target page training data, the first page test data and the second page test data in the aforementioned embodiment; the label label here is the page change rate in the aforementioned embodiment. The steps of data preprocessing are as follows:

[0113] Step S21, obtain a picture, and record the picture as img.

[0114] Step S22, obtaining the width and height of img, which are respectively denoted as w and h. The width and height here are the attribute data in the aforementioned embodiment.

[0115] Step S23, randomly generate a label, the value range of label is (0,1); in order to simulate the change of APP page, such as banner, etc., we assume that there is a region in img that has changed, and the region is rectangular. Here, label means the ratio of the area of ​​the img change region to the total area of ​​img.

[0116] Step S24, calculate the area of ​​the img change region:

[0117]

[0118] Among them, label represents the ratio of the area of ​​img change region to the total area of ​​img, w represents the width of img, and h represents the height of img.

[0119] Step S25, obtain the width of the img change region, recorded as w_v; wherein, w_v = w if np.Sqrt(S)>welse random.uniform(np.Sqrt(s),w), the width of the change region generated by the above formula expressing the width of the img change region should be smaller than the width of the mobile device, i.e., the mobile phone. Thereafter, w_v is converted into an integer, i.e., w_v=int(w_v).

[0120] Step S26, obtaining the height of the img change region: h_v=int(s / w_v); the value of the height h_v is an integer ratio of the area to the width of the img change region.

[0121] Step S27, update the value of label; that is, label=1.0×w_v×h_v / (w×h), where the value of label is a floating point ratio of the area of ​​the img change region to the total area of ​​img.

[0122] Step S7, determine the coordinates (x, y) of the upper left corner of the change area; where: Here, random.random() is a method for obtaining random numbers in Python language.

[0123] Step S28, make a deep copy of the image img to obtain img_c.

[0124] Step S29, fill the pixel values ​​in the changed area of ​​img and return img, img_c, label.

[0125] Furthermore, when the coordinates of the upper left corner (x, y) of the changing area, as well as the width w_v and height h_v are determined, that is, the position of the changing area on img is completely determined, the changing area can be filled. It can be filled with all 0 (that is, the changing area is black), or all 255 (that is, the changing area is white), or a specific pixel value. You can also cut a piece of the same size from other pictures and copy it to this area. Without loss of generality, here we choose to explain the method of filling with 0, that is, img[:,x:x+w_v,y:y+h_v]= numpy.zeros((w_v,h_v)). Furthermore, the features of the above img are (c,w,h), corresponding to the channel, width, and height of img respectively.

[0126] Step S303: model design.

[0127] Specifically, in order to balance performance and efficiency, the training model, test model and recognition model provided in this embodiment are all modified based on mobileNetV3. mobileNetV3 mainly includes an anti-residual module, a SE attention module, a basic convolution module and a classification head. Among them, the SE attention module can configure whether the module is enabled through the parameter se. If se is True, the SE attention module is enabled; if se is False, the SE attention module is not used. However, the SE channel attention module cannot capture the spatial information of the APP page pictures, and the information of the APP page is generally arranged horizontally. Therefore, this embodiment adopts a page attention structure (PAttention) to replace the SE channel attention module, and removes the classification head of mobileNetV3, while the other parts of the structure remain unchanged. The page attention structure here is the target page attention module in the aforementioned embodiment.

[0128] Figure 5 is a structural diagram of a page attention structure provided by this specific embodiment. Figure 5 As shown in the figure, the attention module PAttention first integrates the horizontal features of the feature layer featureMap of the current input data, and compresses the channel to half of the original through the convolution kernel conv1×3 to reduce the amount of calculation; then, it is normalized through the BN layer (BatchNormalization, batch normalization layer) and the ReLU layer performs nonlinear operations to improve the nonlinear fitting ability of the network; secondly, the convolution kernel conv1x1 is used to reduce the channel of the featureMap to 1. Finally, the spatial attention of the featureMap can be obtained through the sigmoid function.

[0129] Furthermore, the convolution and its parameters used by conv1x3 are:

[0130] nn.Conv2d(in, out, kernel_size=(1,3), stride=1, padding=(0,1))

[0131] Among them, in is the number of input channels, out is the number of output channels of the convolution kernel, out=int(0.5×in), int means the value is an integer; kernel_size is the size of the convolution kernel, kernel_size=(1,3) means the height of the convolution kernel is 1 and the width is 3, which means the horizontal features are integrated; stride is the convolution kernel moving step, padding is the feature padding parameter; the channel of BN should be consistent with the output channel of conv, so the number of channels of BN is out.

[0132] Step S304: model training.

[0133] Specifically, Figure 6 is a schematic diagram of a model training method provided in this specific embodiment. Figure 6 , first input the image, and preprocess the image to obtain image 1-img and image 2-img_c, where image 1 is the first target page training data and the first target page training data in the aforementioned embodiment. Afterwards, input image 1 and image 2 into model A and model B respectively to obtain training results embed_A and embed_B, and calculate the cosine distance cos between embed_A and embed_B, and calculate the model prediction loss according to the cosine distance cos and the aforementioned label. Wherein, model A is the first training model in the aforementioned embodiment, and model B is the second training model in the aforementioned embodiment; thereafter, model A and model B are iteratively updated through the model prediction loss until the number of training iterations reaches the preset iteration number threshold, or the accuracy of model A or model B on the evaluation data set is within a preset range.

[0134] The specific steps are as follows:

[0135] Step S31, input a picture, and record the picture as img.

[0136] Step S32, preprocess img according to the data preprocessing method of step S302 to obtain img, img_c and label.

[0137] Step S33, randomly input img and img_c into model A and model B.

[0138] The model structures of Model A and Model B are completely the same, and the network configuration and training configuration are also completely the same. The only difference is the initialization of the model parameters. For the network structures of Model A and Model B, the model design module in step S303 can be used. The brief steps are as follows:

[0139] Use mobileNetV3 as the base network; replace the SE channel attention of mobileNetV3 with PAttention; enable PAttention in the last 5 layers of mobileNetV3 in the same way as mobileNetV3 configures SE channel attention; remove the classification head of mobileNetV3, and the output is the feature.

[0140] Step S34, obtain the output embed_A of model A and the output embed_B of model B.

[0141] Step S35, calculate the cosine distance d between embed_A and embed_B, that is:

[0142] d=cos(embed_A,embed_B)

[0143] Step S36, calculating the model prediction loss.

[0144] Among them, L2loss is used as the loss function, that is, the Euclidean distance between the cosine distance d and the label label is taken as the loss of model prediction, and then back propagation is used to update the parameters of the two models at the same time.

[0145] Step S37, iteratively train the model.

[0146] Among them, the training dataset dataset_train is used to train Model A and Model B according to steps S31 - S36, and the evaluation dataset dataset_eval is used to verify the models obtained from each training. Record the number of iterations epoch and the accuracy acc of the model on dataset_eval, and save the models obtained from each training, denoted as model_epoch, such as model1, model2, etc.; when calculating acc, as long as the prediction error is within a certain range, it can be considered correct.

[0147] Step S38, determine whether the current epoch is greater than the preset threshold or whether acc meets the early stopping condition; if so, stop the model training; if not, jump back to step S37.

[0148] Step S305, model testing.

[0149] Specifically, model testing is mainly used to select the best model for subsequent APP page change recognition; the steps are as follows:

[0150] Step S41, load the model parameters using the modified mobileNetV3 to obtain model. Further, this model can be model A, model B obtained from step S302, and any model during the iteration process.

[0151] Step S42, input an image, and denote this image as img.

[0152] Step S43, preprocess img according to the data preprocessing method in step S302 to obtain img, img_c and label.

[0153] Step S44, input img into model to get embed_A, and input img_c into model to get embed_B.

[0154] Step S45, calculate the similarity between the two images, that is, sim = cos(embed_A, embed_B).

[0155] Step S46, if sim - label < p, then the prediction is considered correct, otherwise it is considered incorrect; where the parameter p is the prediction tolerance range, and exemplarily, the parameter p is set to 0.01.

[0156] Step S47, repeat S42 - S46 using the test dataset dataset_test to obtain the test accuracy acc of the model.

[0157] Step S48, for all models of modelA and modelB trained in step S304, repeat steps S41-S47 to obtain the accuracy of all models, and record the model with the highest accuracy as model_best. Here, model_best is the target recognition model in the aforementioned embodiment.

[0158] Step S306, identifying APP page changes.

[0159] Specifically, Figure 7 is a schematic diagram of an APP page change identification method provided by this specific embodiment. Figure 7 , the page change recognition method is as follows: first initialize the parameter feature, that is, the preset initialization parameter feature is None, and the preset page change rate critical value p_var is 0.3; then input the current page of the APP, that is, the page to be identified refers to the target recognition model, and obtain the feature embed; then determine whether the embed_pre corresponding to the image is None; if so, the page where the current image of the task is located is the changed page, and the initialization parameter feature embed_pre is updated according to the feature embed of the image; if not, calculate the feature similarity sim between the feature embed of the image and the initialization parameter feature embed_pre, and determine the size of the feature similarity sim and the page change rate critical value p_var. If sim is not less than p_var, it is determined that the page where the current image is located is the new page after the change. If sim is less than p_var, it is determined that the page where the current image is located is the old page that has not changed. Then update the initialization parameter feature embed_pre according to the feature embed of the image; and re-acquire the next image, and perform page change recognition on the next image. The specific steps are:

[0160] Step S51, initializing parameters, setting embed_pre=None.

[0161] Step S52, use the modified mobileNetV3 to load the model_best model parameters to obtain the model.

[0162] Step S53, taking a screenshot of the current page of the APP to obtain the image img.

[0163] Step S54, use model_best to extract features from img to obtain embed.

[0164] Step S55, determine whether embed_pre is None.

[0165] If embed_pre is None, it is considered that the current page is a brand-new page, and let embed_pre = embed; jump to step S51; if embed_pre is not None, calculate the similarity between the current page and the previous page, that is:

[0166] sim = cos(embed, embed_pre)

[0167] embed_pre = embed

[0168] where embed is the feature of the page to be recognized, and embed_pre represents the preset initialization parameter feature. After identifying whether the page has changed, update embed_pre according to embed.

[0169] Step S56, determine whether sim < p_var holds; if it holds, it is considered the same page; if it does not hold, it is considered a different page; where p_var is a hyperparameter representing the critical value of the page change rate, which can be set to 0.3.

[0170] In this embodiment, the improved mobileNetV3 model is used to recognize the page change rate, which has stronger robustness than the existing algorithms based on page source code and image hashing, and higher accuracy in page change recognition; a data parallel dual-model structure is adopted during training, and a data serial single-model structure is adopted during recognition, which improves the model training efficiency and accuracy, and at the same time reduces the model inference cost and inference delay.

[0171] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0172] In this embodiment, a page change recognition device is also provided. This device is used to implement the above embodiment and the preferred implementation manners, and those that have been described will not be repeated here. The following terms "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0173] Figure 8 is the structural block diagram of the page change recognition device of this embodiment, as Figure 8 shown, this device includes: a training module 10, a testing module 20, and an identification module 30.

[0174] The training module 10 is used to obtain page training data of the mobile device, and input the page training data into the preset first model to be trained and the second model to be trained respectively for training to obtain the model to be tested; the initialization parameters of the first model to be trained and the second model to be trained are different.

[0175] The test module 20 is used to input the page test data of the mobile device to the model to be tested, so as to test the model to be tested and obtain a target recognition model; the first model to be trained, the second model to be trained and the model to be trained all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel.

[0176] The recognition module 30 is used to input the page to be recognized into the target recognition model to recognize whether the page has changed.

[0177] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0178] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0179] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0180] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0181] S1, obtaining page training data of a mobile terminal device, inputting the page training data into a preset first model to be trained and a second model to be trained respectively for training, to obtain a model to be tested; the first model to be trained and the second model to be trained have different initialization parameters.

[0182] S2, input the page test data of the mobile device to the model to be tested to test the model to be tested and obtain the target recognition model; the first model to be trained, the second model to be trained and the model to be trained and tested all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel.

[0183] S3, input the page to be identified into the target recognition model to identify whether the page has changed.

[0184] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0185] In addition, in combination with the page change recognition method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by a processor, any page change recognition method in the above embodiments is implemented.

[0186] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0187] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0188] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0189] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.< / random>

Claims

1. A method for identifying page changes, characterized in that: Applied to a terminal device, the method comprises: Obtain page training data of a mobile terminal device, and input the page training data into a preset first model to be trained and a second model to be trained respectively for training to obtain a model to be tested; the first model to be trained and the second model to be trained have different initialization parameters; Input the page test data of the mobile terminal device to the model to be tested to test the model to be tested and obtain a target recognition model; the first model to be trained, the second model to be trained and the model to be tested all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel; Inputting the page to be identified into the target identification model to identify whether the page has changed; The acquiring of page training data of the mobile terminal device and inputting the page training data into a preset first model to be trained and a preset second model to be trained for training respectively include: Get the attribute data of page training data; Preset a page change rate, and determine a page change area according to the page change rate and the attribute data; Filling the page change area to obtain first target page training data, and inputting the first target page training data into the first model to be trained; Performing a deep copy of the page training data to obtain second target page training data; Inputting the second target page training data into the second model to be trained; Inputting the first target page training data to the first model to be trained to obtain first training output data, and inputting the second target page training data to the second model to be trained to obtain second training output data; Determining a cosine distance between the first training output data and the second training output data; A model loss is determined according to the cosine distance and the page change rate, and the first model to be trained and the second model to be trained are updated according to the model loss to obtain a model to be tested.

2. The method for identifying page changes according to claim 1, characterized in that: The step of inputting the page test data of the mobile terminal device into the model to be tested to test the model to be tested and obtain a target recognition model includes: Preprocessing the page test data according to a preset page change rate to obtain first page test data and second page test data; Inputting the first page test data and the second page test data into the model to be tested respectively, and obtaining a first page test result and a second page test result; Determine a cosine distance between the first page test result and the second page test result, and obtain a test similarity according to the cosine distance; Determining the test accuracy of the model to be tested according to whether the difference between the page change rate and the test similarity exceeds a preset tolerance threshold range; The target recognition model is determined according to the test accuracy.

3. The method for identifying page changes according to claim 1, characterized in that: The inputting the page to be identified into the target identification model to identify whether the page has changed includes: Acquire the characteristics of the page to be identified, and determine whether the preset initialization parameter characteristics are empty; If yes, it is determined that the page to be identified has changed; and the preset initialization parameter characteristics are updated according to the characteristics of the page to be identified; If not, a cosine distance between the feature and the initialization parameter feature is determined, and whether the page has changed is determined according to the cosine distance.

4. A device for identifying page changes, characterized in that: The device comprises: a training module, a testing module and a recognition module; The training module is used to obtain page training data of the mobile terminal device, input the page training data to the preset first model to be trained and the second model to be trained for training, and obtain the model to be tested; the initialization parameters of the first model to be trained and the second model to be trained are different; the page training data of the mobile terminal device is obtained, and the page training data is input to the preset first model to be trained and the second model to be trained for training, including: obtaining attribute data of the page training data; presetting a page change rate, and determining a page change area according to the page change rate and the attribute data; filling the page change area to obtain first target page training data, and inputting the first target page training data to the first model to be trained; deep copying the page training data to obtain second target page training data; inputting the second target page training data to the second model to be trained Training model; inputting the first target page training data to the first model to be trained to obtain the first training output data, inputting the second target page training data to the second model to be trained to obtain the second training output data; determining the cosine distance between the first training output data and the second training output data; determining the model loss according to the cosine distance and the page change rate, and updating the first model to be trained and the second model to be trained according to the model loss to obtain the model to be tested; the testing module is used to input the page test data of the mobile terminal device to the model to be tested to test the model to be tested and obtain the target recognition model; the first model to be trained, the second model to be trained and the model to be trained all include a target page attention module; the number of output channels of the convolution kernel in the target page attention module is determined by the number of input channels of the convolution kernel; The recognition module is used to input the page to be recognized into the target recognition model to recognize whether the page has changed.

5. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the page change recognition method according to any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for identifying page changes according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Webpage tampering detection method and device and storage medium

    CN109815744A

  • Malicious webpage integrated identification method and system based on Stacking

    CN110348523A