Image-based cartoon animation generation method, device, equipment and storage medium

By dividing image areas, detecting key point transformation relationships and performing global transformation during cartoon video generation, the problem of action and posture errors between cartoon videos and template videos in the existing technology is solved, and the authenticity of cartoon videos is improved.

CN114782592BInactive Publication Date: 2024-09-06CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210458983.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2024-09-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When generating cartoon videos in the existing technology, the affine transformation matrix does not take into account the different movement amplitudes of different key points, resulting in errors in the action poses of the cartoon video and the action poses of the template video.

Method used

By dividing the cartoon image to be driven into different areas, detecting and determining the transformation relationship of key points in each area, performing global transformation, generating pixel motion data, training the deep learning model, generating a cartoon pose transfer network, and reducing the cartoon transfer video and template video Error in action posture.

Benefits of technology

It improves the authenticity of the cartoon video, reduces the error in the action posture between the cartoon migration video and the template video, and the generated cartoon video is closer to the action posture of the template video.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114782592B
    Figure CN114782592B
Patent Text Reader

Abstract

The present invention provides an image-based cartoon animation generation method, device, equipment and storage medium. A reference image is selected from a video frame of a template video as a target image. The target image and a cartoon image to be driven are respectively divided into different areas. The transformation relationship of different areas is obtained according to the coordinates of key points in different areas. Different transformations are performed on key points with different movement amplitudes so that the key points obtain more accurate movement rules and the authenticity of the cartoon migration video is improved. Then, the transformation relationship of different areas is globally transformed to obtain a global transformation relationship. Pixel motion data is obtained according to the global transformation relationship. A deep learning model is trained based on the cartoon image to be driven and the pixel motion data to generate a cartoon posture migration network. The cartoon image to be driven is input into the cartoon posture migration network generated based on the template video to obtain a cartoon migration video with a smaller error with the template video action posture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to an image-based cartoon animation generation method, device, computer equipment and storage medium. Background Art

[0002] As a hot topic in computer graphics, scholars have conducted many years of research on how to generate cartoon videos with computer assistance, and have achieved rich results. There are many methods for generating cartoon videos of human faces. In the generation process, the cartoon image is generally converted into the action posture of the image in the video frame through affine transformation, and the corresponding posture in the video is generated to complete the migration of the action.

[0003] In the prior art, when performing affine transformation, the affine transformation matrix is ​​obtained by transforming the coordinates of key points, without considering the different movement amplitudes of different key points and the impact on the affine transformation matrix, resulting in errors between the action postures in the generated cartoon video and the migrated action postures in the template video. Summary of the invention

[0004] In view of this, the embodiments of the present invention provide a method, apparatus, device and storage medium for generating cartoon animation based on an image, so as to solve the problem that there is an error between the action posture of the generated cartoon migration video and the action of the template video.

[0005] In a first aspect, a method for generating a cartoon animation based on an image is provided, the method comprising:

[0006] Input the cartoon image to be driven into the cartoon posture transfer network generated based on the template video to obtain the cartoon transfer video;

[0007] The cartoon posture transfer network generation process includes:

[0008] Select a reference image from the video frame of the template video as the target image, divide the target image into a first target area and a second target area, and divide the cartoon image to be driven into a first area to be driven and a second area to be driven; the first target area and the first area to be driven are both the upper half of the face area including the eyes, and the second target area and the second area to be driven are both the lower half of the face area including the jawline;

[0009] Detecting each key point in the target image and the cartoon image to be driven, and determining the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven;

[0010] Performing a global transformation on the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship;

[0011] Generate pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0012] Based on the to-be-driven cartoon image and the pixel motion data, a deep learning model is trained to generate a cartoon gesture transfer network.

[0013] In a second aspect, a cartoon animation generating device based on an image is provided, the device comprising:

[0014] Input unit: inputs the cartoon image to be driven into the cartoon posture transfer network generated based on the template video to obtain the cartoon transfer video;

