Verification code image generation method, device, equipment, storage medium and program product
By generating global and local CAPTCHA description information, combined with an image generation model, and employing a two-stage rendering method, the problems of limited image library capacity and obvious splicing marks in existing technologies are solved, resulting in high-quality CAPTCHA images.
Patent Information
- Application Number
- CN202510668995.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2026-11-27
AI Technical Summary
The existing image library has limited capacity and obvious splicing marks, resulting in a decrease in the quality of CAPTCHA images.
By generating global and local CAPTCHA description information and determining reference description information, the CAPTCHA image is generated in combination with an image generation model. A two-stage rendering method is adopted to ensure the foreground and overall quality of the CAPTCHA image.
The image quality and content richness of CAPTCHA images have been improved, resulting in more aesthetically pleasing CAPTCHA images.
Smart Images

Figure CN123181607A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for generating verification code images. Background Technology
[0002] With the development of computer technology, CAPTCHA images have emerged. CAPTCHA images are a visual testing tool used to distinguish between human users and automated programs (such as robots), and are usually presented in the form of images.
[0003] Currently, the common practice is to obtain multiple images from an existing image library and then stitch them together to get the CAPTCHA image. For example, multiple text images can be obtained from an existing image library and then stitched together to get the CAPTCHA image. However, existing image libraries have limited capacity, and the stitching artifacts are obvious, which can easily reduce the quality of the CAPTCHA image. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for generating CAPTCHA images that can improve the image quality of CAPTCHA images, in response to the aforementioned technical problems.
[0005] This application provides a method for generating verification code images, including:
[0006] Obtain the target verification code type;
[0007] Based on the target CAPTCHA type, generate global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type;
[0008] Based on the target CAPTCHA type, reference description information is determined from the global CAPTCHA description information and the local CAPTCHA description information;
[0009] An image is generated based on the reference description information to obtain a reference image;
[0010] Based on the local CAPTCHA description information and the reference image, the foreground information of the target CAPTCHA is determined;
[0011] An image is generated based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0012] This application also provides a verification code image generation apparatus, including:
[0013] The verification code type acquisition module is used to obtain the target verification code type;
[0014] The verification code description information generation module is used to generate global verification code description information and local verification code description information corresponding to the target verification code type based on the target verification code type.
[0015] The reference description information determination module is used to determine reference description information from the global verification code description information and the local verification code description information based on the target verification code type.
[0016] The reference image generation module is used to generate an image based on the reference description information to obtain a reference image;
[0017] The verification code foreground information determination module is used to determine the foreground information of the target verification code based on the local verification code description information and the reference image;
[0018] The verification code image generation module is used to generate an image based on the global verification code description information and the target verification code foreground information, so as to obtain the target verification code image corresponding to the target verification code type.
[0019] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps described in the above-described verification code image generation method.
[0020] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps described in the above-described verification code image generation method.
[0021] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps described in the above-described verification code image generation method.
[0022] The aforementioned CAPTCHA image generation method, apparatus, computer equipment, storage medium, and computer program product acquire a target CAPTCHA type; based on the target CAPTCHA type, generate global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type; based on the target CAPTCHA type, determine reference description information from the global and local CAPTCHA description information; generate an image based on the reference description information to obtain a reference image; determine foreground information of the target CAPTCHA based on the local CAPTCHA description information and the reference image; and generate an image based on the global and foreground information of the target CAPTCHA to obtain a target CAPTCHA image corresponding to the target CAPTCHA type. Thus, by first drawing the more important information in the CAPTCHA image corresponding to the target CAPTCHA type, the image quality of the final CAPTCHA image is ensured. The foreground information of the target CAPTCHA is determined based on local CAPTCHA description information and a reference image. An image is then generated based on the global CAPTCHA description information and the target CAPTCHA foreground information, resulting in the target CAPTCHA image corresponding to the target CAPTCHA type. Further image rendering based on more detailed information ensures the foreground and overall quality of the final CAPTCHA image. In summary, obtaining a CAPTCHA image through two-stage image rendering based on global and local CAPTCHA description information improves the image quality, resulting in a more aesthetically pleasing and richer CAPTCHA image. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is an application environment diagram of a verification code image generation method in one embodiment;
[0025] Figure 2 This is a flowchart illustrating a method for generating a verification code image in one embodiment;
[0026] Figure 3 This is a schematic diagram illustrating the generation of a verification code image corresponding to an object recognition verification code or a spatial reasoning verification code in one embodiment.
[0027] Figure 4This is a schematic diagram illustrating the generation of a verification code image corresponding to an object recognition verification code or a spatial reasoning verification code in another embodiment;
[0028] Figure 5 This is a schematic diagram illustrating the generation of a verification code image corresponding to a difference-annotated verification code in one embodiment;
[0029] Figure 6 This is a schematic diagram of the verification code images corresponding to text-based and general object-based verification codes in one embodiment.
[0030] Figure 7 This is a schematic diagram of the verification code image corresponding to the spatial reasoning type verification code in one embodiment;
[0031] Figure 8 This is a schematic diagram illustrating the process of finding CAPTCHA images corresponding to different types of CAPTCHAs in a single embodiment.
[0032] Figure 9 This is a schematic diagram illustrating the generation of a text-based click-based CAPTCHA image in one embodiment.
[0033] Figure 10 This is a schematic diagram of a verification code image generation method in one embodiment;
[0034] Figure 11 This is a schematic diagram of a one-stage verification code image generation method and a two-stage verification code image generation method in one embodiment;
[0035] Figure 12 This is a structural block diagram of a verification code image generation device in one embodiment;
[0036] Figure 13 This is an internal structural diagram of a computer device in one embodiment;
[0037] Figure 14 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0039] The verification code image generation method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on other devices. Both terminal 102 and server 104 can be used independently to execute the verification code image generation method provided in this embodiment. Terminal 102 and server 104 can also be used collaboratively to execute the verification code image generation method provided in this embodiment. Taking the collaborative execution of the verification code image generation method provided in this embodiment by terminal 102 and server 104 as an example, terminal 102 can generate a verification code image generation request, which carries the target verification code type, and send the verification code image generation request to server 104. After receiving the verification code image generation request, server 104 can obtain the target verification code image corresponding to the target verification code type through two-stage image generation. Specifically, server 104 can generate global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type, and determine reference description information from the global and local CAPTCHA description information based on the target CAPTCHA type. Server 104 can generate an image based on the reference description information to obtain a reference image, determine the target CAPTCHA foreground information based on the local CAPTCHA description information and the reference image, and generate an image based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type. Server 104 can return the target CAPTCHA image to terminal 102.
[0040] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0041] In one embodiment, such as Figure 2 As shown, a method for generating verification code images is provided. Taking the application of this method to a computer device as an example, the computer device can be a terminal or a server. It can be understood that this method can be executed independently by the terminal or server, or it can be implemented through interaction between the terminal and the server. Specifically:
[0042] Step S202: Obtain the target verification code type.
[0043] A CAPTCHA image is an image used to distinguish between real users and bots. Users complete the verification task by recognizing the CAPTCHA image, and the verification result differentiates real users from bots. CAPTCHA images are also called image CAPTCHAs or graphic CAPTCHAs. CAPTCHA types refer to the types of CAPTCHA images. CAPTCHA images can be divided into different types. Different types of CAPTCHA images differ in at least one aspect, such as security, application scenarios, and verification methods. For example, CAPTCHA images are divided into various verification methods such as difference-annotation CAPTCHAs, puzzle CAPTCHAs, rotation CAPTCHAs, and point-selection CAPTCHAs. Difference-annotation CAPTCHAs require users to mark the differences between similar images to complete the verification. Puzzle CAPTCHAs require users to piece together multiple image blocks into a complete image to complete the verification. Rotation CAPTCHAs require users to rotate the image to a specified angle to complete the verification. Point-selection CAPTCHAs require users to click or select a specific object in the image to complete the verification.
[0044] The target CAPTCHA type refers to the type of CAPTCHA being processed. It can be understood that the target CAPTCHA type can be any type of CAPTCHA.
[0045] Specifically, the computer device can obtain the target verification code type locally or from other devices and generate the target verification code image corresponding to the target verification code type.
[0046] Step S204: Based on the target verification code type, generate global verification code description information and local verification code description information corresponding to the target verification code type.
[0047] The global CAPTCHA description information corresponding to the target CAPTCHA type provides an overall description of the CAPTCHA image to be generated for that target CAPTCHA type. The local CAPTCHA description information corresponding to the target CAPTCHA type provides a local description of the CAPTCHA image to be generated for that target CAPTCHA type. In other words, the global CAPTCHA description information focuses more on the global features of the CAPTCHA image to be generated, while the local CAPTCHA description information focuses more on the local features of the CAPTCHA image to be generated. For example, the global CAPTCHA description information describes the scene information in the CAPTCHA image to be generated, while the local CAPTCHA description information describes the foreground object information in the CAPTCHA image to be generated. The CAPTCHA image to be generated refers to the CAPTCHA image to be generated.
[0048] Specifically, computer equipment can generate global and local CAPTCHA descriptions based on the target CAPTCHA type. Specifically, this can be done according to the image characteristics of the CAPTCHA image corresponding to the target CAPTCHA type. For example, the CAPTCHA image for a point-based CAPTCHA needs to include multiple objects for the user to select. Multiple objects are randomly selected to generate local CAPTCHA descriptions, while the background and multiple objects are randomly selected to generate global CAPTCHA descriptions. It can be understood that global and local CAPTCHA descriptions can be generated through a model, selected from a candidate information library, or generated through other methods.
[0049] In one embodiment, the target CAPTCHA type is input into a language model, enabling the language model to generate global and local CAPTCHA description information corresponding to the target CAPTCHA type. The language model then outputs the global and local CAPTCHA description information corresponding to the target CAPTCHA type. Here, the language model refers to a large language model, which is a deep learning model trained on massive amounts of text data, capable of generating natural language text and understanding its semantics. For example, the target CAPTCHA type and a task prompt are input into the language model. The task prompt guides the language model to generate overall and local description information for the CAPTCHA image to be generated corresponding to the target CAPTCHA type, and the language model outputs the global and local CAPTCHA description information corresponding to the target CAPTCHA type.
[0050] Step S206: Based on the target CAPTCHA type, determine reference description information from the global CAPTCHA description information and the local CAPTCHA description information.
[0051] Specifically, the computer device can determine reference description information from global and local CAPTCHA description information based on the target CAPTCHA type. For CAPTCHA types that require drawing local information from the CAPTCHA image first, the local CAPTCHA description information is used as the reference description information. For CAPTCHA types that require drawing global information from the CAPTCHA image first, the global CAPTCHA description information is used as the reference description information. It can be understood that the order in which the CAPTCHA images are drawn for each CAPTCHA type can be set according to actual needs.
[0052] In one embodiment, when the number of foreground object references corresponding to the target CAPTCHA type is greater than a threshold, local CAPTCHA description information is used as reference description information. When the number of foreground object references corresponding to the target CAPTCHA type is less than or equal to the threshold, global CAPTCHA description information is used as reference description information. The number of foreground object references corresponding to the target CAPTCHA type refers to the number of foreground objects in the CAPTCHA image corresponding to the target CAPTCHA type. The number of foreground object references corresponding to the target CAPTCHA type is obtained by statistically analyzing the number of foreground objects in multiple known CAPTCHA images corresponding to the target CAPTCHA type. For example, the average number of foreground objects in multiple known CAPTCHA images corresponding to the target CAPTCHA type can be used as the number of foreground object references corresponding to the target CAPTCHA type. Alternatively, the median number of foreground objects in multiple known CAPTCHA images corresponding to the target CAPTCHA type can be used as the number of foreground object references corresponding to the target CAPTCHA type. The number of foreground object references can reflect the average number of foreground objects in various CAPTCHA images belonging to the same CAPTCHA type. Thus, for CAPTCHA types that require a lot of foreground objects in the CAPTCHA image, the local CAPTCHA description information is used as the reference description information to draw the foreground objects first, in order to ensure the accuracy of the foreground objects. For CAPTCHA types that require less foreground objects in the CAPTCHA image, the global CAPTCHA description information is used as the reference description information to draw the overall image first, in order to ensure the accuracy of the overall image.
[0053] Step S208: Generate an image based on the reference description information to obtain a reference image.
[0054] Specifically, after determining the reference description information, the computer device can generate an image based on the reference description information to obtain a reference image, which is an image that conforms to the description in the reference description information. It is understandable that images can be generated using various image generation algorithms.
[0055] In one embodiment, reference description information is input into an image generation model, causing the model to generate a reference image based on the reference description information, and then output the reference image. The image generation model is an artificial intelligence model used to generate images. For example, if the reference description information is text data, it is input into a text-to-image generation model, which then outputs the reference image.
[0056] In one embodiment, reference description information is converted into an input prompt for the image generation model based on a language model. The input prompt is then fed into the image generation model, which outputs a reference image. The input prompt guides the image generation model to generate an image that conforms to the description of the reference description information.
[0057] Step S210: Determine the foreground information of the target CAPTCHA based on the local CAPTCHA description information and the reference image.
[0058] The target CAPTCHA foreground information refers to information related to the foreground of the CAPTCHA image to be generated, which corresponds to the target CAPTCHA type. It can be understood that the target CAPTCHA foreground information includes more detailed foreground information.
[0059] Specifically, after generating the reference image, the computer device can enrich the foreground description information based on the local CAPTCHA description information and the reference image to obtain the target CAPTCHA foreground information. For example, foreground description information can be extracted from the local CAPTCHA description information as the first foreground description information, and foreground description information can be extracted from the reference image as the second foreground description information. The target CAPTCHA foreground information is obtained based on the first and second foreground description information. In this way, the first and second foreground description information can compensate for each other's deficiencies, and a more information-rich target CAPTCHA foreground information can be obtained based on the first and second foreground description information, thereby helping to improve the image quality of the final generated CAPTCHA image.
[0060] In one embodiment, the global CAPTCHA description information and the local CAPTCHA description information are text data, and the target CAPTCHA foreground information includes at least one of text data and image data.
[0061] Step S212: Generate an image based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0062] The target CAPTCHA image is the final generated CAPTCHA image. It is a CAPTCHA image belonging to the target CAPTCHA type, and it conforms to the descriptions of both the global and local CAPTCHA descriptions.
[0063] Specifically, computer equipment can generate an image based on global CAPTCHA description information and target CAPTCHA foreground information to obtain a target CAPTCHA image corresponding to the target CAPTCHA type. For example, an intermediate CAPTCHA image corresponding to the target CAPTCHA type can be generated based on global CAPTCHA description information. The intermediate CAPTCHA image can then be updated based on the target CAPTCHA foreground information to obtain the target CAPTCHA image. Fine-tuning the intermediate CAPTCHA image based on the target CAPTCHA foreground information can quickly yield the target CAPTCHA image. It can be understood that global CAPTCHA image description information controls the overall visual effect of the CAPTCHA image, while target CAPTCHA foreground information controls the detailed visual effect. Generating an image by combining global CAPTCHA description information and target CAPTCHA foreground information results in a high-quality target CAPTCHA image.
[0064] In one embodiment, global CAPTCHA description information and target CAPTCHA foreground information are input into an image generation model, so that the image generation model generates an image based on the global CAPTCHA description information and target CAPTCHA foreground information, thereby obtaining a target CAPTCHA image corresponding to the target CAPTCHA type, and the image generation model outputs the target CAPTCHA image.
[0065] In the above-described CAPTCHA image generation method, based on the target CAPTCHA type, global and local CAPTCHA description information corresponding to the target CAPTCHA type are generated. Reference description information is determined from the global and local CAPTCHA description information based on the target CAPTCHA type. An image is generated based on the reference description information to obtain a reference image. By first drawing the more important information in the CAPTCHA image corresponding to the target CAPTCHA type, the image quality of the final CAPTCHA image is ensured. Based on the local CAPTCHA description information and the reference image, the foreground information of the target CAPTCHA is determined. An image is generated based on the global CAPTCHA description information and the foreground information of the target CAPTCHA, resulting in the target CAPTCHA image corresponding to the target CAPTCHA type. Image drawing based on more detailed information ensures the foreground and overall quality of the final CAPTCHA image. In summary, obtaining a CAPTCHA image through two-stage image drawing based on global and local CAPTCHA description information can improve the image quality of the CAPTCHA image, resulting in a more aesthetically pleasing and richer CAPTCHA image.
[0066] In one embodiment, based on the target CAPTCHA type, global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type are generated, including:
[0067] Based on the verification code variable corresponding to the target verification code type, generate global verification code description information and local verification code description information corresponding to the target verification code type.
[0068] The CAPTCHA variable is a variable set for the CAPTCHA image to control its diversity. Based on the CAPTCHA variable, a large number of non-repeating CAPTCHA images can be generated. The CAPTCHA variable can be a variable related to the foreground of the CAPTCHA image, such as the number, shape, or position of foreground objects. The number of foreground objects refers to the number of foreground objects contained in the CAPTCHA image. The shape of the foreground objects refers to the shape of the foreground objects in the CAPTCHA image. The position of the foreground objects refers to their position in the image. The CAPTCHA variable can also be a variable related to the background of the CAPTCHA image, such as the background style or color. Different CAPTCHA types can correspond to the same or different CAPTCHA variables. The CAPTCHA variable corresponding to a CAPTCHA type can be set according to actual needs. The CAPTCHA variable corresponding to the target CAPTCHA type is a variable set for the CAPTCHA image corresponding to the target CAPTCHA type to control its diversity.
[0069] Specifically, the computer device obtains the verification code variable corresponding to the target verification code type, randomly generates the variable value of the verification code variable, and generates global verification code description information and local verification code description information corresponding to the target verification code type under the constraint of the variable value of the verification code variable.
[0070] For example, the CAPTCHA variables corresponding to the target CAPTCHA type include variables related to the number of foreground objects. The number of foreground objects is randomly generated. If the number of foreground objects is specifically 4, then local description information is generated for each of the 4 foreground objects. Local CAPTCHA description information is obtained based on each local description information, background description information is generated, and global CAPTCHA description information is obtained based on the local and background description information. It can be understood that description information can be generated through a model, selected from a candidate information library, or generated through other methods.
[0071] In one embodiment, the CAPTCHA variable corresponding to the target CAPTCHA type is input into the language model. Based on this variable, the language model generates global and local CAPTCHA description information corresponding to the target CAPTCHA type. The language model then outputs these two descriptions. Here, the language model refers to a large language model, which is a deep learning model trained on massive amounts of text data, capable of generating natural language text and understanding its semantics.
[0072] In the above embodiments, based on the verification code variable corresponding to the target verification code type, global verification code description information and local verification code description information corresponding to the target verification code type are generated, so that the global verification code description information and local verification code description information have randomness, thereby helping to improve the scalability of the verification code image.
[0073] In one embodiment, based on the target CAPTCHA type, global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type are generated, including:
[0074] Randomly generate the variable value of the verification code variable corresponding to the target verification code type, and determine the target foreground object set from the candidate object set based on the variable value;
[0075] Based on the foreground object attribute requirements corresponding to the target CAPTCHA type, generate local description information for each target foreground object in the target foreground object set;
[0076] Local CAPTCHA description information is obtained based on the local description information;
[0077] Background description information is generated based on each local description information, and the global CAPTCHA description information is obtained by merging the local description information and the background description information.
[0078] The CAPTCHA variable corresponding to the target CAPTCHA type refers to the variable controlling the target foreground object in the CAPTCHA image. For example, the CAPTCHA variable could be a variable controlling the number, shape, or position of the foreground object. The target foreground object is the foreground object the user needs to identify during verification. For instance, if the target CAPTCHA type is a spatial reasoning CAPTCHA, the target foreground object could be various geometric objects in the CAPTCHA image. The user needs to identify the correct geometric object through spatial reasoning; if the user identifies it correctly, the verification succeeds; if the user identifies it incorrectly, the verification fails.
[0079] The candidate object set includes multiple candidate objects. A candidate object is selected from the candidate object set as the target foreground object. The target foreground object set includes at least one target foreground object. It is understood that the candidate object set can include a wide variety of candidate objects. For example, the candidate object set may include various texts, various items, etc.
[0080] The foreground object attribute requirements corresponding to the target CAPTCHA type refer to the attribute requirements of the target foreground object in the CAPTCHA image corresponding to the target CAPTCHA type, which indicates which attributes the target foreground object needs to have.
[0081] The local description information corresponding to the target foreground object is used to describe the target foreground object. This local description information includes the specific attribute values of the target foreground object under the foreground object attribute requirements corresponding to the target CAPTCHA type. For example, if the foreground object attribute requirements corresponding to the target CAPTCHA type include the foreground object's shape, then the local description information corresponding to the target foreground object includes the specific shape of the target foreground object. Of course, the local description information corresponding to the target foreground object can also include the specific attribute values of the target foreground object in other foreground object attributes.
[0082] Background description information is used to describe the background of the CAPTCHA image.
[0083] Specifically, when generating global and local CAPTCHA description information based on the CAPTCHA variable corresponding to the target CAPTCHA type, the target foreground object can be determined first based on the CAPTCHA variable corresponding to the target CAPTCHA type, and local description information corresponding to the target foreground object can be generated. Local CAPTCHA description information can be obtained based on the local description information. In addition, background description information can be generated based on the local description information, and global CAPTCHA description information can be obtained based on the local description information and the background description information.
[0084] The computer device randomly generates the variable value of the verification code variable corresponding to the target verification code type, and determines the target foreground object set from the candidate object set based on this variable value. For example, if the verification code variable corresponding to the target verification code type includes a variable for the number of foreground objects, the number of foreground objects is randomly generated. If the number of foreground objects is specifically 3, then 3 candidate objects are randomly selected from the candidate object set as target foreground objects, and these 3 target foreground objects are combined into a target foreground object set. As another example, if the verification code variable corresponding to the target verification code type includes a variable for the shape of the foreground objects, the shape of the foreground objects is randomly generated. If the shape of the foreground object is specifically a car shape, then a car object is randomly selected from the candidate object set as a target foreground object, and all target foreground objects are combined into a target foreground object set. Next, the computer device generates local description information corresponding to each target foreground object in the target foreground object set based on the foreground object attribute requirements corresponding to the target verification code type. Specifically, it can determine the various foreground object attributes that the target foreground object must possess based on the foreground object attribute requirements corresponding to the target verification code type, and for any target foreground object, randomly generate the specific attribute values of each foreground object attribute to form the local description information corresponding to the target foreground object. It can be understood that different target foreground objects correspond to different local description information. Finally, the computer device obtains local CAPTCHA description information based on the various local description information. Furthermore, the computer device can generate matching background description information based on these local description information, ensuring that the background and foreground of the final CAPTCHA image match. For example, based on the local description information, foreground features such as style, color, material, and lighting are determined; image features such as style, color, material, and lighting that match the foreground features are used as background features, and background description information is obtained based on these background features. These local description information pieces are then combined to form the local CAPTCHA description information. Finally, the computer device fuses the local and background description information to obtain the global CAPTCHA description information. For example, semantic fusion of the local and background description information yields the global CAPTCHA description information. Alternatively, the local and background description information can be input into a large language model for semantic fusion to obtain the global CAPTCHA description information. Another example is combining the local and background description information to form the global CAPTCHA description information.
[0085] In one embodiment, a verification code request object corresponding to the target verification code type is determined, and a set of promotional objects corresponding to the verification code request object is obtained. This set of promotional objects is then used as a candidate object set. Specifically, the verification code request object corresponding to the target verification code type refers to the object requesting to obtain the verification code image corresponding to the target verification code type. For example, the verification code request object can be a customer who needs verification code services. The set of promotional objects corresponding to the verification code request object includes at least one promotional object corresponding to the verification code request object. A promotional object refers to an object that needs to be advertised and promoted. The promotional object corresponding to the verification code request object refers to an object owned by the verification code request object that needs to be promoted. For example, if the verification code request object is company A, the set of promotional objects corresponding to the verification code request object can include a product set designed by company A. Products are selected from the product set as target foreground objects, and a verification code image containing the target foreground object is generated. In this way, when generating the verification code image, the customer's promotional object is used as the target foreground object. Subsequently, when using the verification code image for verification, the customer can be promoted simultaneously. This is a new promotion method that can improve the effectiveness of promotion and expand the functionality of verification code images.
[0086] In one embodiment, background description information is generated based on the application scenario corresponding to the target CAPTCHA type and various local descriptive information. For example, the background complexity is determined based on the application scenario corresponding to the target CAPTCHA type, and background description information conforming to the background complexity is generated based on the various local descriptive information. For example, background complexity is positively correlated with the risk coefficient of the application scenario; application scenarios with higher risk coefficients use more complex backgrounds to improve the defensiveness of the CAPTCHA image, making it difficult to crack. Background complexity can be reflected by features such as the number of background elements, color changes, and area. Thus, by further combining the application scenario of the CAPTCHA image with the background description information generated based on various local descriptive information, the image quality of the CAPTCHA image can be further improved.
[0087] In the above embodiments, variable values for CAPTCHA variables are randomly generated. Based on these variable values, a target foreground object set is determined from the candidate object set, allowing different CAPTCHA images to contain different target foreground objects, thereby improving the diversity and scalability of CAPTCHA images. Based on the foreground object attribute requirements corresponding to the target CAPTCHA type, local description information is generated for each target foreground object in the target foreground object set. Local CAPTCHA description information is obtained based on these local description information, thus containing the local description information corresponding to each target foreground object. Background description information is generated based on these local description information, ensuring that the background and foreground match. The local description information and background description information are then fused to obtain global CAPTCHA description information, thus containing both foreground and background information.
[0088] In one embodiment, determining the target foreground object set from the candidate object set based on variable values includes:
[0089] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the number of foreground objects is determined based on the variable values, and candidate objects that match the number of foreground objects are randomly selected from the candidate object set to form the target foreground object set.
[0090] Among them, object recognition CAPTCHAs distinguish between real users and bots based on the user's ability to recognize objects. For example, an object recognition CAPTCHA could be a text selection CAPTCHA, where the user needs to select specific text from the CAPTCHA image. If the selection is correct, the verification is successful, and the user is a real user; if the selection is incorrect, the verification fails, and the user is a bot. Spatial reasoning CAPTCHAs distinguish between real users and bots based on the user's spatial reasoning ability. The number of foreground objects refers to the number of target foreground objects that must be included in the CAPTCHA image.
[0091] Specifically, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the CAPTCHA variables include variables related to the number of foreground objects. The computer device can determine the number of foreground objects based on the variable values of the CAPTCHA variables and randomly select candidate objects from the candidate object set that match the number of foreground objects to form the target foreground object set. For example, if the randomly generated number of foreground objects is 4, then 4 candidate objects are randomly selected from the candidate object set to form the target foreground object set.
[0092] In one embodiment, determining the target foreground object set from the candidate object set based on variable values includes:
[0093] When the target CAPTCHA type is a differential annotation CAPTCHA, the position of the foreground object is determined based on the variable value, and candidate objects that match the position of the foreground object are randomly selected from the candidate object set to form the target foreground object set.
[0094] Among them, difference-annotated CAPTCHAs distinguish between real users and bots by having users identify differences between similar images. Foreground object location refers to the image location of the target foreground object that must be included in the CAPTCHA image.
[0095] Specifically, when the target CAPTCHA type is a difference-annotated CAPTCHA, the CAPTCHA variables include variables related to the position of the foreground object. The computer device can determine the position of the foreground object based on the variable values and randomly select candidate objects from the candidate object set that match the foreground object position to form the target foreground object set. For example, if the randomly generated foreground object position is the upper left corner of the image, then candidate objects suitable for placing in the upper left corner of the image are randomly selected from the candidate object set to form the target foreground object set. The candidate object set can include the recommended image position corresponding to each candidate object, and candidate objects whose recommended image position and foreground object position match are used as candidate objects that match the foreground object position. Matching the recommended image position and the foreground object position can be defined as the positional difference between the recommended image position and the foreground object position being less than a preset threshold.
[0096] In the above embodiments, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the CAPTCHA variables include variables related to the number of foreground objects. This allows different CAPTCHA images to contain different numbers of target foreground objects, thereby improving the diversity and scalability of the CAPTCHA images. When the target CAPTCHA type is a difference-annotated CAPTCHA, the CAPTCHA variables include variables related to the position of the foreground objects. This allows different CAPTCHA images to contain target foreground objects at different image positions, further improving the diversity and scalability of the CAPTCHA images.
[0097] In one embodiment, when the target CAPTCHA type is an object recognition CAPTCHA, the foreground object attributes corresponding to the target CAPTCHA type are required to include at least one of the following attributes: foreground object position, foreground object shape, etc. That is, when the target CAPTCHA type is an object recognition CAPTCHA, the local description information corresponding to the target foreground object is used to describe at least one of the following attributes: image position, shape, etc., of the target foreground object in the CAPTCHA image. When the target CAPTCHA type is a spatial reasoning CAPTCHA, the foreground object attributes corresponding to the target CAPTCHA type are required to include at least one of the following attributes: foreground object position, foreground object shape, foreground object color, foreground object size, etc. That is, when the target CAPTCHA type is a spatial reasoning CAPTCHA, the local description information corresponding to the target foreground object is used to describe at least one of the following attributes: image position, shape, color, size, etc., of the target foreground object in the CAPTCHA image. When the target CAPTCHA type is a difference-annotated CAPTCHA, the foreground object attributes corresponding to the target CAPTCHA type are required to include attributes such as foreground object position. That is, when the target CAPTCHA type is a difference-annotated CAPTCHA, the local description information corresponding to the target foreground object is used to describe attributes such as the image position, etc., of the target foreground object in the CAPTCHA image.
[0098] In one embodiment, based on the target CAPTCHA type, global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type are generated, including:
[0099] Get the design hints for the CAPTCHA image corresponding to the target CAPTCHA type; the CAPTCHA image design hints include a design introduction and design examples for the target CAPTCHA type;
[0100] Input the CAPTCHA image design prompts into the language model so that the language model can design the CAPTCHA image based on the design prompts and output the global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type with reference to the design sample.
[0101] Among them, the language model refers to the large language model, which is a deep learning model trained on massive amounts of text data. It can generate natural language text and understand its semantics.
[0102] The CAPTCHA image design hints are input prompts to the language model, guiding it in designing CAPTCHA images to generate global and local CAPTCHA descriptions. Different CAPTCHA types correspond to different design hints. The CAPTCHA image design hints for the target CAPTCHA type include a design introduction and a design example. The design introduction for the target CAPTCHA type provides an overview of the design process, guiding the language model in the design. The design example for the target CAPTCHA type is an example of the CAPTCHA image design result. The language model observes and imitates the design example to output a new CAPTCHA image design result. The CAPTCHA image design result includes global and local CAPTCHA descriptions.
[0103] Specifically, in order to improve the accuracy of global and local CAPTCHA description information, language models can be used to generate global and local CAPTCHA description information.
[0104] After obtaining the target CAPTCHA type, the computer device can acquire the corresponding CAPTCHA image design hints. These hints are then input into a language model. The language model designs the CAPTCHA image based on the hints, generating global and local CAPTCHA descriptions for the target CAPTCHA type, and outputting these descriptions. The language model learns and understands the CAPTCHA image design task through these hints, thereby outputting new and accurate global and local CAPTCHA descriptions. The CAPTCHA image design hints for the target CAPTCHA type include a design introduction and a design example. The language model designs the CAPTCHA image based on the design introduction and outputs the global and local CAPTCHA descriptions for the target CAPTCHA type, referring to the design example.
[0105] In one embodiment, the design description corresponding to the target CAPTCHA type includes CAPTCHA variables corresponding to the target CAPTCHA type, which are used to guide the model to design CAPTCHA images based on the CAPTCHA variables.
[0106] In a specific application, taking object recognition CAPTCHAs as an example, the CAPTCHA image design prompts for object recognition CAPTCHAs are as follows:
[0107] # Role: Poster Designer
[0108] ##Profile (Overview)
[0109] Language: Chinese
[0110] -Description: Your task is to design a poster that features the foreground object as the main subject, with a reasonable layout, aesthetic appeal, and harmonious composition.
[0111] -Background: Possesses a background in design, art, and communications, specializing in poster design.
[0112] -Personality: Meticulous, detail-oriented, and possesses strong spatial imagination.
[0113] ##Require
[0114] - All given foreground objects must be shown on the poster; none may be omitted.
[0115] -The poster's dimensions are both 1024.
[0116] - The image is harmonious and unified, possessing rich artistic beauty.
[0117] ## Workflow
[0118] 1. Randomly determine the foreground object
[0119] 2. Based on the given foreground object, select an appropriate style and background.
[0120] 3. Determine the position of each foreground object and provide a local description.
[0121] 4. Provide an overall description of the image.
[0122] ## example
[0123] Output: {Overall Image Description: This image depicts a warm interior scene. In the foreground are a yellow teddy bear, a red toy car, and a colorful toy castle. The background shows a simply decorated room with wooden chairs, green plants, and picture frames and shelves on the wall. Ample natural light streams in from the left window, creating a playful and joyful atmosphere that evokes a comfortable and warm feeling of family life.} {Partial Image Description: {"Toy Winnie the Pooh": (200, 650, 400, 850, A yellow teddy bear dressed in red, resembling the classic Winnie the Pooh, sitting on the floor with a smile, looking very cute), "Toy Car": (500, 800, 600, 850, A red toy car with exquisite details, resembling a classic toy car), "Toy Castle": (650, 550, 800, 850, A colorful toy castle with red and green spires on top, adorned with small flags; the castle's design is playful and rich in detail)}}
[0124] In the above embodiments, the CAPTCHA image design prompts corresponding to the target CAPTCHA type enable the model to quickly adapt to the CAPTCHA image design task, demonstrating flexible learning ability. The language model designs CAPTCHA images using the CAPTCHA image design prompts corresponding to the target CAPTCHA type, and can output global and local CAPTCHA description information corresponding to the target CAPTCHA type without model training.
[0125] In one embodiment, reference description information is determined from global and local CAPTCHA description information based on the target CAPTCHA type, including:
[0126] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the local CAPTCHA description information is used as the reference description information.
[0127] When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is used as the reference description information.
[0128] Specifically, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the main content of the CAPTCHA image is the image foreground. The computer device can use the local CAPTCHA description information as reference description information to first draw the foreground of the CAPTCHA image to ensure the accuracy of the image subject.
[0129] When the target CAPTCHA type is a differential annotation CAPTCHA, the main content of the CAPTCHA image is the image background. The computer device can use the global CAPTCHA description information as a reference description information to first draw the overall CAPTCHA image to ensure the accuracy of the image subject.
[0130] In one embodiment, determining the foreground information of the target CAPTCHA based on local CAPTCHA description information and a reference image includes:
[0131] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the reference image is the foreground object image corresponding to each target foreground object. The foreground object region is segmented from the foreground object image. Based on the image position corresponding to the target foreground object in the local CAPTCHA description information, the foreground object regions are combined to obtain the initial CAPTCHA image. The target CAPTCHA foreground information is obtained based on the initial CAPTCHA image.
[0132] The foreground object image corresponding to the target foreground object is an image that uses the target foreground object as the main subject. The foreground object region is the area where the target foreground object is located in the foreground object image. The local CAPTCHA description information includes the image position corresponding to the target foreground object. The image position corresponding to the target foreground object refers to the image position of the target foreground object in the CAPTCHA image. The initial CAPTCHA image refers to the initial CAPTCHA image, and correspondingly, the target CAPTCHA image refers to the final CAPTCHA image.
[0133] Specifically, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the local CAPTCHA description information includes local description information corresponding to each target foreground object. This local CAPTCHA description information is used as reference description information, and an image is generated based on this reference description information to obtain foreground object images corresponding to each target foreground object. The computer device performs image segmentation on the foreground object images, segmenting foreground object regions from the foreground object images to obtain foreground object regions corresponding to each target foreground object. For example, the foreground object image is input into an object segmentation model to obtain foreground object regions. Based on the image positions corresponding to each target foreground object in the local CAPTCHA description information, the various foreground object regions are combined to obtain the initial CAPTCHA image. That is, based on the image positions corresponding to each target foreground object in the local CAPTCHA description information, the various foreground object regions are stitched together to obtain the initial CAPTCHA image. Finally, the computer device uses the initial CAPTCHA image as the foreground information for the target CAPTCHA.
[0134] In the above embodiments, when the target verification code type is an object recognition verification code or a spatial reasoning verification code, foreground object images corresponding to each target foreground object are generated first to ensure the accuracy of the appearance of the target foreground object. Then, the foreground object region is segmented from the foreground object image. Based on the image position of the target foreground object in the local verification code description information, the foreground object regions are combined to obtain the initial verification code image to ensure the accuracy of the position of the target foreground object in the verification code image.
[0135] In one embodiment, an image is generated based on global CAPTCHA description information and target CAPTCHA foreground information to obtain a target CAPTCHA image corresponding to the target CAPTCHA type, including:
[0136] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the background of the initial CAPTCHA image is drawn based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0137] Specifically, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the foreground information of the target CAPTCHA includes the initial CAPTCHA image. When generating the target CAPTCHA image based on the global CAPTCHA description information and the target CAPTCHA foreground information, the computer device can perform background rendering on the initial CAPTCHA image based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type. For example, a background image can be generated based on the global CAPTCHA description information, and the initial CAPTCHA image and the background image can be fused to obtain the target CAPTCHA image. Another example is that the global CAPTCHA description information and the initial CAPTCHA image can be input into a text-based graph model, allowing the text-based graph model to perform background rendering on the initial CAPTCHA image based on the global CAPTCHA description information to obtain the target CAPTCHA image, which is then output.
[0138] In the above embodiments, when the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the background is supplemented in the initial CAPTCHA image based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type. In this way, by first generating an initial CAPTCHA image containing accurate target foreground objects, and then supplementing the background in the initial CAPTCHA image to obtain the target CAPTCHA image, the accuracy of the foreground and background can be guaranteed, thus improving image quality.
[0139] In a specific application, refer to Figure 3This section describes the image generation process for CAPTCHAs based on object recognition or spatial reasoning. First, a Large Language Model (LLM) is used to generate an overall image description of the CAPTCHA image. The LLM then generates individual descriptions for each foreground object, and finally, it generates the location information (position information within the CAPTCHA image) of each foreground object. Next, leveraging the text-to-image generation capability of a visual generative model, foreground object images are generated based on the individual object descriptions. A combination of object detection and object segmentation models is used to segment the foreground objects from their respective images. After segmenting all foreground objects, they are stitched together according to their location information to obtain a complete foreground image. Finally, using the foreground image and the overall image description as conditions, the visual generative model's redrawing capability is used to complete the background, resulting in the final CAPTCHA image. The visual generative model can also draw the background within the foreground image based on the overall image description, thus obtaining the CAPTCHA image.
[0140] In a specific application, refer to Figure 4 This section describes the image generation process for CAPTCHAs based on object recognition or spatial reasoning. First, a Large Language Model (LLM) is used to generate an overall image description of the CAPTCHA image. The LLM then generates individual descriptions for each foreground object, and finally, it generates the location information (position information within the CAPTCHA image) of each foreground object. Next, leveraging the text-to-image generation capability of a visual generative model, foreground object images are generated based on the individual object descriptions. A combination of object detection and object segmentation models is used to segment the foreground objects from their respective images. After segmenting all foreground objects, they are stitched together according to their location information to obtain a complete foreground image and a foreground mask image. Using the foreground image, foreground mask image, and overall image description as conditions, the redrawing capability of the visual LLM is used to complete the corresponding background image, resulting in the complete CAPTCHA image. The visual LLM can also draw the background in the foreground mask image based on the overall image description, obtaining a background image. Finally, the foreground and background images are fused based on the foreground mask image to obtain the CAPTCHA image.
[0141] In one embodiment, determining the foreground information of the target CAPTCHA based on local CAPTCHA description information and a reference image includes:
[0142] When the target CAPTCHA type is a difference-annotated CAPTCHA, the reference image is the first CAPTCHA image. Based on the local CAPTCHA description information, the current image position corresponding to the target foreground object is determined from the first CAPTCHA image. Based on the current image position and the first CAPTCHA image, the target CAPTCHA foreground information is obtained.
[0143] The CAPTCHA images corresponding to the difference-annotated type include CAPTCHA image pairs. Each CAPTCHA image pair includes a first CAPTCHA image and a second CAPTCHA image. The first CAPTCHA image includes the target foreground object, while the second CAPTCHA image does not. The first and second CAPTCHA images are identical in content except for the presence or absence of the target foreground object. The current image position corresponding to the target foreground object refers to its position within the first CAPTCHA image.
[0144] Specifically, when the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is used as reference description information, and an image is generated based on the reference description information to obtain the first CAPTCHA image. The computer device can determine the current image position corresponding to the target foreground object from the first CAPTCHA image based on the local CAPTCHA description information, which includes local description information corresponding to the target foreground object. The target foreground object is identified from the first CAPTCHA image based on the local description information, and its image position in the first CAPTCHA image is taken as its current image position. Furthermore, the computer device obtains the target CAPTCHA foreground information based on the current image position of the target foreground object and the first CAPTCHA image.
[0145] In the above embodiments, when the target CAPTCHA type is a difference-annotated CAPTCHA, a first CAPTCHA image is generated first, and then the current image position corresponding to the target foreground object is determined from the first CAPTCHA image based on the local CAPTCHA description information. This can obtain the most accurate image position of the target foreground object, thereby helping to ensure the accuracy of the subsequent generation of the second CAPTCHA image.
[0146] In one embodiment, an image is generated based on global CAPTCHA description information and target CAPTCHA foreground information to obtain a target CAPTCHA image corresponding to the target CAPTCHA type, including:
[0147] When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is adjusted based on the current image position to obtain updated CAPTCHA description information. Based on the updated CAPTCHA description information, the first CAPTCHA image, and the current image position, the image is redrawn to obtain the second CAPTCHA image. Based on the first CAPTCHA image and the second CAPTCHA image, the target CAPTCHA image corresponding to the target CAPTCHA type is obtained.
[0148] For difference-annotated CAPTCHAs, the global CAPTCHA description includes information about the target foreground object, while the updated CAPTCHA description does not. The CAPTCHA image corresponding to a difference-annotated CAPTCHA consists of a CAPTCHA image pair. Each CAPTCHA image pair includes a first CAPTCHA image and a second CAPTCHA image. The first CAPTCHA image includes the target foreground object, while the second CAPTCHA image does not. The first and second CAPTCHA images are identical in content except for the presence or absence of the target foreground object.
[0149] Specifically, when the target CAPTCHA type is a difference-annotated CAPTCHA, the target CAPTCHA foreground information includes a first CAPTCHA image and the current image position corresponding to the target foreground object. The computer device can adjust the global CAPTCHA description information based on the current image position corresponding to the target foreground object to obtain updated CAPTCHA description information. Specifically, information related to the target foreground object and information related to the current image position can be deleted from the global CAPTCHA description information to obtain updated CAPTCHA description information. Furthermore, the computer device can redraw the image based on the updated CAPTCHA description information, the first CAPTCHA image, and the current image position to obtain a second CAPTCHA image. Specifically, an image can be generated based on the updated CAPTCHA description information to obtain an updated CAPTCHA image; based on the first CAPTCHA image and the current image position, the updated CAPTCHA image can be corrected to obtain the second CAPTCHA image. It can be understood that the first CAPTCHA image and the second CAPTCHA image are identical in all image positions except for the image content at the current image position. The first CAPTCHA image has a target foreground object at the current image position, while the second CAPTCHA image does not have a target foreground object at the current image position. Finally, the computer device obtains the target CAPTCHA image corresponding to the target CAPTCHA type based on the first CAPTCHA image and the second CAPTCHA image. For example, the first and second CAPTCHA images can be combined to form a CAPTCHA image pair, which can then be used as the target CAPTCHA image. Alternatively, the first and second CAPTCHA images can be divided into n equal parts each, shuffled, and then concatenated to obtain a disordered first and second CAPTCHA image. This disordered first and second CAPTCHA image can then be combined to form a CAPTCHA image pair, which can then be used as the target CAPTCHA image.
[0150] In the above embodiments, when the target verification code type is a difference-annotated verification code, the global verification code description information is adjusted based on the current image position to obtain updated verification code description information. Based on the updated verification code description information, the first verification code image, and the current image position, the image is redrawn to obtain the second verification code image, so that the second verification code image and the first verification code image have different image regions at the current image position, but the same image regions at other image positions.
[0151] In a specific application, refer to Figure 5 This paper describes the generation process of the CAPTCHA image corresponding to the difference-annotated CAPTCHA. First, a large language model is used to generate an overall image description of the first CAPTCHA image, and then another large language model is used to generate an object-specific description of the foreground object to be redrawn. Next, the image-to-text generation capability of the large visual model is used to generate the first CAPTCHA image based on the overall image description. An object detection model is used to determine the current image position of the foreground object to be redrawn within the first CAPTCHA image. The overall image description of the first CAPTCHA image is adjusted using the large language model to obtain the overall image description of the second CAPTCHA image (i.e., updating the overall description). The descriptions related to the foreground object to be redrawn are removed from the overall image description of the first CAPTCHA image to obtain the overall image description of the second CAPTCHA image. Finally, based on the updated overall description, the first CAPTCHA image, and the current image position of the foreground object to be redrawn, the redrawing capability of the large visual model is used to generate a new image without the foreground object to be redrawn, resulting in the second CAPTCHA image. The target CAPTCHA image is obtained based on the first and second CAPTCHA images.
[0152] In one embodiment, the verification code image generation method further includes:
[0153] Based on the foreground information of the target CAPTCHA, generate a CAPTCHA question-answer pair corresponding to the target CAPTCHA image;
[0154] Perform artistic and functional verification on the target CAPTCHA image to obtain the image quality corresponding to the target CAPTCHA image;
[0155] When the image quality is greater than or equal to the quality threshold, the target CAPTCHA image and the CAPTCHA question-answer pair are associated and stored in the CAPTCHA database.
[0156] The verification question-and-answer pair corresponding to the CAPTCHA image refers to the question and its correct answer that the user needs to answer when verifying using the CAPTCHA image. The artistic and functional verification of the CAPTCHA image refers to checking its artistic merit and functionality to determine its image quality. The artistic merit of the CAPTCHA image characterizes its visual effect. The functional merit characterizes its accuracy. The CAPTCHA database is a database that stores CAPTCHA images and their corresponding verification question-and-answer pairs.
[0157] Specifically, the foreground information of the target CAPTCHA includes information related to the foreground of the target CAPTCHA image, which can be used to design the corresponding CAPTCHA question-and-answer pairs. Computer devices can generate CAPTCHA question-and-answer pairs based on the foreground information. For example, the foreground information can be input into a language model for CAPTCHA question-and-answer pair design to obtain the corresponding CAPTCHA question-and-answer pairs. Furthermore, the computer device can perform artistic and functional verification on the target CAPTCHA image, and obtain the image quality based on the verification results. Finally, the computer device filters low-quality target CAPTCHA images based on image quality, selects high-quality target CAPTCHA images, and associates the high-quality target CAPTCHA images and their corresponding CAPTCHA question-and-answer pairs into the CAPTCHA database. That is, when the image quality of the target CAPTCHA image is greater than or equal to a quality threshold, the target CAPTCHA image and its corresponding CAPTCHA question-and-answer pair are associated and stored in the CAPTCHA database.
[0158] In one embodiment, when the target CAPTCHA type is an object recognition CAPTCHA, the target CAPTCHA foreground information includes an initial CAPTCHA image. Foreground object regions for each target foreground object are determined based on the initial CAPTCHA image, and verification question-and-answer pairs corresponding to the target CAPTCHA image are generated based on the foreground object regions of each target foreground object. Specifically, the target foreground objects can be randomly arranged to obtain the verification question corresponding to the target CAPTCHA image, and the triggering order of each foreground object region is determined based on the arrangement order of the target foreground objects to obtain the verification answer corresponding to the verification question. For example, refer to... Figure 6 Object recognition CAPTCHAs include text selection CAPTCHAs and general object selection CAPTCHAs. Taking text selection CAPTCHAs as an example, the verification question requires users to click on the corresponding text in a specific order, and the verification answer is the correct click area and click order.
[0159] In one embodiment, when the target CAPTCHA type is a spatial reasoning CAPTCHA, the target CAPTCHA foreground information includes an initial CAPTCHA image. Foreground object attribute information for each target foreground object is determined based on the initial CAPTCHA image, and a CAPTCHA question-and-answer pair corresponding to the target CAPTCHA image is generated based on this foreground object attribute information. Specifically, the CAPTCHA question-and-answer pair corresponding to the target CAPTCHA image can be constructed based on a preset cross-reference operator. For example, the preset cross-reference operator A is comparing the area (width × height) of the objects. Two target foreground objects are randomly selected from each target foreground object, and a CAPTCHA question corresponding to the target CAPTCHA image is generated. The area of these two target foreground objects is determined based on their foreground object attribute information, and the CAPTCHA answer corresponding to the CAPTCHA question is obtained. For example, refer to... Figure 7 Spatial reasoning CAPTCHAs require users to deduce the answer by observing the CAPTCHA image.
[0160] In one embodiment, when the target CAPTCHA type is "image-based CAPTCHA matching," the target CAPTCHA foreground information includes a first CAPTCHA image and the current image position corresponding to the target foreground object. A verification question corresponding to the target CAPTCHA image is generated, and a verification answer corresponding to the verification question is generated based on the current image position corresponding to the target foreground object. For example, refer to... Figure 8 The image-based CAPTCHA matching problem requires users to piece together an image and find the different image blocks to verify the correct image block.
[0161] In the above embodiments, based on the foreground information of the target CAPTCHA, a verification question-and-answer pair corresponding to the target CAPTCHA image is generated. The target CAPTCHA image undergoes artistic and functional verification to obtain its image quality. When the image quality is greater than or equal to a quality threshold, the target CAPTCHA image and the verification question-and-answer pair are associated and stored in the CAPTCHA library. Thus, after generating the target CAPTCHA image, further artistic and functional verification is performed on it, filtering out low-quality target CAPTCHA images, which helps to further improve the image quality of the CAPTCHA images. The CAPTCHA library is used to store high-quality CAPTCHA images, which helps to improve the service quality of the CAPTCHA service.
[0162] In one embodiment, the target CAPTCHA image is subjected to artistic and functional verification to obtain the image quality corresponding to the target CAPTCHA image, including:
[0163] Perform an artistic verification on the target CAPTCHA image to obtain the target artistic quality of the target CAPTCHA image;
[0164] Based on the target CAPTCHA type, the target CAPTCHA image is functionally verified to obtain the target functionality corresponding to the target CAPTCHA image.
[0165] The image quality corresponding to the target CAPTCHA image is determined based on the target artistic quality and target functional quality.
[0166] The artistic verification of CAPTCHA images refers to verifying their aesthetic appeal. The artistic quality of a CAPTCHA image is a quantitative indicator of its artistic merit. The functional verification of CAPTCHA images refers to verifying their functionality. The functional quality of a CAPTCHA image is a quantitative indicator of its functionality.
[0167] Specifically, when performing artistic and functional verification on the target CAPTCHA image, artistic and functional verification can be performed separately, and the image quality corresponding to the target CAPTCHA image can be obtained by combining the results of artistic and functional verification.
[0168] Computer devices can perform artistic verification on target CAPTCHA images to obtain the target artistic score. For example, an artistic scoring model can be trained, the target CAPTCHA image can be input into the artistic scoring model, and the model can output the target artistic score. Computer devices can also perform functional verification on target CAPTCHA images based on the target CAPTCHA type to obtain the target functional score. Different CAPTCHA types use different functional verification methods. Finally, the computer device determines the image quality of the target CAPTCHA image based on the target artistic score and target functional score. For example, the target artistic score and target functional score can be fused to obtain a comprehensive score, which is then used as the image quality of the target CAPTCHA image. Alternatively, if the target artistic score is greater than or equal to an artistic score threshold and the target functional score is greater than or equal to a functional score threshold, the image quality of the target CAPTCHA image is determined to be greater than or equal to a quality threshold; if the target artistic score is less than an artistic score threshold or the functional score is less than a functional score threshold, the image quality of the target CAPTCHA image is determined to be less than a quality threshold.
[0169] In the above embodiments, the target CAPTCHA image is subjected to artistic verification to obtain the target artistic quality corresponding to the target CAPTCHA image. Based on the target CAPTCHA type, the target CAPTCHA image is subjected to functional verification to obtain the target functional quality corresponding to the target CAPTCHA image. By combining the target artistic quality and the target functional quality, the image quality corresponding to the target CAPTCHA image is determined, which can improve the accuracy of image quality.
[0170] In one embodiment, based on the target CAPTCHA type, a functional verification is performed on the target CAPTCHA image to obtain the target functionality corresponding to the target CAPTCHA image, including:
[0171] When the target CAPTCHA type is an object recognition CAPTCHA, the target CAPTCHA image is segmented to obtain the foreground object region corresponding to each target foreground object. The uniqueness of the target foreground object is verified based on the foreground object region. The integrity of the foreground object region is verified based on the answer in the CAPTCHA question-answer pair. Based on the uniqueness verification result and the integrity verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0172] Among these, uniqueness verification for foreground objects refers to verifying whether the foreground object is unique. Integrity verification for foreground object regions refers to verifying whether the foreground object region is complete.
[0173] Specifically, when performing functional verification on a target CAPTCHA image, if the target CAPTCHA type is an object recognition CAPTCHA, the target functionality of the target CAPTCHA image can be determined by performing uniqueness verification and integrity verification.
[0174] Computer equipment can perform image segmentation on the target CAPTCHA image to obtain the foreground object regions corresponding to each target foreground object. Uniqueness verification is then performed on the target foreground objects based on these regions. If one target foreground object corresponds to multiple foreground object regions, the uniqueness verification result is determined to be a failure; if one target foreground object corresponds to one foreground object region, the uniqueness verification result is determined to be a success. Based on the answer in the CAPTCHA question-answering pair, integrity verification is performed on the foreground object regions. If the image region indicated by the answer contains the foreground object region, the integrity verification result is determined to be a success; otherwise, the integrity verification result is determined to be a failure. Finally, the computer equipment can obtain the target functionality corresponding to the target CAPTCHA image based on the uniqueness verification result and the integrity verification result. For example, if both the uniqueness verification result and the integrity verification result are successful, the target functionality corresponding to the target CAPTCHA image is determined to be greater than or equal to a functionality threshold.
[0175] In one embodiment, based on the target CAPTCHA type, a functional verification is performed on the target CAPTCHA image to obtain the target functionality corresponding to the target CAPTCHA image, including:
[0176] When the target CAPTCHA type is a difference-annotated CAPTCHA, the first CAPTCHA image and the second CAPTCHA image in the target CAPTCHA image are compared to obtain the difference image region. Based on the answer in the CAPTCHA question-answer pair, the difference image region is verified for consistency. Based on the consistency verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0177] The difference image region refers to the image region where there is a difference between the first CAPTCHA image and the second CAPTCHA image. Consistency verification of the difference image region means verifying whether the difference image region is consistent with the image region indicated by the answer.
[0178] Specifically, when performing functional verification on a target CAPTCHA image, if the target CAPTCHA type is a difference-annotated CAPTCHA, the target functionality of the target CAPTCHA image can be determined by comparing the first CAPTCHA image and the second CAPTCHA image.
[0179] The computer device can compare the first and second CAPTCHA images in the target CAPTCHA image to obtain the difference image region. Specifically, it can calculate the difference between the pixel values of corresponding pixels in the first and second CAPTCHA images, and define the region consisting of pixels with a difference greater than a preset threshold as the difference image region. Then, based on the answer in the CAPTCHA question-and-answer pair, the computer device can perform a consistency verification on the difference image region. If the image region indicated by the answer contains the difference image region, the consistency verification result is considered successful; otherwise, the consistency verification result is considered unsuccessful. Finally, based on the consistency verification result, the computer device obtains the target functionality corresponding to the target CAPTCHA image. For example, if all consistency verification results are successful, the target functionality corresponding to the target CAPTCHA image is determined to be greater than or equal to a functionality threshold.
[0180] In one embodiment, based on the target CAPTCHA type, a functional verification is performed on the target CAPTCHA image to obtain the target functionality corresponding to the target CAPTCHA image, including:
[0181] When the target CAPTCHA type is a spatial reasoning CAPTCHA, the target CAPTCHA image is segmented to obtain the foreground object region corresponding to each target foreground object. Based on the foreground object region, the foreground object attribute information corresponding to the target foreground object is determined. Based on the foreground object attribute information, the accuracy of the verification question-answer pair is verified. Based on the accuracy verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0182] Here, foreground object attribute information refers to the attribute information of the foreground object. Accuracy verification of the validation question-and-answer pair refers to verifying whether the answer is accurate.
[0183] Specifically, when performing functional verification on a target CAPTCHA image, if the target CAPTCHA type is a spatial reasoning CAPTCHA, the target functionality of the target CAPTCHA image can be determined by extracting the foreground object attribute information of the target foreground object from the target CAPTCHA image.
[0184] Computer equipment can perform image segmentation on the target CAPTCHA image to obtain the foreground object regions corresponding to each target foreground object. Based on these foreground object regions, the equipment can determine the foreground object attribute information. Specifically, various image features of the target foreground objects can be extracted from the foreground object regions to obtain the corresponding foreground object attribute information. For example, the color of the target foreground object can be extracted from the foreground object region to obtain the corresponding color attribute information, and the size of the target foreground object can be extracted from the foreground object region to obtain the corresponding size attribute information. Furthermore, based on the foreground object attribute information, the computer equipment can perform accuracy verification on the CAPTCHA question-answer pair. It verifies whether the answer to the question is accurate. If the answer is accurate, the accuracy verification result is considered successful; otherwise, the accuracy verification result is considered unsuccessful. Finally, based on the accuracy verification result, the computer equipment can obtain the target functionality corresponding to the target CAPTCHA image. For example, if all accuracy verification results are successful, the target functionality corresponding to the target CAPTCHA image is determined to be greater than or equal to a functionality threshold.
[0185] In the above embodiments, different functional verification methods are used for different types of CAPTCHA images, which can effectively ensure the accuracy of functional verification.
[0186] In one embodiment, the verification code image generation method further includes:
[0187] When the verification complexity corresponding to the target CAPTCHA type is greater than or equal to the complexity threshold, the process proceeds to the step of generating global and local CAPTCHA description information based on the target CAPTCHA type, until the target CAPTCHA image corresponding to the target CAPTCHA type is obtained.
[0188] When the verification complexity corresponding to the target CAPTCHA type is less than the complexity threshold, a global CAPTCHA description information corresponding to the target CAPTCHA type is generated based on the target CAPTCHA type, and an image is generated based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0189] The verification complexity of a CAPTCHA type refers to the complexity of verifying the CAPTCHA image corresponding to that type. This complexity can be determined based on factors such as the application scenario of the CAPTCHA image, the number of user operations during the verification process, and the average verification time. For example, more operations result in higher verification complexity; a longer average verification time also results in higher complexity; and a higher risk factor in the application scenario leads to higher verification complexity.
[0190] Specifically, when the verification complexity corresponding to the target CAPTCHA type is greater than or equal to a complexity threshold, a target CAPTCHA image corresponding to the target CAPTCHA type is obtained through two-stage image rendering. When the verification complexity corresponding to the target CAPTCHA type is greater than or equal to the complexity threshold, the computer device can generate global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type. Based on the target CAPTCHA type, reference description information is determined from the global and local CAPTCHA description information. An image is generated based on the reference description information to obtain a reference image. Based on the local CAPTCHA description information and the reference image, target CAPTCHA foreground information is determined. An image is generated based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0191] When the verification complexity corresponding to the target CAPTCHA type is less than a complexity threshold, the target CAPTCHA image is obtained through a one-stage image rendering process. When the verification complexity corresponding to the target CAPTCHA type is less than the complexity threshold, the computer device can generate global CAPTCHA description information corresponding to the target CAPTCHA type. For example, the target CAPTCHA type can be input into a language model to obtain the global CAPTCHA description information. Furthermore, the computer device can generate an image based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type. For example, the global CAPTCHA description information can be input into an image generation model to obtain the target CAPTCHA image.
[0192] In one embodiment, when the verification complexity corresponding to the target CAPTCHA type is greater than or equal to a complexity threshold, the step of generating global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type based on the CAPTCHA variables corresponding to the target CAPTCHA type is executed until the target CAPTCHA image corresponding to the target CAPTCHA type is obtained; when the verification complexity corresponding to the target CAPTCHA type is less than a complexity threshold, global CAPTCHA description information corresponding to the target CAPTCHA type is generated based on the CAPTCHA variables corresponding to the target CAPTCHA type, and an image is generated based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0193] In one embodiment, object recognition CAPTCHAs are divided into text recognition CAPTCHAs and other object recognition CAPTCHAs. The target CAPTCHA image corresponding to the text recognition CAPTCHA can be obtained through a one-stage image rendering process. The target CAPTCHA image corresponding to the other object recognition CAPTCHAs can be obtained through a two-stage image rendering process.
[0194] refer to Figure 9For text recognition-based CAPTCHAs, a large language model is used to generate a comprehensive image description, which includes the text displayed in the foreground, the image position of the foreground text, and a description of the image background. The large language model then converts this comprehensive image description into a text-to-image prompt. This prompt is input into a visual large model, which generates a CAPTCHA image that matches the comprehensive image description.
[0195] In the above embodiments, for CAPTCHA types with high verification complexity, a two-stage image rendering process is used to generate the corresponding CAPTCHA image, ensuring the accuracy of the generated CAPTCHA image. For CAPTCHA types with low verification complexity, a one-stage image rendering process is used to generate the corresponding CAPTCHA image, ensuring the efficiency of CAPTCHA image generation.
[0196] In a specific embodiment, the method of this application can be applied to CAPTCHA scenarios. This application provides a CAPTCHA image generation method based on a large language model and a large visual model, capable of generating CAPTCHA images with functionality, scalability, high defense, and aesthetic appeal. Functionality means that the generated CAPTCHA image can distinguish between real users and computational users by being paired with corresponding questions, thus realizing the function of a graphical CAPTCHA. Scalability means that it can generate a larger number of non-repeating CAPTCHA images within a reasonable timeframe as demand increases. High defense means that the generated CAPTCHA image is difficult for attackers to crack or requires a high attack cost to achieve an attack. Aesthetic appeal means that the generated CAPTCHA image has a certain artistic beauty, providing users with an aesthetic experience.
[0197] refer to Figure 10 This application's method enables batch generation of CAPTCHA images. It leverages the instruction following and reasoning planning capabilities of a large language model to generate CAPTCHA descriptions, corresponding verification questions, and answers that conform to human aesthetics. It utilizes the controllable generation capabilities of a large visual model to generate CAPTCHA images based on the descriptions. After generating the CAPTCHA images, they can be filtered and stored in a database. Functional and artistic verification is performed on the generated CAPTCHA images, filtering out those with poor functionality or aesthetics. For CAPTCHA images that meet functional and artistic requirements, the CAPTCHA image, verification question, and answer are combined into a CAPTCHA triplet and stored in the CAPTCHA database for later use. Each time the front-end calls the CAPTCHA service, a CAPTCHA triplet is randomly selected from the database and returned to the front-end. The CAPTCHA image and verification question from the triplet are then displayed to the user, and the user's actions and the answers in the triplet are used to distinguish between real users and bots.
[0198] refer to Figure 11This application proposes two methods for generating CAPTCHA images: a one-stage CAPTCHA generation method and a two-stage CAPTCHA generation method. The one-stage CAPTCHA generation method generates and fuses the foreground and background images simultaneously through a single computation of a large visual model. The two-stage CAPTCHA generation method generates and fuses the foreground and background images through two computations of the large visual model. In the two-stage CAPTCHA generation method, a portion of the CAPTCHA image is first generated based on the large visual model, and then the CAPTCHA image is supplemented or redrawn based on the large visual model to obtain the complete CAPTCHA image. For example, text-based CAPTCHAs and spatial reasoning CAPTCHAs can use the one-stage CAPTCHA generation method, while general object-based CAPTCHAs and puzzle-finding-different-difference CAPTCHAs can use the two-stage CAPTCHA generation method.
[0199] The method in this application utilizes the instruction following and reasoning planning capabilities of large language models and the controllable generation capabilities of large visual models to generate a large number of CAPTCHA images that are both aesthetically pleasing and highly defensive.
[0200] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0201] Based on the same inventive concept, this application also provides a verification code image generation apparatus for implementing the verification code image generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more verification code image generation apparatus embodiments provided below can be found in the limitations of the verification code image generation method described above, and will not be repeated here.
[0202] In one embodiment, such as Figure 12 As shown, a verification code image generation device is provided, including: a verification code type acquisition module 1202, a verification code description information generation module 1204, a reference description information determination module 1206, a reference image generation module 1208, a verification code foreground information determination module 1210, and a verification code image generation module 1212, wherein:
[0203] The verification code type acquisition module 1202 is used to acquire the target verification code type.
[0204] The verification code description information generation module 1204 is used to generate global verification code description information and local verification code description information corresponding to the target verification code type based on the target verification code type.
[0205] The reference description information determination module 1206 is used to determine reference description information from global verification code description information and local verification code description information based on the target verification code type.
[0206] The reference image generation module 1208 is used to generate an image based on reference description information to obtain a reference image.
[0207] The verification code foreground information determination module 1210 is used to determine the foreground information of the target verification code based on the local verification code description information and the reference image.
[0208] The verification code image generation module 1212 is used to generate an image based on the global verification code description information and the target verification code foreground information, so as to obtain the target verification code image corresponding to the target verification code type.
[0209] In one embodiment, the verification code description information generation module 1204 is further configured to:
[0210] Randomly generate the variable value of the verification code variable corresponding to the target verification code type, and determine the target foreground object set from the candidate object set based on the variable value;
[0211] Based on the foreground object attribute requirements corresponding to the target CAPTCHA type, generate local description information for each target foreground object in the target foreground object set;
[0212] Local CAPTCHA description information is obtained based on the local description information;
[0213] Background description information is generated based on each local description information, and the global CAPTCHA description information is obtained by merging the local description information and the background description information.
[0214] In one embodiment, the verification code description information generation module 1204 is further configured to:
[0215] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the number of foreground objects is determined based on the variable values, and candidate objects that match the number of foreground objects are randomly selected from the candidate object set to form the target foreground object set;
[0216] When the target CAPTCHA type is a differential annotation CAPTCHA, the position of the foreground object is determined based on the variable value, and candidate objects that match the position of the foreground object are randomly selected from the candidate object set to form the target foreground object set.
[0217] In one embodiment, the verification code description information generation module 1204 is further configured to:
[0218] Get the design hints for the CAPTCHA image corresponding to the target CAPTCHA type; the CAPTCHA image design hints include a design introduction and design examples for the target CAPTCHA type;
[0219] Input the CAPTCHA image design prompts into the language model so that the language model can design the CAPTCHA image based on the design prompts and output the global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type with reference to the design sample.
[0220] In one embodiment, the reference description information determination module 1206 is further configured to:
[0221] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the local CAPTCHA description information is used as the reference description information.
[0222] When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is used as the reference description information.
[0223] In one embodiment, the verification code foreground information determination module 1210 is further configured to:
[0224] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the reference image is the foreground object image corresponding to each target foreground object. The foreground object region is segmented from the foreground object image. Based on the image position corresponding to the target foreground object in the local CAPTCHA description information, the foreground object regions are combined to obtain the initial CAPTCHA image. The target CAPTCHA foreground information is obtained based on the initial CAPTCHA image.
[0225] In one embodiment, the verification code image generation module 1212 is further configured to:
[0226] When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the background of the initial CAPTCHA image is drawn based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0227] In one embodiment, the verification code foreground information determination module 1210 is further configured to:
[0228] When the target CAPTCHA type is a difference-annotated CAPTCHA, the reference image is the first CAPTCHA image. Based on the local CAPTCHA description information, the current image position corresponding to the target foreground object is determined from the first CAPTCHA image. Based on the current image position and the first CAPTCHA image, the target CAPTCHA foreground information is obtained.
[0229] In one embodiment, the verification code image generation module 1212 is further configured to:
[0230] When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is adjusted based on the current image position to obtain updated CAPTCHA description information. Based on the updated CAPTCHA description information, the first CAPTCHA image, and the current image position, the image is redrawn to obtain the second CAPTCHA image. Based on the first CAPTCHA image and the second CAPTCHA image, the target CAPTCHA image corresponding to the target CAPTCHA type is obtained.
[0231] In one embodiment, the verification code image generating apparatus is further used for:
[0232] Based on the foreground information of the target CAPTCHA, generate a CAPTCHA question-answer pair corresponding to the target CAPTCHA image;
[0233] Perform artistic and functional verification on the target CAPTCHA image to obtain the image quality corresponding to the target CAPTCHA image;
[0234] When the image quality is greater than or equal to the quality threshold, the target CAPTCHA image and the CAPTCHA question-answer pair are associated and stored in the CAPTCHA database.
[0235] In one embodiment, the verification code image generating apparatus is further used for:
[0236] Perform an artistic verification on the target CAPTCHA image to obtain the target artistic quality of the target CAPTCHA image;
[0237] Based on the target CAPTCHA type, the target CAPTCHA image is functionally verified to obtain the target functionality corresponding to the target CAPTCHA image.
[0238] The image quality corresponding to the target CAPTCHA image is determined based on the target artistic quality and target functional quality.
[0239] In one embodiment, the verification code image generating apparatus is further used for:
[0240] When the target CAPTCHA type is an object recognition CAPTCHA, the target CAPTCHA image is segmented to obtain the foreground object region corresponding to each target foreground object. The uniqueness of the target foreground object is verified based on the foreground object region. The integrity of the foreground object region is verified based on the answer in the CAPTCHA question-answer pair. Based on the uniqueness verification result and the integrity verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0241] When the target CAPTCHA type is a difference-annotated CAPTCHA, the first CAPTCHA image and the second CAPTCHA image in the target CAPTCHA image are compared to obtain the difference image region. Based on the answer in the CAPTCHA question-answer pair, the difference image region is verified for consistency. Based on the consistency verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0242] When the target CAPTCHA type is a spatial reasoning CAPTCHA, the target CAPTCHA image is segmented to obtain the foreground object region corresponding to each target foreground object. Based on the foreground object region, the foreground object attribute information corresponding to the target foreground object is determined. Based on the foreground object attribute information, the accuracy of the verification question-answer pair is verified. Based on the accuracy verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
[0243] In one embodiment, the verification code image generating apparatus is further used for:
[0244] When the verification complexity corresponding to the target CAPTCHA type is greater than or equal to the complexity threshold, the process proceeds to the step of generating global and local CAPTCHA description information based on the target CAPTCHA type, until the target CAPTCHA image corresponding to the target CAPTCHA type is obtained.
[0245] When the verification complexity corresponding to the target CAPTCHA type is less than the complexity threshold, a global CAPTCHA description information corresponding to the target CAPTCHA type is generated based on the target CAPTCHA type, and an image is generated based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
[0246] The aforementioned CAPTCHA image generation device generates global and local CAPTCHA description information corresponding to the target CAPTCHA type. Based on the target CAPTCHA type, it determines reference description information from the global and local CAPTCHA description information. An image is then generated based on the reference description information to obtain a reference image. By first drawing the more important information in the CAPTCHA image corresponding to the target CAPTCHA type, the image quality of the final CAPTCHA image is ensured. The device then determines the target CAPTCHA foreground information based on the local CAPTCHA description information and the reference image. An image is then generated based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type. Image rendering based on more detailed information ensures the foreground and overall quality of the final CAPTCHA image. In summary, obtaining a CAPTCHA image through two-stage image rendering based on global and local CAPTCHA description information improves the image quality of the CAPTCHA image, resulting in a more aesthetically pleasing and richer CAPTCHA image.
[0247] Each module in the aforementioned verification code image generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0248] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 13 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data related to the CAPTCHA image generation method. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a CAPTCHA image generation method.
[0249] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 14As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a method for generating verification code images. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0250] Those skilled in the art will understand that Figure 13 , Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0251] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0252] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0253] In one embodiment, a computer program product is provided, the computer program product including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0254] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0255] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, etc., and are not limited to these.
[0256] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0257] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for generating a verification code image, characterized in that, The method includes: Obtain the target verification code type; Based on the target CAPTCHA type, generate global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type; Based on the target CAPTCHA type, reference description information is determined from the global CAPTCHA description information and the local CAPTCHA description information; An image is generated based on the reference description information to obtain a reference image; Based on the local CAPTCHA description information and the reference image, the foreground information of the target CAPTCHA is determined; An image is generated based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
2. The method according to claim 1, characterized in that, The step of generating global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type includes: Randomly generate the variable value of the verification code variable corresponding to the target verification code type, and determine the target foreground object set from the candidate object set based on the variable value; Based on the foreground object attribute requirements corresponding to the target CAPTCHA type, generate local description information corresponding to each target foreground object in the target foreground object set; Local CAPTCHA description information is obtained based on the local description information; Background description information is generated based on the local description information, and global CAPTCHA description information is obtained by fusing the local description information and the background description information.
3. The method according to claim 2, characterized in that, The step of determining the target foreground object set from the candidate object set based on the variable values includes: When the target verification code type is an object recognition verification code or a spatial reasoning verification code, the number of foreground objects is determined based on the variable value, and candidate objects that match the number of foreground objects are randomly selected from the candidate object set to form a target foreground object set; When the target CAPTCHA type is a differential annotation CAPTCHA, the position of the foreground object is determined based on the variable value, and candidate objects that match the position of the foreground object are randomly selected from the candidate object set to form the target foreground object set.
4. The method according to claim 1, characterized in that, The step of generating global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type includes: Obtain the CAPTCHA image design prompts corresponding to the target CAPTCHA type; the CAPTCHA image design prompts include a design introduction and design examples corresponding to the target CAPTCHA type; The CAPTCHA image design prompt is input into the language model so that the language model designs the CAPTCHA image based on the design prompt, and outputs the global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type with reference to the design example.
5. The method according to claim 1, characterized in that, The step of determining reference description information from the global CAPTCHA description information and the local CAPTCHA description information based on the target CAPTCHA type includes: When the target verification code type is an object recognition verification code or a spatial reasoning verification code, the local verification code description information is used as the reference description information; When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is used as the reference description information.
6. The method according to claim 1, characterized in that, Determining the foreground information of the target CAPTCHA based on the local CAPTCHA description information and the reference image includes: When the target verification code type is an object recognition verification code or a spatial reasoning verification code, the reference image is the foreground object image corresponding to each target foreground object. The foreground object region is segmented from the foreground object image. Based on the image position corresponding to the target foreground object in the local verification code description information, the foreground object regions are combined to obtain the initial verification code image. The target verification code foreground information is obtained based on the initial verification code image.
7. The method according to claim 6, characterized in that, The step of generating an image based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type includes: When the target CAPTCHA type is an object recognition CAPTCHA or a spatial reasoning CAPTCHA, the background of the initial CAPTCHA image is drawn based on the global CAPTCHA description information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type.
8. The method according to claim 1, characterized in that, The step of determining the foreground information of the target CAPTCHA based on the local CAPTCHA description information and the reference image includes: When the target CAPTCHA type is a difference-annotated CAPTCHA, the reference image is the first CAPTCHA image. Based on the local CAPTCHA description information, the current image position corresponding to the target foreground object is determined from the first CAPTCHA image. Based on the current image position and the first CAPTCHA image, the target CAPTCHA foreground information is obtained.
9. The method according to claim 8, characterized in that, The step of generating an image based on the global CAPTCHA description information and the target CAPTCHA foreground information to obtain the target CAPTCHA image corresponding to the target CAPTCHA type includes: When the target CAPTCHA type is a difference-annotated CAPTCHA, the global CAPTCHA description information is adjusted based on the current image position to obtain updated CAPTCHA description information. Based on the updated CAPTCHA description information, the first CAPTCHA image, and the current image position, the image is redrawn to obtain a second CAPTCHA image. Based on the first CAPTCHA image and the second CAPTCHA image, the target CAPTCHA image corresponding to the target CAPTCHA type is obtained.
10. The method according to claim 1, characterized in that, The method further includes: Based on the foreground information of the target CAPTCHA, a CAPTCHA question-answer pair corresponding to the target CAPTCHA image is generated; The target CAPTCHA image is subjected to artistic and functional verification to obtain the image quality corresponding to the target CAPTCHA image; When the image quality is greater than or equal to the quality threshold, the target CAPTCHA image and the CAPTCHA question-answer pair are associated and stored in the CAPTCHA database.
11. The method according to claim 10, characterized in that, The step of performing artistic and functional verification on the target CAPTCHA image to obtain the image quality corresponding to the target CAPTCHA image includes: Perform an artistic verification on the target CAPTCHA image to obtain the target artistic quality corresponding to the target CAPTCHA image; Based on the target CAPTCHA type, the target CAPTCHA image is functionally verified to obtain the target functionality corresponding to the target CAPTCHA image; Based on the target artistic quality and the target functional quality, the image quality corresponding to the target CAPTCHA image is determined.
12. The method according to claim 11, characterized in that, The step of performing functional verification on the target CAPTCHA image based on the target CAPTCHA type to obtain the target functionality corresponding to the target CAPTCHA image includes: When the target verification code type is an object recognition verification code, the target verification code image is segmented to obtain the foreground object region corresponding to each target foreground object. The uniqueness of the target foreground object is verified based on the foreground object region. The integrity of the foreground object region is verified based on the answer in the verification question-answer pair. Based on the uniqueness verification result and the integrity verification result, the target functional degree corresponding to the target verification code image is obtained. When the target CAPTCHA type is a difference-annotated CAPTCHA, the first CAPTCHA image and the second CAPTCHA image in the target CAPTCHA image are compared to obtain the difference image region. Based on the answer in the CAPTCHA question-answer pair, the difference image region is subjected to consistency verification. Based on the consistency verification result, the target functional degree corresponding to the target CAPTCHA image is obtained. When the target CAPTCHA type is a spatial reasoning CAPTCHA, the target CAPTCHA image is segmented to obtain the foreground object region corresponding to each target foreground object. Based on the foreground object region, the foreground object attribute information corresponding to the target foreground object is determined. Based on the foreground object attribute information, the accuracy of the CAPTCHA question-answer pair is verified. Based on the accuracy verification result, the target functional degree corresponding to the target CAPTCHA image is obtained.
13. The method according to any one of claims 1 to 12, characterized in that, The method further includes: When the verification complexity corresponding to the target CAPTCHA type is greater than or equal to a complexity threshold, the step of generating global CAPTCHA description information and local CAPTCHA description information corresponding to the target CAPTCHA type is executed until the target CAPTCHA image corresponding to the target CAPTCHA type is obtained. When the verification complexity corresponding to the target verification code type is less than the complexity threshold, a global verification code description information corresponding to the target verification code type is generated based on the target verification code type, and an image is generated based on the global verification code description information to obtain the target verification code image corresponding to the target verification code type.
14. A verification code image generation device, characterized in that, The device includes: The verification code type acquisition module is used to obtain the target verification code type; The verification code description information generation module is used to generate global verification code description information and local verification code description information corresponding to the target verification code type based on the target verification code type. The reference description information determination module is used to determine reference description information from the global verification code description information and the local verification code description information based on the target verification code type. The reference image generation module is used to generate an image based on the reference description information to obtain a reference image; The verification code foreground information determination module is used to determine the foreground information of the target verification code based on the local verification code description information and the reference image; The verification code image generation module is used to generate an image based on the global verification code description information and the target verification code foreground information, so as to obtain the target verification code image corresponding to the target verification code type.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 13.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 13.
17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 13.