[0015] A division unit: selects a reference image from the video frame of the template video as a target image, divides the target image into a first target area and a second target area, and divides the cartoon image to be driven into a first area to be driven and a second area to be driven; the first target area and the first area to be driven are both the upper half of the face area including the eyes, and the second target area and the second area to be driven are both the lower half of the face area including the jawline;

[0016] A detection unit: detecting each key point in the target image and the cartoon image to be driven, and determining a transformation relationship between the key points in the first target area and the first area to be driven, and a transformation relationship between the key points in the second target area and the second area to be driven;

[0017] A global unit: globally transforming the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship;

[0018] A generating unit: generating pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0019] Training unit: Based on the to-be-driven cartoon image and the pixel motion data, a deep learning model is trained to generate a cartoon posture transfer network.

[0020] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, an image-based cartoon animation generation method as described in the first aspect is implemented.

[0021] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image-based cartoon animation generation method as described in the first aspect is implemented.

[0022] Compared with the prior art, the present invention has the following beneficial effects:

[0023] The present invention provides an image-based cartoon animation generation method, which comprises the following steps: selecting a reference image as a target image from a video frame of a template video, dividing the target image and a cartoon image to be driven into different regions respectively, obtaining transformation relationships of different regions according to the coordinates of key points of different regions, respectively obtaining different transformation relationships, performing different transformations on key points with different movement amplitudes, so that the key points obtain more accurate movement rules, and improving the authenticity of a cartoon migration video; then globally transforming the transformation relationships of different regions to obtain a global transformation relationship, obtaining pixel motion data according to the global transformation relationship, training a deep learning model based on the cartoon image to be driven and the pixel motion data, generating a cartoon posture migration network, inputting the cartoon image to be driven into the cartoon posture migration network generated based on the template video, and obtaining a cartoon migration video with a smaller error with the template video action posture. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0025] Figure 1 This is a schematic diagram of an application environment of an image-based cartoon animation generation method provided in the first embodiment of the present invention;

[0026] Figure 2 It is a flowchart of a method for generating cartoon animation based on an image provided by the first embodiment of the present invention;

[0027] Figure 3 is a flowchart of a method for generating cartoon animation based on an image provided by Embodiment 2 of the present invention;

[0028] Figure 4 is a flowchart of a method for generating cartoon animation based on an image provided by Embodiment 3 of the present invention;

[0029] Figure 5 It is a structural schematic diagram of an image-based cartoon animation generating device provided by an embodiment of the present invention;

[0030] Figure 6 The present invention is a schematic diagram of the structure of a computer device for an image-based cartoon animation generation method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0032] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0033] It should also be understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0034] As used in the present specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]", depending on the context.

[0035] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0036] References to "one embodiment" or "some embodiments" etc. described in the present specification mean that one or more embodiments of the present invention include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0037] The embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0038] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0039] It should be understood that the order of execution of the steps in the following embodiments does not imply a precedence of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0040] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.

[0041] The first embodiment of the present invention provides a method for generating cartoon animation based on an image, which can be applied in the following aspects: Figure 1 In the application environment, the client communicates with the server. The client includes but is not limited to a PDA, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA) and other computer devices. The server can be implemented by an independent server or a server cluster composed of multiple servers.

[0042] See also Figure 2, is a flowchart of a method for generating cartoon animation based on an image provided by the first embodiment of the present invention. The method for generating cartoon animation based on an image can be applied to Figure 1 In the client, the corresponding computer device connects to the target database through a preset application programming interface (API). When the target data is driven to execute the corresponding task, a corresponding task log will be generated, and the above task log can be collected through the API. Figure 2 As shown, the image-based cartoon animation generation method may include the following steps:

[0043] S11: inputting the cartoon image to be driven into a cartoon posture transfer network generated based on the template video to obtain a cartoon transfer video;

[0044] In step S11, the cartoon image to be driven is the image to be obtained with the cartoon image, the cartoon posture transfer network generated based on the template video is the trend of the motion posture of the template video, and the cartoon image to be driven is input into the cartoon posture transfer network generated based on the template video to generate a cartoon transfer video with the same motion posture as the template video.

[0045] In this embodiment, the cartoon image to be driven is a cartoon image of a head containing a positive human face, and the template video is a video of head posture changes containing a person's head portrait. In the cartoon posture migration network generated based on the template video, the head posture movement in the template video is migrated to the cartoon image, and the head in the cartoon image is driven to move to generate a cartoon migration video.

[0046] S12: selecting a reference image from the video frame of the template video as a target image, dividing the target image into a first target area and a second target area, and dividing the to-be-driven cartoon image into a first to-be-driven area and a second to-be-driven area;

[0047] In step S12, the target image is a video frame image in a template video, and the face area in the target image is divided into two parts, including a target first area and a target second area. The target first area is the upper area including the eyes, and the target second area is the part including the jaw line of the face. The image to be driven is divided into two parts in the same way to obtain the first area to be driven and the second area to be driven.

[0048] In this embodiment, when selecting a reference image from a template video, the next adjacent frame reference image in the video frame with the same posture as the cartoon image to be driven in the template video frame is selected as the target image, and the face area of ​​the head part in the target image and the cartoon image to be driven is processed in blocks, and the face area is divided into different areas to facilitate more accurate calculation of the conversion relationship between different areas, so that the pixels in different areas can obtain more accurate movement data. In this embodiment, the face area is divided into upper and lower parts. Considering that when the head posture changes, the transformation action of the upper part of the face area will be greater than the transformation action of the lower part, the face area is divided into upper and lower parts.

[0049] S13: Detecting each key point in the target image and the cartoon image to be driven, and determining the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven;

[0050] In step S13, according to the preset key point detection model, key point detection is performed on the target image and the cartoon image to be driven. During the key point detection, the number of keys obtained in the same area in the target image and the cartoon image to be driven is the same as the position of the key point. According to the key point detection result, the key point coordinates in the target first area and the key point coordinates in the target second area in the target image, as well as the key point coordinates in the first area to be driven and the key point coordinates in the cartoon image to be driven are obtained. According to the key point coordinates in the target first area in the target image and the key point coordinates in the first area to be driven in the cartoon image to be driven, the key point transformation relationship between the target first area and the first area to be driven is obtained by calculation. According to the key point coordinates in the target second area in the target image and the key point coordinates in the second area to be driven in the cartoon image to be driven, the key point transformation relationship between the target second area and the second area to be driven is obtained by calculation.

[0051] In this embodiment, feature point detection is performed on the face area, and a pre-trained face key point detection model is used. When training the face key point detection model, multiple feature points are manually calibrated for each pair of sample training faces and cartoon images. These points are mainly marked on the geometric contours of the facial contour and facial features. When marking the points, it is important to note that the feature points should cover important positions of the contour, such as the jaw line, the corners of the eyes, the corners of the mouth, and the tip of the nose. At the same time, the position of each feature point calibrated in each image should be basically the same, so as to reduce the error of the average value of the points, and the face feature point detection model is obtained through training.

[0052] According to the pre-trained facial feature point detection model, key points in different areas of the target image and the cartoon image to be driven are detected, and the key point coordinates in the target first area and the key point coordinates in the target second area in the target image, as well as the key point coordinates in the first area to be driven and the key point coordinates in the second area to be driven in the cartoon image to be driven are obtained.

[0053] It should be noted that the key points in the target image and the cartoon image to be driven are in a corresponding relationship. There are corresponding key points in the same position of the target image and the cartoon image to be driven. The corresponding key points can be moved from one key point to another corresponding key point position through affine transformation. Therefore, by calculating the transformation relationship of the key points, the moving direction and distance of the key points can be estimated.

[0054] In this embodiment, according to the detected key point coordinates, the key points are affine transformed to obtain the transformation relationship between different areas. The key points in the first area of ​​the target image and the first area of ​​the image to be driven are transformed by affine transformation to obtain the transformation relationship between the key points in the first area of ​​the target image and the first area to be driven. The key points in the second area of ​​the target image and the second area of ​​the image to be driven are transformed by affine transformation to obtain the transformation relationship between the key points in the second area of ​​the target image and the second area to be driven.

[0055] It should be noted that in the second area of ​​the face area, the number of key points is relatively small, mainly concentrated in the jaw line part of the face area. When calculating the affine transformation with relatively few key points, the error of the affine transformation relationship obtained is relatively large. More key points can be obtained according to the interpolation method. First, the key points of the jaw line area are fitted to obtain a fitting curve, and multiple key points in the fitting curve are extracted from the fitting curve, so as to obtain multiple key points in the second area of ​​the face area. Based on the affine transformation of multiple key points, a more accurate transformation relationship of the key points in the second area can be obtained.

[0056] S14: globally transforming the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship;

[0057] In step S14, the key point transformation relationship between the target first area and the first area to be driven and the key point transformation relationship between the target second area and the second area to be driven are local transformation relationships in the face area. When performing head posture migration, the entire face area needs to be driven, so the local transformation relationship is transformed globally to obtain the global transformation relationship of the entire face area.

[0058] In this embodiment, in order to reduce the affine transformation error between the target image and the cartoon image to be driven, the local transformation relationship is globalized to obtain the global transformation relationship. When performing global transformation processing, the weight is determined by the pseudo centroid weighting method, and the average value of the key point coordinates in each area is used. is the centroid, and the specific formula is:

[0059]

[0060] In formula (1) and formula (2), M is the number of key points in any area of ​​the cartoon image to be driven, (x i ,y i ) is the coordinate of the key point in any region, then the corresponding weight w in each region j for:

[0061]

[0062] In formula (3), when j is 1, w j is the weight of the key point transformation relationship in the first region. When j is 2, w j is the weight of the key point transformation relationship in the second region, is the coordinate of the centroid, X p is the coordinate of the corresponding key point in any area of ​​the cartoon image to be driven, and σ is the Gaussian scaling factor.

[0063] The global transformation relationship is obtained according to the weight of the key point transformation relationship between the first target area and the first area to be driven and the weight of the key point transformation relationship between the second target area and the second area to be driven. Based on the key point coordinate calculation results, the present invention distributes weights to different areas, which can smooth the image distortion caused by the local transformation relationship. The present invention takes into account the image of the local transformation relationship on the change relationship of the entire image, so that the obtained global transformation relationship is more accurate. When the posture in the template video is generated by the cartoon image to be driven, the action posture in the corresponding template video frame can be generated more accurately.

[0064] S15: generating pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0065] In step S15, the pixel motion data is the motion data of pixels associated with the head posture change of the cartoon image to be driven moving to the specified pixel position, and the pixel motion data includes the motion direction of the pixels in the head area of ​​the cartoon image to be driven pointing to the matching target pixels in the target image.

[0066] In this embodiment, according to the global transformation relationship and the cartoon image to be driven, the movement direction of the head posture in the cartoon image to be driven can be determined, and the direction is a vector direction, which is used as pixel movement data.

[0067] In this embodiment, step S15 specifically includes:

[0068] The cartoon image to be driven and the global transformation relationship are input into a pre-trained dense motion estimation model to obtain pixel motion data output by the dense motion estimation model.

[0069] In this embodiment, the pre-trained dense motion estimation model is a deep learning model, which is composed of basic neural network structures such as convolutional layers, fully connected layers, activation layers, pooling layers, and normalization layers, or other Encoder-Decoder model structures. The transformation parameters in the global transformation relationship are input, and the pixel motion data is obtained after calculation by the network's convolutional layers, fully connected layers, activation layers, pooling layers, normalization layers, etc.

[0070] It should be noted that when training the dense motion estimation model, the minimum value of the optical measurement error between the video frame of the template video and the spatial transformation video frame is used as the training target, and the deep learning model is trained to generate a dense motion estimation model; wherein the spatial transformation video frame is generated by inputting the video frame of the template video into the spatial transformation model. By training the dense motion estimation model, the dense motion estimation model can learn the motion characteristics of the optical flow, so that the pixel motion data can be accurately extracted.

[0071] S16: Based on the cartoon image to be driven and the pixel motion data, a deep learning model is trained to generate a cartoon gesture transfer network.

[0072] In step S16, the cartoon posture transfer network is used to drive the head in the cartoon image to be driven to change its posture, so that the head posture in the template video is transferred to the cartoon image to be driven. In the process of moving the pixels in the head area to the matching pixel positions in the specified head posture, it is necessary to determine the direction and position distance of the movement, etc. The pixel motion data of the cartoon image to be driven to be transformed into the target image is learned by learning the model, and the cartoon image to be driven can be adjusted to the corresponding posture according to the head posture features in the template video.

[0073] In this embodiment, the generated pixel data is used as a training sample to train the deep learning model so that the cartoon posture transfer network can learn the pixel motion data from the head-driven posture driving features. The training process is to learn the changing trend of the pixel motion data so that the cartoon posture transfer network can learn the correct corresponding relationship, thereby completing the training of the cartoon posture transfer network.

[0074] The present invention provides an image-based cartoon animation generation method, which comprises the following steps: selecting a reference image as a target image from a video frame of a template video, dividing the target image and a cartoon image to be driven into different regions respectively, obtaining transformation relationships of different regions according to the coordinates of key points of different regions, respectively obtaining different transformation relationships, performing different transformations on key points with different movement amplitudes, so that the key points obtain more accurate movement rules, and improving the authenticity of a cartoon migration video; then globally transforming the transformation relationships of different regions to obtain a global transformation relationship, obtaining pixel motion data according to the global transformation relationship, training a deep learning model based on the cartoon image to be driven and the pixel motion data, generating a cartoon posture migration network, inputting the cartoon image to be driven into the cartoon posture migration network generated based on the template video, and obtaining a cartoon migration video with a smaller error with the template video action posture.

[0075] See also Figure 3 , is a flow chart of a method for generating cartoon animation based on an image provided by Embodiment 2 of the present invention. As shown in the figure, the method for generating cartoon animation may include the following steps:

[0076] S12: selecting a reference image from the video frame of the template video as a target image, dividing the target image into a first target area and a second target area, and dividing the to-be-driven cartoon image into a first to-be-driven area and a second to-be-driven area;

[0077] S13: Detecting each key point in the target image and the cartoon image to be driven, and determining the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven;

[0078] S14: globally transforming the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship;

[0079] S15: generating pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0080] S16: Based on the cartoon image to be driven and the pixel motion data, a deep learning model is trained to generate a cartoon gesture transfer network.

[0081] S21: Detecting the face region in the driven image by using a face detection algorithm, detecting the face region, and obtaining a positive face image according to a coordinate conversion algorithm;

[0082] S22: inputting the positive face image into the cartoon network to obtain a cartoon image to be driven corresponding to the positive face image;

[0083] S11: Input the cartoon image to be driven into the cartoon posture transfer network generated based on the template video to obtain a cartoon transfer video.

[0084] Among them, the contents of steps S12 to S16 in the second embodiment are the same as those of steps S12 to S16 in the first embodiment, and the contents of step S11 are the same as those of the above-mentioned step S11, which will not be repeated here. In this embodiment, the image to be driven is an image containing a face area, the face area is detected to obtain a face region of interest, and when detecting the face area, a convolutional neural network is used to detect the face area and key points in the face area, and the image to be driven is rotationally corrected according to the key point coordinates of the eye position in the detected face area. During the correction, the position coordinate information of the key points of the two eyes is used to calculate the rotation angle of the face area in the plane, and then the entire image is reversely rotated using the solved rotation angle, so that the key points of the two eyes will be on the same horizontal line, and a positive face image is obtained.

[0085] The positive face image is input into the cartoon network to convert the face in the image into a cartoon face. In this embodiment, the AgileGAN network is used to generate the cartoon image to be driven.

[0086] The cartoon animation generation method of this embodiment converts any image containing a face area into an image with a positive face, prepares for the subsequent key point detection of the face area, and inputs the positive face image into the cartoon network to obtain a cartoon image that is closer to the positive face, making the obtained cartoon image closer to the real character image.

[0087] See also Figure 4 , is a flow chart of a method for generating cartoon animation based on an image provided by Embodiment 3 of the present invention. As shown in the figure, the method for generating cartoon animation may include the following steps:

[0088] S12: selecting a reference image from the video frame of the template video as a target image, dividing the target image into a first target area and a second target area, and dividing the to-be-driven cartoon image into a first to-be-driven area and a second to-be-driven area;

[0089] S13: Detecting each key point in the target image and the cartoon image to be driven, and determining the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven;

[0090] S14: globally transforming the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship;

[0091] S15: generating pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0092] S16: Based on the to-be-driven cartoon image and the pixel motion data, training a deep learning model to generate a cartoon gesture transfer network;

[0093] S11: inputting the cartoon image to be driven into a cartoon posture transfer network generated based on the template video to obtain a cartoon transfer video;

[0094] The contents of step S12 to step S11 in the third embodiment are the same as those of step S12 to step S11 in the second embodiment, and are not described again here.

[0095] S31: synthesizing the cartoon migration video of the to-be-driven cartoon image with the pre-obtained speech to obtain a cartoon dynamic video.

[0096] In this embodiment, the cartoon migration video is a generated cartoon image video with head migration movements. The pre-acquired speech is processed to obtain the audio features of the speech, and the audio features are encoded and synthesized with the cartoon migration video to obtain a cartoon dynamic video with speech.

[0097] In this embodiment, step S31 specifically includes:

[0098] The video frame images corresponding to the cartoon migration video of the cartoon image to be driven and the pre-obtained speech are respectively encoded through different encoders to obtain the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of speech; the concatenated features of the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of speech are sent to the decoder to generate a target sequence image; the target sequence image is a cartoon image containing lip shape features; the target sequence image is synthesized with the uploaded speech to obtain a cartoon dynamic video.

[0099] In this embodiment, the pre-obtained speech is normalized, and the speech features are mainly Mel-spectrogram cepstrum features. Mel-spectrogram cepstrum uses a set of waiting-pass filters to filter the input speech signal, uses a suitable waiting width to remove the frequencies that the human ear cannot hear, and uses the output signal energy as the audio information of the speech signal. This method not only removes some frequencies that the human ear cannot hear, but also reduces the interference of high frequencies on the speech signal. Moreover, this method does not rely on the properties of the signal, has stronger robustness, and achieves better recognition performance in practical applications. By normalizing the pre-obtained speech, normalized audio information is obtained.

[0100] The cartoon migration video to drive the cartoon image and the normalized audio information are extracted at the same frame rate to obtain a first sequence of frame images and a second sequence of frame audios, respectively. The first sequence of frame images is encoded using a first encoder to obtain a cartoon image feature vector for each frame; the second sequence of frame audios is encoded using a second encoder to obtain a lip feature vector corresponding to each frame of audio. When encoding the second sequence of frame audios, the mapping relationship between audio information and lip features is trained using a pre-constructed multi-scale fusion convolutional neural network. The multi-scale fusion convolutional neural network is trained with audio information as input and lip feature vectors as output to achieve mapping fitting of audio information to lip features.

[0101] The concatenated features of the feature vector of each cartoon image frame and the lip shape feature vector corresponding to each speech frame are sent to the decoder to generate the target sequence image, which is a cartoon image containing lip shape features. The target sequence image is synthesized with the uploaded speech to obtain a cartoon dynamic video.

[0102] In the cartoon animation generation method of this embodiment, the cartoon migration video is synthesized with the pre-obtained voice, so that the lip shape of the cartoon character in the cartoon migration video corresponds to the pre-obtained voice, and different voices correspond to different lip shapes, and finally a cartoon dynamic video with voice is obtained, which makes the cartoon character in the cartoon migration video more vivid and lifelike.

[0103] Corresponding to the method of the above embodiment, Figure 5 The structural device block diagram of the image-based cartoon animation generation provided by the embodiment of the present invention is shown. The image-based cartoon animation generation device is applied to a computer device, and the computer device is connected to a target database through a preset application program interface. When the target database is driven to execute a corresponding task, a corresponding task log is generated, and the task log can be collected through the API. For the convenience of explanation, only the part related to the embodiment of the present invention is shown.

[0104] See also Figure 5 , the image-based cartoon animation generating device 40 comprises:

[0105] An input unit 41 is used to input the to-be-driven cartoon image into a cartoon posture transfer network generated based on a template video to obtain a cartoon transfer video;

[0106] A dividing unit 42 is used to select a reference image from the video frame of the template video as a target image, divide the target image into a target first area and a target second area, and divide the to-be-driven cartoon image into a to-be-driven first area and a to-be-driven second area; the target first area and the to-be-driven first area are both the upper half of the face area including the eyes, and the target second area and the to-be-driven second area are both the lower half of the face area including the jawline;

[0107] A detection unit 43 is used to detect each key point in the target image and the cartoon image to be driven, and determine the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven;

[0108] A global unit 44 is used to globally transform the key point transformation relationship between the target first area and the first area to be driven and the key point transformation relationship between the target second area and the second area to be driven to obtain a global transformation relationship;

[0109] A generating unit 45, configured to generate pixel motion data based on the cartoon image to be driven and the global transformation relationship;

[0110] The training unit 46 is used to train a deep learning model based on the to-be-driven cartoon image and the pixel motion data to generate a cartoon gesture transfer network.

[0111] As an embodiment of the present application, the image-based cartoon animation generating device 40 further includes:

[0112] The first execution unit 47 is used to detect the face area in the driven image by using a face detection algorithm, detect the face area, and obtain a positive face image according to a coordinate conversion algorithm;

[0113] The second execution unit 48 is used to input the positive face image into the cartoon network to obtain the cartoon image to be driven corresponding to the positive face image.

[0114] The third execution unit 49 is used to synthesize the cartoon migration video of the to-be-driven cartoon image with the pre-obtained voice to obtain a cartoon dynamic video.

[0115] As an embodiment of the present application, the global unit 44 is specifically used to input the to-be-driven cartoon image and the global transformation relationship into a pre-trained dense motion estimation model to obtain pixel motion data output by the dense motion estimation model.

[0116] As an embodiment of the present application, the first execution unit 47 is specifically used to extract the pixel coordinates of the eyes in the face area; and obtain the positive face image through a coordinate conversion algorithm based on the pixel coordinates of the eyes.

[0117] As an embodiment of the present application, the third execution unit 49 is specifically used to encode the corresponding video frame images in the cartoon migration video of the cartoon image to be driven and the pre-obtained speech respectively to obtain the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of the speech; the concatenated features of the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of the speech are sent to the decoder to generate a target sequence image; the target sequence image is a cartoon image containing lip shape features; the target sequence image is synthesized with the pre-obtained speech to obtain a cartoon dynamic video.

[0118] Figure 6 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention. Figure 6 As shown, the computer device of this embodiment includes: at least one processor ( Figure 6 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps in any of the above-mentioned image-based cartoon animation generation method embodiments are implemented.

[0119] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 6 These are merely examples of computer devices and do not constitute limitations on the computer devices. The computer devices may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, they may also include a network interface, a display screen, and an input device.

[0120] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0121] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of an operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments may also be an external storage device of a computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on a computer device. Further, the memory may also include both an internal storage unit of a computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of computer programs, etc. The memory may also be used to temporarily store data that has been output or is to be output.

[0122] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0123] The present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing.

[0124] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0125] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0126] In the embodiments provided by the present invention, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0127] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0128] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A method for generating cartoon animation based on an image, characterized in that: include: Input the cartoon image to be driven into the cartoon posture transfer network generated based on the template video to obtain the cartoon transfer video; The generation process of the cartoon posture transfer network includes: Select a reference image from the video frame of the template video as the target image, divide the target image into a first target area and a second target area, and divide the cartoon image to be driven into a first area to be driven and a second area to be driven; the first target area and the first area to be driven are both the upper half of the face area including the eyes, and the second target area and the second area to be driven are both the lower half of the face area including the jawline; Detecting each key point in the target image and the cartoon image to be driven, and determining the key point transformation relationship between the first target area and the first area to be driven, and the key point transformation relationship between the second target area and the second area to be driven; Performing a global transformation on the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship; Inputting the to-be-driven cartoon image and the global transformation relationship into a pre-trained dense motion estimation model, and obtaining pixel motion data output by the dense motion estimation model; Based on the to-be-driven cartoon image and the pixel motion data, a deep learning model is trained to generate a cartoon posture transfer network; Encoding the corresponding video frame image in the cartoon migration video of the to-be-driven cartoon image and the pre-obtained speech respectively to obtain a feature vector of each frame of the cartoon image and a lip shape feature vector corresponding to each frame of speech; The concatenated features of the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of speech are sent to the decoder to generate a target sequence image; the target sequence image is a cartoon image containing lip shape features; The target sequence image and the pre-obtained speech are synthesized to obtain a cartoon dynamic video.

2. The method for generating cartoon animation based on an image as claimed in claim 1, characterized in that: The step of inputting the to-be-driven cartoon image into the cartoon posture transfer network obtained by training based on the template video to obtain the cartoon transfer video further includes: The face area in the driven image is detected by the face detection algorithm, and the face area is detected, and the positive face image is obtained according to the coordinate conversion algorithm; The positive face image is input into a cartoon network to obtain a cartoon image to be driven corresponding to the positive face image.

3. The method for generating cartoon animation based on an image as claimed in claim 2, characterized in that: According to the input image, the face area is detected through the face detection algorithm, and the positive face image is obtained according to the coordinate conversion algorithm, including: Extracting pixel coordinates of eyes in the face area; According to the pixel coordinates of the eyes, a forward face image is obtained through a coordinate conversion algorithm.

4. The method for generating cartoon animation based on an image as claimed in claim 1, characterized in that: The video frame image corresponding to the cartoon migration video of the cartoon image to be driven and the pre-obtained speech are respectively encoded by different encoders to obtain a feature vector of each frame of the cartoon image and a lip shape feature vector corresponding to each frame of speech, including: Extracting audio information from the pre-obtained speech, and normalizing the audio information to obtain normalized audio information; Performing same frame rate extraction on the cartoon migration video of the to-be-driven cartoon image and the normalized audio information to obtain a first sequence of frame images and a second sequence of frame audios respectively; Using a first encoder, encoding the first sequence of frame images to obtain a cartoon image feature vector for each frame; The second sequence of audio frames is encoded using a second encoder to obtain a lip shape feature vector corresponding to each audio frame.

5. A cartoon animation generating device based on an image, characterized in that: Input unit: inputs the cartoon image to be driven into the cartoon posture transfer network generated based on the template video to obtain the cartoon transfer video; A division unit: selects a reference image from the video frame of the template video as a target image, divides the target image into a first target area and a second target area, and divides the cartoon image to be driven into a first area to be driven and a second area to be driven; the first target area and the first area to be driven are both the upper half of the face area including the eyes, and the second target area and the second area to be driven are both the lower half of the face area including the jawline; A detection unit: detecting each key point in the target image and the cartoon image to be driven, and determining a transformation relationship between the key points in the first target area and the first area to be driven, and a transformation relationship between the key points in the second target area and the second area to be driven; A global unit: globally transforming the key point transformation relationship between the first target area and the first area to be driven and the key point transformation relationship between the second target area and the second area to be driven to obtain a global transformation relationship; A generating unit: inputting the to-be-driven cartoon image and the global transformation relationship into a pre-trained dense motion estimation model, and acquiring pixel motion data output by the dense motion estimation model; Training unit: training a deep learning model based on the to-be-driven cartoon image and the pixel motion data to generate a cartoon posture transfer network; The third execution unit is used to encode the video frame image corresponding to the cartoon migration video of the to-be-driven cartoon image and the pre-obtained speech respectively, to obtain a feature vector of each frame of the cartoon image and a lip shape feature vector corresponding to each frame of speech; The concatenated features of the feature vector of each frame of the cartoon image and the lip shape feature vector corresponding to each frame of speech are sent to the decoder to generate a target sequence image; the target sequence image is a cartoon image containing lip shape features; The target sequence image and the pre-obtained speech are synthesized to obtain a cartoon dynamic video.

6. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the image-based cartoon animation generation method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image-based cartoon animation generation method according to any one of claims 1 to 4 is implemented.