Film and television character classification method, device, computer equipment and storage medium
Through subject detection, feature extraction and clustering processing of target images in film and television videos, the problem of low efficiency of traditional film and television character classification is solved and fast and accurate character classification is achieved.
Patent Information
- Application Number
- CN202110896917.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-05
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-08-05
AI Technical Summary
Traditional film and television character classification methods are inefficient and require manual operations, making it difficult to quickly and accurately classify characters in film and television dramas.
By acquiring target images in film and television videos, performing subject detection and cropping character images, extracting features, dividing feature subsets and clustering, automatically classify images of the same character category.
It improves the efficiency and accuracy of film and television character classification, avoids the influence of lighting, background and other factors, and achieves fast and accurate character classification.
Smart Images

Figure CN114282057B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, computer equipment and storage medium for classifying film and television characters. Background Art
[0002] With the development of society and economy, there are more and more movies and TV series, and the demand for classifying the roles of various objects appearing in movies and TV series is also increasing. Classifying the roles of objects appearing in movies and TV series can facilitate users to find the role of a certain object, or obtain stills of a certain role, etc.
[0003] The traditional method of classifying film and television characters usually requires staff to manually classify each object that appears in the film and television drama, which has the problem of low efficiency in character classification. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for classifying film and television characters that can improve efficiency in order to address the above technical issues.
[0005] A method for classifying film and television roles, the method comprising:
[0006] Acquire a target image from at least one film or television video;
[0007] Performing subject detection on each of the target images respectively, and cutting out the character image from the target image based on the subject detection result;
[0008] Extracting features from each character image to obtain corresponding image features;
[0009] Dividing the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character images corresponding to the image features in each feature subset are from the same film and television video;
[0010] For each feature subset, the image features in the corresponding feature subset are clustered to obtain at least one cluster, and the character images corresponding to the image features in the same cluster are classified into the same character category.
[0011] A device for classifying film and television roles, the device comprising:
[0012] An acquisition module, used for acquiring a target image from at least one film or television video;
[0013] A detection module, used to perform subject detection on each of the target images, and cut out a character image from the target image based on the subject detection result;
[0014] A feature extraction module, used to extract features from each character image to obtain corresponding image features;
[0015] The classification module is used to divide the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character images corresponding to the image features in each feature subset are derived from the same film and television video; for each feature subset, the image features in the corresponding feature subset are clustered to obtain at least one clustering cluster, and the character images corresponding to the image features under the same clustering cluster are classified into the same character category.
[0016] In one of the embodiments, the acquisition module is further used to acquire at least one film and television video; for each film and television video, at least one target image is extracted at every preset playback duration on the playback time axis of the film and television video.
[0017] In one of the embodiments, the detection module is also used to perform subject detection on each of the target images to obtain a subject detection result; if the subject detection result indicates that there is a character object in the target image, a character area where the character object is located is determined based on the subject detection result; based on the character area, a character image including the character object is cropped out from the target image.
[0018] In one embodiment, the device also includes an adjustment module for obtaining a first input image size of a subject detection model; if the size of the target image does not match the first input image size, the size of the target image is adjusted to the first input image size to obtain a first image; the first image is used as a new target image; the detection module is also used to perform subject detection on each of the target images respectively.
[0019] In one of the embodiments, the adjustment module is also used to delete pixels of the target image in the direction of the edge if the pixel size of the edge of the target image is larger than the first pixel size of the corresponding preset edge, so as to reduce the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; if the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, then insert pixels in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, an adjusted first image is obtained.
[0020] In one embodiment, the adjustment module is also used to obtain the second input image size of the feature extraction network; if the size of the character image does not match the size of the second input image, the size of the character image is adjusted to the size of the second input image to obtain a second image; the feature extraction module is also used to perform feature extraction on each of the second images to obtain corresponding image features.
[0021] In one of the embodiments, the classification module is also used to take each image feature in the corresponding feature subset as an initial image node, calculate the similarity between any two image nodes in the current round; combine the two image nodes with the highest similarity into a new image node, continue to execute the next round until the clustering cutoff condition is met, and finally obtain at least one target image node, and take each of the target image nodes obtained as a cluster cluster; wherein each of the target image nodes obtained in the end includes a single image feature, or includes more than one image feature.
[0022] In one of the embodiments, the classification module is also used to determine, for each cluster in each of the feature subsets, an average image feature corresponding to the corresponding cluster based on each image feature under the corresponding cluster; for each cluster, calculate the degree of deviation between each image feature in the corresponding cluster and the average image feature of the corresponding cluster; filter out image features whose degree of deviation is greater than a preset deviation threshold, and classify character images corresponding to image features whose degree of deviation is less than or equal to the preset deviation threshold under the same cluster into the same character category.
[0023] In one of the embodiments, the device also includes a rejection module, which is used to obtain a rejection instruction for each of the character categories, if it is determined that a specified image in the character images does not belong to the corresponding character category after comparing the character images under the corresponding character category; and reject the specified image from the corresponding character category based on the rejection instruction.
[0024] In one embodiment, the device also includes a training module, which is used to use the character images included in each of the character categories as training data to train the character recognition model until the training cutoff condition is met to obtain a trained character recognition model; the trained character recognition model is used to process the image to be recognized to predict the character category of the image to be recognized.
[0025] In one embodiment, the device also includes a construction module, which is used to obtain image features of character images under each character category; determine reference image features that match the corresponding character category based on the image features of the character images under each character category; and associate the reference image features corresponding to each character category with the corresponding character category to construct a character category library.
[0026] In one embodiment, the device also includes a recognition module, which is used to obtain an image to be recognized; calculate the feature similarity between the target feature vector corresponding to the image to be recognized and each reference image feature to obtain at least one feature similarity corresponding to the image to be recognized; determine the target reference image feature corresponding to the maximum feature similarity, and use the role category corresponding to the target reference image feature as the role category corresponding to the image to be recognized.
[0027] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned method for classifying film and television characters when executing the computer program.
[0028] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for classifying film and television characters.
[0029] The above-mentioned film and television character classification method, device, computer equipment and storage medium obtain target images from at least one film and television video, first perform subject detection on each target image respectively, and cut out the character image from the target image based on the subject detection result, then perform feature extraction on each character image respectively to obtain the corresponding image features, and then divide the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video. Then, for each feature subset, cluster the image features in the corresponding feature subset to obtain at least one cluster cluster, and the same or similar image features can be quickly clustered into the same cluster cluster. The character images corresponding to the image features in the same cluster cluster represent the same character and can be divided into the same character category, so that each character in each film and television video can be quickly classified, thereby improving the efficiency of film and television character classification. In addition, cutting out the character image from the target image and then performing clustering processing based on the image features of the character image can avoid the influence of other factors in the target image other than the character image, such as lighting, background, image size, etc., thereby improving the accuracy and robustness of film and television character classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1A diagram of an application environment of a method for classifying film and television roles in an embodiment;
[0031] Figure 2 1 is a flow chart of a method for classifying film and television roles in one embodiment;
[0032] Figure 3 The figure is a flow chart of the steps of performing subject detection on each target image and cutting out a character image from the target image based on the subject detection result in one embodiment;
[0033] Figure 4 A schematic diagram of a flow chart of a method for classifying film and television roles in another embodiment;
[0034] Figure 5 A schematic diagram of a flow chart of steps for extracting features from each character image to obtain corresponding image features in one embodiment;
[0035] Figure 6 It is a flowchart of a step of classifying character images corresponding to image features under the same cluster into the same character category in one embodiment;
[0036] Figure 7 A schematic diagram of a flow chart of a method for classifying film and television roles in another embodiment;
[0037] Figure 8 A schematic diagram of a flow chart of a method for classifying film and television roles in another embodiment;
[0038] Fig. 9 is a structural block diagram of a device for classifying film and television roles in one embodiment;
[0039] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0041] The film and television role classification method provided in this application can be applied to Figure 1In the application environment shown. Among them, the server 102 communicates with the terminal 104 through the network. The film and television character classification method in the present application can be implemented by the terminal or server alone, or by the terminal and the server in collaboration. Taking the implementation of the terminal and the server in collaboration as an example, the terminal 104 sends the target image from the same film and television video to the server 102. The server 102 obtains at least one target image; performs subject detection on each target image respectively, and cuts out the character image from the target image based on the subject detection result; extracts features from each character image respectively to obtain corresponding image features; divides the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video; for each feature subset, clusters the image features in the corresponding feature subset to obtain at least one clustering cluster, and divides the character images corresponding to the image features under the same clustering cluster into the same character category, and returns the character category of each character image to the terminal 104. The terminal 104 receives the role category of each character image and can mark the role category on each character image in the film and television video.
[0042] Among them, the terminal 104 can be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a car terminal, and a smart TV. The server 102 can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. The terminal 104 can be provided with a client, which can be a video client, a browser client, or an information stream client, etc. The number of terminals 104 and servers 102 is not limited in this application.
[0043] The server 102 can train and learn the role recognition model based on artificial intelligence technology to obtain a trained role recognition model, so as to more accurately process the image to be recognized and predict a more accurate role category of the image to be recognized.
[0044] 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. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology and machine learning / deep learning.
[0045] In one embodiment, Figure 2 As shown, a method for classifying film and television roles is provided, and the method is applied to a computer device as an example for explanation, wherein the computer device can be specifically Figure 1 The method for classifying film and television roles comprises the following steps:
[0046] Step S202: Acquire a target image from at least one film or television video.
[0047] Among them, film and television videos are an art form that uses copies, tapes, films, storage devices, etc. as carriers and is projected on screens to achieve visual and auditory viewing. Film and television videos can at least include movies, TV series, programs, or animations. The number of film and television videos can be set as needed, for example, the number of film and television videos is 1 or 3.
[0048] The target image is an image frame extracted from a film or TV video. The target image may be a human image, a landscape image, or an animation image, etc. The number of target images may be set as required, for example, the number of target images may be 10 or 20, etc.
[0049] The computer device obtains at least one video and extracts a target image from each preset node in each video. In one embodiment, the preset node may be a node where each preset number of image frames in the video are located. The preset number may be set as needed, for example, the preset number may be 4 frames, 10 frames, etc.
[0050] In another embodiment, the preset node may be a node at each preset playback duration on the playback time axis of the film and television video. The preset duration may be set as needed, for example, the preset duration may be 0.02s (seconds), 0.1s, etc. In another embodiment, the preset node may be a node set by a user.
[0051] Step S204: perform subject detection on each target image, and crop the character image from the target image based on the subject detection result.
[0052] Among them, subject detection is a way of detecting a target object, which can be human detection, animal detection, plant detection, or detection of some other physical object. The subject detection result is the result of subject detection on the target image. The subject detection result can at least include whether there is a subject in the target image, the coordinate position of the subject, the size of the subject, the category to which the subject belongs, etc.
[0053] The character image is an image of the area where the character object is located. The character object included in the character image can be a person, an animal, an object, or a cartoon individual.
[0054] In one embodiment, the computer device performs human detection on each target image, and cuts out a human character image from the target image based on the human detection result. In another embodiment, the computer device performs animal detection on each target image, and cuts out an animal character image from the target image based on the animal detection result.
[0055] Step S206, extracting features from each character image to obtain corresponding image features.
[0056] Among them, the image feature is the feature contained in the character image. The image feature can be represented by a vector (Embedding). One image feature can be extracted from each character image, and each image feature can include at least one dimension of sub-features. The dimension of the image feature can be set as needed, for example, the dimension of the image feature can include 1×512, 1×600, etc. Each dimension of the image feature represents a sub-feature of the character image. For example, the sub-feature of one dimension of the image feature is (224*384), indicating that the size of the character image is 224*384; the sub-feature of one dimension of the image feature is the brightness value, indicating the average brightness value of the character image.
[0057] The computer device extracts features from each character image to obtain sub-features corresponding to each character image; the sub-features corresponding to each character image are sorted according to the importance of each sub-feature to generate image features corresponding to each character image.
[0058] The importance of each sub-feature can be set as needed. For example, the importance of each sub-feature decreases in order of the size of the character image, the color of the character image, the brightness value of the character image, the clarity of the character image, etc.
[0059] Step S208, dividing the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video.
[0060] The feature subset is a set of image features of all character images included in each film and television video. The computer device can generate a corresponding tag for each feature subset, and the tag of each feature subset is associated with the film and television video corresponding to the feature subset. The tag can specifically be the name of the film and television video, the number of the film and television video, or the theme cover image of the film and television video.
[0061] Specifically, when a computer device obtains a target image from at least one film and television video, each target image is associated with the film and television video to which the target image belongs. Then, from the association record between each target image and the film and television video to which it belongs, image features of the character image in the target image obtained by the same film and television video are obtained, and the image features of the same film and television video are divided into the same feature subset.
[0062] Furthermore, when the computer device crops out character images from the target image based on the subject detection result, each character image is recorded in association with the target image; when feature extraction is performed on each character image to obtain the corresponding image features, each image feature is recorded in association with the character image; then based on the association record of each target image with the film and television video to which it belongs, the association record of each character image with the target image, and the association record of each image feature with the character image, the association record of each image feature with the film and television video can be determined, and all image features of the same film and television video association record can be divided into the same feature subset.
[0063] For example, the computer device may divide the image features into at least one feature subset E according to the film and television video to which the corresponding character image belongs. i =(i=1,2,3...). Among them, E i Refers to a subset of features.
[0064] Step S210 , for each feature subset, clustering the image features in the corresponding feature subset to obtain at least one cluster, and classifying the character images corresponding to the image features in the same cluster into the same character category.
[0065] The cluster refers to a set of samples generated by clustering. It can be understood that the similarity of each image feature under the cluster is high and the difference is small, and the difference between image features of different clusters is large.
[0066] The role category refers to the category of the role to which the role image belongs. In some cases, the role category may not include role-related information, but is only used to distinguish different roles, such as user-specified categories, such as category 1, category 2, and category 3; in other cases, the role category may include role-related information. Among them, the role-related information is information related to film and television roles, such as the name of the film and television video, the name of the role, the characteristics of the role, or the name of the actor related to the role. For example, the role category can specifically be the emperor, the queen, the warrior A, the warrior B, the assassin, the general A, the general B, etc. The role category can also be the name of the role, such as "Black Cat Sheriff", "White Cat Squad Leader" or "White Dove Detective" in "Black Cat Sheriff".
[0067] Each feature subset includes the image features of all character images of each film and television video. Usually, each feature subset includes character images of multiple character objects. The image features of the character images of the same character object are relatively small, while the image features of the character images of different character objects are relatively large. Therefore, the character images in the feature subset can be clustered to obtain multiple clusters, and each cluster includes the image features of the character images of one character object. Of course, a feature subset can also include only one character object, and clustering the image features of the character images of the character object can obtain a cluster.
[0068] For each feature subset, the character images corresponding to the image features in each cluster are obtained, and the character images corresponding to the image features under the same cluster are divided into the same character category.
[0069] In one embodiment, the computer device groups the character images corresponding to the image features under the same cluster into the same set, and all the character images in the set belong to the same character category. In another embodiment, the computer device groups the character images corresponding to the image features under the same cluster into the same set, and determines the character category to which the character images in the set belong.
[0070] Furthermore, the computer device can also annotate each character image under the same character category with the identification of the corresponding character category, thereby realizing rapid annotation of the character images, shortening the annotation cycle, and saving annotation costs.
[0071] The above-mentioned film and television character classification method obtains a target image from at least one film and television video, first performs subject detection on each target image, and cuts out a character image from the target image based on the subject detection result, then performs feature extraction on each character image to obtain corresponding image features, and then divides the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video. Then, for each feature subset, clustering the image features in the corresponding feature subset to obtain at least one cluster cluster, the same or similar image features can be quickly clustered into the same cluster cluster, and the character images corresponding to the image features in the same cluster cluster represent the same character and can be divided into the same character category, so that each character in each film and television video can be quickly classified, thereby improving the efficiency of film and television character classification. In addition, cutting out the character image from the target image and then performing clustering processing based on the image features of the character image can avoid the influence of other factors in the target image other than the character image, such as lighting, background, image size, etc., thereby improving the accuracy and robustness of film and television character classification.
[0072] In one embodiment, obtaining a target image from at least one film and television video includes: obtaining at least one film and television video; for each film and television video, extracting at least one target image at every preset playback duration on the playback timeline of the film and television video.
[0073] The play time axis refers to the time axis of the video during the play process. For example, if the duration of the video is 1 hour, the play time axis of the video includes 0-60 minutes.
[0074] The preset playback time can be set as needed. For example, the preset playback time is 20 seconds, that is, during the playback of the video, at least one target image is extracted every 20 seconds, and at least 90 target images can be extracted from a 30-minute video.
[0075] In one embodiment, in a film or video, the number of target images extracted each time can be set as needed. For example, on the playback time axis of the film or video, the computer device can extract one target image at each preset playback time interval. For another example, on the playback time axis of the film or video, the computer device can extract three target images at each preset playback time interval.
[0076] In this embodiment, for each film and television video, on the playback timeline of the film and television video, at least one target image is extracted at each preset playback duration, and target images can be extracted from multiple playback time nodes in each film and television video, thereby improving the diversity of target images extracted from the film and television video, thereby obtaining more diverse character images and classifying more diverse character categories.
[0077] In one embodiment, Figure 3 As shown, subject detection is performed on each target image, and a character image is cropped from the target image based on the subject detection result, including:
[0078] Step S302: Perform subject detection on each target image to obtain a subject detection result.
[0079] Specifically, a subject detection result may be obtained for each target image, and the subject detection result may at least include whether a subject exists in the target image, the coordinate position of the subject, the size of the subject, the category to which the subject belongs, and the like.
[0080] Step S304: If the subject detection result indicates that there is a character object in the target image, a character region where the character object is located is determined based on the subject detection result.
[0081] The character object is an object representing a character. The character object can be a person, a face, an animal, etc. The character area is the area where the character object is located. The character area can be a rectangular area, a circular area, or an irregular area including the character object, etc., which is not limited here.
[0082] The target image may or may not contain a character object. If the target image contains a character object, the number of character objects in the target image may be one or more. If the target image contains no character object, the target image may not be processed or may be discarded.
[0083] In one embodiment, if the subject detection result indicates that there is a character object in the target image, the coordinate position of the character object is obtained, and the character area where the character object is located is determined based on the coordinate position of the character object. The coordinate position of the character object can be the four vertices of a rectangular area containing the character object, and the character area where the character object is located, that is, the rectangular area, is determined based on the coordinate positions of the four vertices.
[0084] In one implementation, if the subject detection result indicates that there is a character object in the target image, the outline of the character object is obtained, and the character region where the character object is located is determined based on the outline of the character object. The computer device may directly use the region where the outline of the character object is located as the character region, or may use the region containing the outline of the character object as the character region, which is not limited here.
[0085] Step S306: based on the character area, a character image including the character object is cut out from the target image.
[0086] Specifically, the computer device cuts according to the edge lines of the character area to obtain a character image including the character object.
[0087] Furthermore, the computer device recognizes the character region in the target image, determines the outline of the character object, and cuts out the character image including the character object from the character region according to the outline of the character object. The computer device only recognizes the character region, avoiding recognition of the entire target image, and can more quickly determine the outline of the character object, thereby more quickly cutting out the character image including the character object.
[0088] In this embodiment, subject detection is performed on each target image to obtain a subject detection result; if the subject detection result indicates that there is a character object in the target image, the character area where the character object is located is determined based on the subject detection result, and based on the character area, the character image including the character object can be cropped out from the target image more quickly.
[0089] In one embodiment, Figure 4 As shown, the film and television character classification method also includes the step of adjusting the size of the target image, which specifically includes:
[0090] Step S402, obtaining a first input image size of a subject detection model.
[0091] The subject detection model is a model used to detect subjects in an image. The subject detection model may be at least one of a Mask RCNN model, a Fast RCNN model, an SSD model, and the like.
[0092] The first input image size is the image size required by the input subject detection model. The first input image size can be set as needed. For example, the first input image size can be 800*800 pixels or 500*650 pixels.
[0093] The subject detection model can be pre-trained based on subject training image data. For example, if the subject detection model is a human body detection model, the human body detection model can be pre-trained based on human body training image data. For another example, if the subject detection model is an animal detection model, the animal detection model can be pre-trained based on animal training image data.
[0094] Step S404: if the size of the target image does not match the size of the first input image, the size of the target image is adjusted to the size of the first input image to obtain a first image.
[0095] Specifically, the computer device obtains the size of the target image and matches the size of the target image with the size of the first input image. When the size of the target image is consistent with the size of the first input image, it indicates that the size of the target image matches the size of the first input image; when the size of the target image is inconsistent with the size of the first input image, it indicates that the size of the target image does not match the size of the first input image.
[0096] For example, the size of the first input image of the subject detection model is 800*800 pixels, and the size of the target image is 755*650 pixels. The size of the target image is adjusted from 755*650 pixels to 800*800 pixels to obtain the adjusted first image.
[0097] Step S406: Use the first image as a new target image, input the new target image into a subject detection model, and use the subject detection model to perform subject detection on each target image.
[0098] The computer device adjusts the size of the target image to the size of the first input image, and then the first image can be input into the subject detection model as a new target image. The subject detection model can perform subject detection on the target image to obtain a subject detection result.
[0099] In this embodiment, the first input image size of the subject detection model is obtained. If the size of the target image does not match the first input image size, the size of the target image is adjusted to the first input image size to obtain an adjusted first image. The size of the adjusted first image meets the size required by the subject detection model, and subject detection can be accurately performed on the adjusted first image.
[0100] In one embodiment, the first input image size includes a first pixel size of each preset edge; if the size of the target image does not match the first input image size, the size of the target image is adjusted to the first input image size to obtain a first image, including: if the pixel size of the edge of the target image is larger than the first pixel size of the corresponding preset edge, then the pixels of the target image in the direction of the edge are deleted to reduce the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; if the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, then the pixels are inserted in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, the first image is obtained.
[0101] The first pixel size is the pixel size required by the preset side in the first input image size. For example, if the first input image size is 800*700 pixels, the first pixel size of the longer preset side is 800 pixels, and the first pixel size of the shorter preset side is 700 pixels.
[0102] After the computer device acquires the target image, it detects the pixel size of each side of the target image and matches the pixel size of each side with the first pixel size of the corresponding preset side. If the pixel size of the side of the target image is the same as the first pixel size of the corresponding preset side, the pixels in the direction of the side are not processed.
[0103] If the pixel size of the side of the target image is larger than the first pixel size corresponding to the preset side, the computer device may delete the pixels of the target image in the direction of the side to reduce the pixel size of the side of the target image to the first pixel size corresponding to the preset side. For example, if the pixel size of the target image is 800*900 pixels, the target image includes 900 rows and 800 columns of pixels, the pixel size of the long side is 900 pixels, and the first pixel size of the long side corresponding to the preset side is 800 pixels, then the pixels of the target image in the direction of the long side, that is, the pixels in the column direction are deleted to obtain a target image of 800 rows and 800 columns of pixels.
[0104] If the pixel size of the side of the target image is smaller than the first pixel size of the corresponding preset side, the computer device may insert pixels in the direction of the side of the target image to enlarge the pixel size of the side of the target image to the first pixel size of the corresponding preset side. The inserted pixels may be zero pixels or designated pixels such as white pixels, black pixels, gray pixels, etc., but are not limited thereto.
[0105] For example, the pixel size of the target image is 650*800 pixels, the target image includes 800 rows and 650 columns of pixels, the pixel size of the short side is 650 pixels, and the first pixel size of the short side corresponding to the preset side is 800 pixels, then pixels are inserted in the short side direction of the target image, that is, pixels are inserted in the row direction to obtain a target image of 800 rows and 800 columns of pixels.
[0106] If the target image only has an edge whose pixel size is larger than the first pixel size of the corresponding preset edge, the pixels of the target image in the direction of the edge are deleted to obtain the adjusted first image. If the target image only has an edge whose pixel size is smaller than the first pixel size of the corresponding preset edge, the pixels are inserted in the direction of the edge of the target image to obtain the adjusted first image. If the target image has an edge whose pixel size is larger than the first pixel size of the corresponding preset edge, the pixels of the edge larger than the first pixel size of the corresponding preset edge are deleted; and if the target image also has an edge whose pixel size is smaller than the first pixel size of the corresponding preset edge, the pixels of the edge smaller than the first pixel size of the corresponding preset edge are inserted to obtain the adjusted first image.
[0107] Furthermore, if the pixel size of an edge of the target image is larger than a first pixel size of a corresponding preset edge, the computer device proportionally reduces the pixel size of each edge of the target image so that the pixel size of the edge of the target image is equal to the first pixel size of the corresponding preset edge, and then performs pixel deletion and / or pixel insertion on the reduced edge perpendicular to the edge to obtain a first image.
[0108] For example, the pixel size of the target image is 1600*700 pixels, the target image includes 700 rows and 1600 columns of pixels, the pixel size of the long side is 1600 pixels, the size of the first input image is 800*800 pixels, and the first pixel size of the long side corresponding to the preset side is 800 pixels. The pixel sizes of each side of the target image are proportionally reduced to obtain a pixel size of 800*350 pixels after the reduction. Pixels are then inserted into the reduced short side perpendicular to the long side, that is, pixels are inserted into the side with a size of 350 pixels to obtain a side with a pixel size of 800 pixels, that is, a first image of 800*800 pixels is obtained.
[0109] Furthermore, if the pixel size of an edge of the target image is smaller than a first pixel size of a corresponding preset edge, the computer device proportionally enlarges the pixel size of each edge of the target image to make the pixel size of the edge of the target image equal to the first pixel size of the corresponding preset edge, and then performs pixel deletion and / or pixel insertion on the enlarged edge perpendicular to the edge to obtain a first image.
[0110] For example, the pixel size of the target image is 400*700 pixels, the target image includes 700 rows and 400 columns of pixels, the pixel size of the short side is 400 pixels, the first input image size is 800*800 pixels, and the first pixel size of the short side corresponding to the preset side is 800 pixels. The pixel sizes of each side of the target image are proportionally enlarged to obtain a pixel size of 800*1400 pixels after the enlargement of the target image, and then the pixels of the reduced long side perpendicular to the short side are deleted, that is, the pixels of the side with a size of 1400 pixels are deleted to obtain a side with a pixel size of 800 pixels, that is, a first image of 800*800 pixels is obtained.
[0111] In this embodiment, if the pixel size of the edge of the target image is larger than the first pixel size of the corresponding preset edge, the pixels of the target image in the direction of the edge are deleted to reduce the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; if the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, pixels are inserted in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, an adjusted first image can be accurately obtained, and the pixel size of the adjusted first image matches the first pixel size of each preset edge required by the subject detection model, and the adjusted first image can be accurately processed for subject detection.
[0112] In one embodiment, Figure 5 As shown, feature extraction is performed on each character image to obtain corresponding image features, including:
[0113] Step S502, obtaining the second input image size of the feature extraction network.
[0114] The feature extraction network is a network used to extract features from an image. The feature extraction network can be a classification network with Resnet-50 as the backbone. It is understandable that without departing from the principles of this application, networks such as Vgg and Resnet-101 can also be used to extract image features.
[0115] The second input image size is the image size required by the input feature extraction network. The second input image size can be set as needed. For example, the second input image size can be 224*384 pixels or 500*650 pixels.
[0116] Step S504: If the size of the character image does not match the size of the second input image, the size of the character image is adjusted to the size of the second input image to obtain a second image.
[0117] Specifically, the computer device obtains the size of the character image and matches the size of the character image with the size of the second input image. When the size of the character image is consistent with the size of the second input image, it means that the size of the character image matches the size of the second input image; when the size of the character image is inconsistent with the size of the second input image, it means that the size of the character image does not match the size of the second input image.
[0118] For example, the size of the second input image of the subject detection model is 800*800 pixels, and the size of the character image is 755*650 pixels, then the size of the character image is adjusted from 755*650 pixels to 800*800 pixels to obtain the second image.
[0119] Step S506: extract features from each second image through a feature extraction network to obtain corresponding image features.
[0120] The computer device adjusts the size of the character image to the size of the second input image, and the adjusted character image, that is, the second image, can be input into the feature extraction network as a new target image. The feature extraction network can perform feature extraction on the target image to obtain corresponding image features.
[0121] In this embodiment, the size of the second input image of the feature extraction network is obtained; if the size of the character image does not match the size of the second input image, the size of the character image is adjusted to the size of the second input image to obtain a second image; feature extraction is performed on each second image through the feature extraction network to obtain corresponding image features, and the size of the adjusted character image meets the size required by the feature extraction network, and feature extraction can be accurately performed on the adjusted character image.
[0122] In one embodiment, the second input image size includes the second pixel size of each preset edge; if the size of the character image does not match the second input image size, the size of the character image is adjusted to the second input image size to obtain a second image, including: if the pixel size of the edge of the character image is larger than the second pixel size of the corresponding preset edge, then the pixels of the character image in the direction of the edge are deleted to reduce the pixel size of the edge of the character image to the second pixel size of the corresponding preset edge; if the pixel size of the edge of the character image is smaller than the second pixel size of the corresponding preset edge, then pixels are inserted in the direction of the edge of the character image to enlarge the pixel size of the edge of the character image to the second pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, the second image is obtained.
[0123] The second pixel size is the pixel size required by the preset side in the second input image size. For example, if the second input image size is 950*700 pixels, the second pixel size of the longer preset side is 950 pixels, and the second pixel size of the shorter preset side is 700 pixels.
[0124] After the computer device acquires the character image, it detects the pixel size of each side of the character image and matches the pixel size of each side with the second pixel size of the corresponding preset side. If the pixel size of the side of the character image is the same as the second pixel size of the corresponding preset side, the pixels in the direction of the side are not processed.
[0125] If the pixel size of the side of the character image is larger than the second pixel size corresponding to the preset side, the pixels of the character image in the direction of the side are deleted to reduce the pixel size of the side of the character image to the second pixel size corresponding to the preset side. For example, the pixel size of the character image is 800*900 pixels, the character image includes 900 rows and 800 columns of pixels, the pixel size of the long side is 900 pixels, and the second pixel size of the long side corresponding to the preset side is 800 pixels, then the pixels of the character image in the direction of the long side, that is, the pixels in the column direction are deleted to obtain a character image of 800 rows and 800 columns of pixels.
[0126] If the pixel size of the side of the character image is smaller than the second pixel size of the corresponding preset side, then insert pixels in the direction of the side of the character image to enlarge the pixel size of the side of the character image to the second pixel size of the corresponding preset side. For example, the pixel size of the character image is 650*800 pixels, the character image includes 800 rows and 650 columns of pixels, the pixel size of the short side is 650 pixels, and the second pixel size of the short side corresponding to the preset side is 800 pixels, then insert pixels in the direction of the short side of the character image, that is, insert pixels in the row direction, to obtain a character image of 800 rows and 800 columns of pixels.
[0127] If the character image only has edges whose pixel size is larger than the second pixel size of the corresponding preset edge, the pixels of the character image in the direction of the edge are deleted to obtain an adjusted second image. If the character image only has edges whose pixel size is smaller than the second pixel size of the corresponding preset edge, the pixels are inserted in the direction of the edge of the character image to obtain an adjusted second image. If the character image has edges whose pixel size is larger than the second pixel size of the corresponding preset edge, the pixels of the edges larger than the second pixel size of the corresponding preset edge are deleted; and if the character image also has edges whose pixel size is smaller than the second pixel size of the corresponding preset edge, the pixels of the edges smaller than the second pixel size of the corresponding preset edge are inserted to obtain an adjusted second image.
[0128] In this embodiment, if the pixel size of the edge of the character image is larger than the second pixel size of the corresponding preset edge, the pixels of the character image in the direction of the edge are deleted to reduce the pixel size of the edge of the character image to the second pixel size of the corresponding preset edge; if the pixel size of the edge of the character image is smaller than the second pixel size of the corresponding preset edge, pixels are inserted in the direction of the edge of the character image to enlarge the pixel size of the edge of the character image to the second pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, an adjusted second image can be accurately obtained, the pixel size of the adjusted second image matches the second pixel size of each preset edge required by the feature extraction network, and feature extraction can be accurately performed on the adjusted second image.
[0129] In one embodiment, hierarchical clustering is performed on the image features in the corresponding feature subset to obtain at least one cluster; the hierarchical clustering includes: for each feature subset, each image feature is used as an initial image node, and the similarity between any two image nodes is calculated in the current round; the two image nodes with the highest similarity are combined into a new image node, and the next round is continued until the clustering cutoff condition is met, and finally at least one target image node is obtained, and each of the finally obtained target image nodes is respectively used as a cluster; wherein each of the finally obtained target image nodes includes a single image feature, or includes more than one image feature.
[0130] The clustering cutoff condition can be set as needed. For example, the clustering cutoff condition can be at least one of the following: the clustering duration reaches a preset duration threshold, the number of clustering nodes is less than a preset number, the minimum similarity is greater than a preset similarity threshold, etc. Among them, the preset duration threshold, the preset number, and the preset similarity threshold can all be set as needed. For example, the preset duration threshold can be 10 minutes, the preset number can be 5, and the preset similarity threshold can be 50%.
[0131] Among them, the image nodes include independent image nodes and combined image nodes. Independent image nodes are nodes composed of a single image feature, and combined image nodes are nodes composed of more than one image feature. The initial image node is the image node in the first round, that is, each image feature in the feature subset is an initial image node. In the continuous iteration process, different image nodes can be combined to form a new image node, and this new image node can be called a combined image node. It can be understood that the combined image node in the iteration can be obtained by combining multiple independent image nodes; it can also be obtained by combining an independent image node and a combined image node obtained in the previous iteration; it can also be obtained by combining multiple combined image nodes obtained in the previous iteration. For example, the combined image nodes are (A, C), (B, F), etc., and the independent image nodes are D, E, etc.
[0132] Specifically, the computer device calculates the Euclidean distance between two image features corresponding to any two image nodes, and the Euclidean distance represents the similarity between the two image nodes. The smaller the Euclidean distance, the higher the similarity between the corresponding two image nodes.
[0133] The computer device compares the size of all calculated similarities, combines the two image nodes with the highest similarity into a new image node, and continues to perform the next round of calculating the similarity between any two image nodes. For example, there are 4 image features in the feature subset, that is, there are 4 initial image nodes, namely image node A, image node B, image node C and image node D. The calculated similarity between image node A and image node B is 60, the similarity between image node A and image node C is 56, the similarity between image node A and image node D is 45, the similarity between image node B and image node C is 50, the similarity between image node B and image node D is 42, and the similarity between image node C and image node D is 85. It can be determined that the two image nodes with the highest similarity are image node C and image node D, and image node C and image node D are combined into a new image node (C, D). Continue to execute the next round, the calculated similarity between image node A and image node B is 60, the similarity between image node A and image node (C, D) is 47, and the similarity between image node B and image node (C, D) is 45. It can be determined that the two image nodes with the highest similarity are image node A and image node B, and image node A and image node B are combined into a new image node (A, B). If the clustering cutoff condition is met at this time, two target image nodes are finally obtained, namely (A, B) and (C, D). Image node (A, B) includes 2 image features, and (C, D) also includes 2 image features, that is, (A, B) and (C, D) are both combined image nodes.
[0134] For another example, there are 4 image features in the feature subset, that is, there are 4 initial image nodes, namely image node A, image node B, image node C and image node D. The calculated similarity between image node A and image node B is 78, the similarity between image node A and image node C is 23, the similarity between image node A and image node D is 45, the similarity between image node B and image node C is 34, the similarity between image node B and image node D is 48, and the similarity between image node C and image node D is 28. It can be determined that the two image nodes with the highest similarity are image node A and image node B, and image node A and image node B are combined into a new image node (A, B). Continue to execute the next round, the calculated similarity between image node (A, B) and image node C is 30, the similarity between image node (A, B) and image node D is 56, and the similarity between image node C and image node D is 28. It can be determined that the two image nodes with the highest similarity are image node (A, B) and image node D, and image node (A, B) and image node D are combined into a new image node (A, B, D). If the clustering cutoff condition is met at this time, two target image nodes are finally obtained, namely (A, B, D) and C. Image node (A, B, D) includes 3 image features, and image node C includes a single image feature, that is, image node (A, B, D) is a combined image node, and image node C is an independent image node.
[0135] It should be noted that when the clustering cutoff condition is met, at least one combined image node can be clustered, or at least one combined image node and at least one independent image node can be clustered. An independent image node indicates that the cluster includes a single image feature. A combined image node indicates that the cluster includes more than one image feature.
[0136] In this embodiment, for each feature subset, each image feature is used as an initial image node, and the similarity between any two image nodes is calculated in the current round; the two image nodes with the highest similarity are combined into a new image node, and the next round is continued until the clustering cutoff condition is met, and finally at least one target image node is obtained. Each of the target image nodes obtained in the end is used as a cluster cluster, so that the image features in the feature subset can be clustered more accurately to obtain at least one cluster cluster.
[0137] In another embodiment, the computer device may also use other density-based clustering algorithms (such as K-means clustering, or density-based clustering algorithms, etc.) to cluster the image features in the corresponding feature subset to obtain at least one cluster cluster, which is not limited in this application.
[0138] In one embodiment, Figure 6 As shown, the character images corresponding to the image features under the same cluster are divided into the same character category, including:
[0139] Step S602: for each cluster in each feature subset, based on each image feature under the corresponding cluster, determine the average image feature corresponding to the corresponding cluster.
[0140] The average image feature is the feature obtained by averaging all the image features under the cluster. The average image feature can represent the features of the corresponding cluster.
[0141] Specifically, for each cluster in each feature subset, the computer device obtains each image feature under the cluster, calculates the average of each image feature, and uses the average as the average image feature of the corresponding cluster.
[0142] It can be understood that when each image feature is a feature vector, the sub-features of the same dimension of each image feature are averaged, and the average of each dimension is used as the sub-feature of each dimension of the average image feature, thereby generating the average image feature of the corresponding cluster.
[0143] Step S604: for each cluster, calculating the degree of deviation between each image feature in the corresponding cluster and the average image feature of the corresponding cluster.
[0144] It can be understood that the higher the deviation between a certain image feature and the average image feature, the smaller the similarity between the image feature and most of the image features in the cluster, and the greater the difference between the image feature and most of the image features in the cluster, the less likely the image feature is to belong to the feature of the character category.
[0145] Specifically, for each cluster in each feature subset, the computer device obtains each image feature under the corresponding cluster, calculates the variance between each image feature and the average image feature of the corresponding cluster, and the variance calculated for each image feature represents the degree of deviation between the image feature and the average image feature. The larger the variance of the image feature, the greater the degree of deviation between the image feature and the average image feature, that is, the greater the difference between the image feature and most of the image features in the feature subset. Among them, variance is a measure of the degree of dispersion when probability theory and statistical variance measure random variables or a set of data.
[0146] In another embodiment, for each cluster in each feature subset, the computer device obtains each image feature under the corresponding cluster, calculates the standard deviation between each image feature and the average image feature of the corresponding cluster, and the standard deviation calculated for each image feature represents the degree of deviation between the image feature and the average image feature. The larger the standard deviation of the image feature, the greater the degree of deviation between the image feature and the average image feature, that is, the greater the difference between the image feature and most of the image features in the feature subset. The standard deviation is also called the standard deviation, or the experimental standard deviation, and is most commonly used in probability statistics as a measurement basis for the degree of statistical distribution.
[0147] In another embodiment, for each cluster in each feature subset, the computer device obtains each image feature under the corresponding cluster, calculates the average difference between each image feature and the average image feature of the corresponding cluster, and the average difference calculated for each image feature represents the degree of deviation between the image feature and the average image feature. The larger the average difference of the image feature, the greater the degree of deviation between the image feature and the average image feature, that is, the greater the difference between the image feature and most of the image features in the feature subset. Mean Deviation is one of the numerical values that represents the degree of difference between each variable value, and refers to the arithmetic mean of the absolute values of the deviations between each variable value and the mean.
[0148] Step S606 , filtering out image features whose deviation is greater than a preset deviation threshold, and classifying character images corresponding to image features whose deviation is less than or equal to the preset deviation threshold under the same cluster into the same character category.
[0149] The preset deviation threshold can be set as needed. For example, the preset deviation threshold can be 30, 50, etc. If the deviation degree of the image feature is greater than the preset deviation threshold, it means that the image feature is significantly different from the average image feature, and the image feature is highly likely not to belong to the same character category as the other image features, so the image feature is filtered out.
[0150] If the deviation degree of an image feature is less than or equal to the preset deviation threshold, it means that the difference between the image feature and the average image feature is small, and the image feature is likely to belong to the same character category as other image features. Therefore, the character images corresponding to the image features with a deviation degree less than or equal to the preset deviation threshold under the same cluster are divided into the same character category.
[0151] In this embodiment, for each cluster in each feature subset, the average image feature corresponding to the corresponding cluster is determined based on each image feature under the corresponding cluster; for each cluster, the degree of deviation between each image feature in the corresponding cluster and the average image feature of the corresponding cluster is calculated; image features with a deviation greater than a preset deviation threshold are filtered out, and character images corresponding to image features with a deviation less than or equal to the preset deviation threshold are classified into the same character category. This can filter out image features that are significantly different from other image features, and more accurately classify the image features in each feature subset into roles.
[0152] In one embodiment, Figure 7 As shown, the above method also includes:
[0153] Step S702 : for each character category, after comparing the character images under the corresponding character category, if it is determined that a designated image in the character images does not belong to the corresponding character category, a removal instruction for the designated image is obtained.
[0154] The designated image is an image designated by a user, and the elimination instruction is an instruction for eliminating the designated image.
[0155] In one implementation, for each role category, after comparing the role images under the corresponding role category, if it is determined that the designated image in the role image does not belong to the corresponding role category, the staff selects the designated image from the role images under the corresponding role category and triggers a removal operation, and obtains a removal instruction for the designated image based on the removal operation. The staff does not need to remember a large number of role images, but only needs to compare the role images under the same role category and remove the role images under the role category that do not belong to the same role category.
[0156] In another embodiment, for each cluster in each feature subset, the computer device determines the degree of deviation between each image feature under the corresponding cluster and other image features; obtains image features whose deviation degree is greater than a preset deviation threshold, and uses the character image corresponding to the image feature under the corresponding character category as the designated image, and generates a removal instruction for the designated image.
[0157] Step S704: Eliminate the designated image from the corresponding character category based on the elimination instruction.
[0158] In this embodiment, for each role category, after comparing the role images under the corresponding role category, if it is determined that a specified image in the role images does not belong to the corresponding role category, a removal instruction for the specified image is obtained; based on the removal instruction, the specified image is removed from the corresponding role category, so that film and television characters can be classified more accurately.
[0159] Figure 8FIG. 2 is a flow chart of a method for classifying film and television roles in another embodiment. Figure 8 As shown, a computer device obtains at least one film and television video, extracts video frames from the video frames included in each film and television video, and obtains at least one target image; performs human body detection on each target image, and cuts out a human body image from the target image; extracts human body features from each human body image to obtain corresponding human body features; divides the human body features into at least one feature subset according to the film and television video to which the corresponding human body image belongs; the human body images corresponding to the human body features in each feature subset are derived from the same film and television video; for each feature subset, clusters the human body features in the corresponding feature subset to obtain at least one cluster cluster, and divides the human body images corresponding to the image features under the same cluster cluster into the same role category; for each cluster cluster in each feature subset, determines the variance of each human body feature under the corresponding cluster cluster and other human body features; if the variance of the human body feature is greater than or equal to the threshold, removes the human body image corresponding to the human body feature from the cluster cluster; if the variance of the human body feature is less than the threshold, divides the human body feature into the same role category.
[0160] In one embodiment, the above method also includes: using the character images included in each character category as training data, training the character recognition model until the training cutoff condition is met, and obtaining a trained character recognition model; the trained character recognition model is used to process the image to be recognized to predict the character category of the image to be recognized.
[0161] Among them, the training cut-off condition can be set as needed. For example. The training cut-off condition can be at least one of the following: the number of training times reaches a preset number threshold, the training duration reaches a preset duration threshold, the recognition accuracy of the role recognition model reaches a preset accuracy threshold, etc. The preset number threshold, preset duration threshold, and specified effect can all be set as needed. For example, the preset number threshold can be 100 times, the preset duration threshold can be 1h (hour), and the preset accuracy threshold can be 90%, 95%, etc.
[0162] The image to be identified is an image of a character category to be identified. The image to be identified may be a human image, a landscape image, an animation image, etc. The number of images to be identified can be set as needed, for example, the number of images to be identified is 10, 20, etc.
[0163] Specifically, the computer device inputs the image to be identified into the trained role recognition model, extracts the features to be identified of the image to be identified through the trained role recognition model, matches the features to be identified with the reference features of each preset role category to obtain a matching result, and predicts the role category of the image to be identified based on the matching result.
[0164] In one of the embodiments, the trained character recognition model can match the features to be recognized with the reference features of each preset character category to obtain the matching degree between the features to be recognized and each reference feature, determine the target feature from each reference feature based on the matching degree, and use the character category corresponding to the target feature as the character category of the image to be recognized.
[0165] It is understandable that the higher the matching degree, the higher the correlation between the feature to be identified and the reference feature. In one embodiment, the computer device selects the reference feature with the highest matching degree from each matching degree as the target feature. In another embodiment, the computer device selects the reference feature with the second highest matching degree from each matching degree as the target feature. In other embodiments, the computer device may also determine the target feature in other ways, which are not limited here.
[0166] In this embodiment, the character images included in each character category are used as training data to train the character recognition model until the training cutoff condition is met to obtain a trained character recognition model. Then, the trained character recognition model can more accurately identify the character category of the image.
[0167] In one embodiment, the above method also includes a step of constructing a role category library, which specifically includes: obtaining image features of the role images under each role category; based on the image features of the role images under each role category, determining reference image features that match the corresponding role category; associating the reference image features corresponding to each role category with the corresponding role category to construct a role category library.
[0168] The reference image features are image features that match the character categories. The character category library is a database that stores character categories and image features corresponding to the character categories.
[0169] In one embodiment, the computer device performs mean processing on the image features of the character images under each character category to obtain reference image features that match the corresponding character category. In another embodiment, the computer device may randomly select one from the image features of the character images under each character category as the reference image feature that matches the corresponding character category. In other embodiments, the computer device may determine the reference image feature that matches the corresponding character category in other ways, which are not limited here.
[0170] The computer device associates the reference image features corresponding to each character category with the corresponding character category to construct a character category library. For example, character category A is associated with the corresponding reference image feature A, character category B is associated with the corresponding reference image feature B, character category C is associated with the corresponding reference image feature C, and so on, and each character category and the corresponding reference image feature are stored in a designated location, thereby constructing a character category library.
[0171] In this embodiment, based on the image features of the character images under each character category, reference image features that match the corresponding character category are determined, and the reference image features corresponding to each character category are associated with the corresponding character category to construct a character category library, so that when the image is subsequently identified or searched for a character, character identification or search can be performed more quickly from the character category library.
[0172] In one embodiment, the above method also includes a step of identifying the character category of the image to be identified, which step specifically includes: obtaining the image to be identified; calculating the feature similarity between the target feature vector corresponding to the image to be identified and each reference image feature, and obtaining at least one feature similarity corresponding to the image to be identified; determining the target reference image feature corresponding to the maximum feature similarity, and using the character category corresponding to the target reference image feature as the character category corresponding to the image to be identified.
[0173] The target feature vector is the feature vector of the image to be identified. The feature similarity is the pixel degree between the target feature vector and the reference image feature. The target reference image feature is the reference image feature with the greatest feature similarity.
[0174] Specifically, the computer device calculates the Euclidean distance between the target feature vector corresponding to the image to be identified and each reference image feature, and obtains at least one Euclidean distance corresponding to the image to be identified. Each Euclidean distance represents the feature similarity between the target feature vector corresponding to the image to be identified and the reference image feature. The larger the Euclidean distance, the smaller the feature similarity; the smaller the Euclidean distance, the greater the feature similarity.
[0175] The computer device determines the reference image feature corresponding to the minimum Euclidean distance, that is, determines the target reference image feature corresponding to the maximum feature similarity, and uses the role category corresponding to the target reference image feature as the role category corresponding to the image to be identified.
[0176] In this embodiment, the computer device calculates the feature similarity between the target feature vector corresponding to the image to be identified and each reference image feature, obtains at least one feature similarity corresponding to the image to be identified, determines the target reference image feature corresponding to the maximum feature similarity, and uses the role category corresponding to the target reference image feature as the role category corresponding to the image to be identified, so as to accurately identify or find out the role category of the image to be identified.
[0177] In a specific embodiment, another method for classifying film and television roles is provided, and the method is applied to a computer device as an example for explanation, wherein the computer device can be specifically Figure 1 The method for classifying film and television roles comprises the following steps:
[0178] Step 1, obtaining at least one film and television video; for each film and television video, extracting at least one target image at every preset playback duration on the playback time axis of the film and television video.
[0179] Step 2, obtain the first input image size of the subject detection model; if the pixel size of the edge of the target image is larger than the first pixel size of the corresponding preset edge, delete the pixels of the target image in the direction of the edge to reduce the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; if the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, insert pixels in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; obtain a first image based on the image processed by pixel deletion and / or pixel insertion; use the first image as a new target image, and input the new target image into the subject detection model.
[0180] Step 3, perform subject detection on each target image through the subject detection model to obtain a subject detection result; if the subject detection result indicates that there is a character object in the target image, determine the character area where the character object is located based on the subject detection result; based on the character area, crop the character image including the character object from the target image.
[0181] Step 4, obtain the second input image size of the feature extraction network; if the size of the character image does not match the second input image size, adjust the size of the character image to the second input image size to obtain a second image, and input each second image into the feature extraction network.
[0182] Step 5: extract features from each second image through a feature extraction network to obtain corresponding image features.
[0183] Step 6, dividing the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video;
[0184] Step 7: For each feature subset, hierarchical clustering is performed on each image feature in the feature subset to obtain at least one cluster. Hierarchical clustering includes: taking each image feature in the corresponding feature subset as an initial image node, calculating the similarity between any two image nodes in the current round; combining the two image nodes with the highest similarity into a new image node, and continuing to execute the next round until the clustering cutoff condition is met, and finally obtaining at least one target image node, and taking each of the target image nodes obtained as a cluster; wherein each of the target image nodes obtained in the end includes a single image feature, or includes more than one image feature.
[0185] Step 8, for each cluster in each feature subset, determine the average image feature corresponding to the corresponding cluster based on each image feature under the corresponding cluster; for each cluster, calculate the degree of deviation between each image feature in the corresponding cluster and the average image feature of the corresponding cluster; filter out image features with a deviation greater than a preset deviation threshold, and classify the character images corresponding to the image features with a deviation less than or equal to the preset deviation threshold under the same cluster into the same character category.
[0186] Step 9, for each role category, after comparing the role images under the corresponding role category, if it is determined that the specified image in the role images does not belong to the corresponding role category, obtain a removal instruction for the specified image; and remove the specified image from the corresponding role category based on the removal instruction.
[0187] Step 10, using the character images included in each character category as training data, and training the character recognition model until the training cutoff condition is met to obtain a trained character recognition model; the trained character recognition model is used to process the image to be recognized to predict the character category of the image to be recognized.
[0188] Step 11, obtaining image features of the character images under each character category; based on the image features of the character images under each character category, determining reference image features that match the corresponding character category; associating the reference image features corresponding to each character category with the corresponding character category to construct a character category library.
[0189] Step 12, obtain the image to be identified; calculate the feature similarity between the target feature vector corresponding to the image to be identified and each reference image feature, and obtain at least one feature similarity corresponding to the image to be identified; determine the target reference image feature corresponding to the maximum feature similarity, and use the role category corresponding to the target reference image feature as the role category corresponding to the image to be identified.
[0190] In this embodiment, a target image from at least one film and television video is obtained, and subject detection is first performed on each target image, and a character image is cropped from the target image based on the subject detection result, and then feature extraction is performed on each character image to obtain corresponding image features, and then the image features are divided into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset is from the same film and television video. Then, for each feature subset, the image features in the corresponding feature subset are clustered to obtain at least one cluster cluster, and the same or similar image features can be quickly clustered into the same cluster cluster. The character images corresponding to the image features in the same cluster cluster represent the same character and can be classified into the same character category, so that each character in each film and television video can be quickly classified, thereby improving the efficiency of film and television character classification. In addition, the character image is cropped from the target image, and then clustering is performed based on the image features of the character image, which can avoid the influence of other factors in the target image other than the character image, such as lighting, background, image size, etc., thereby improving the accuracy and robustness of film and television character classification. Furthermore, each character image can be compared under the corresponding character category, so as to quickly eliminate the character images that do not belong to the corresponding character category, and classify each character image more quickly and accurately.
[0191] The present application also provides an application scenario, which applies the above-mentioned film and television role classification method.
[0192] Specifically, the application of the film and television role classification method in this application scenario is as follows:
[0193] A computer device obtains a plurality of TV series videos and / or movie videos, extracts a plurality of target images from each TV series video and / or movie video; performs human body detection on each target image, and crops the human body image in the target image; then extracts the human body image features of the human body image, divides the human body image features corresponding to the same TV series video into the same feature subset, and then clusters each feature subset to obtain a cluster cluster, so that each human body image can be divided into the same character category, and the human body images in each character category are images of the same character.
[0194] It should be understood that although Figures 2 to 8The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figures 2 to 8 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0195] In one embodiment, Fig. 9 As shown, a device for classifying film and television characters is provided. The device can adopt a software module or a hardware module, or a combination of the two to become a part of a computer device. The device specifically includes: an acquisition module 902, a detection module 904, a feature extraction module 906 and a classification module 908, wherein:
[0196] The acquisition module 902 is used to acquire a target image from at least one film or television video.
[0197] The detection module 904 is used to perform subject detection on each target image and crop the character image from the target image based on the subject detection result.
[0198] The feature extraction module 906 is used to extract features from each character image to obtain corresponding image features.
[0199] The classification module 908 is used to divide the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character images corresponding to the image features in each feature subset are derived from the same film and television video; for each feature subset, the image features in the corresponding feature subset are clustered to obtain at least one clustering cluster, and the character images corresponding to the image features under the same clustering cluster are classified into the same character category.
[0200] The above-mentioned film and television character classification device obtains a target image from at least one film and television video, first performs subject detection on each target image, and cuts out a character image from the target image based on the subject detection result, then performs feature extraction on each character image to obtain corresponding image features, and then divides the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video. Then, for each feature subset, clustering the image features in the corresponding feature subset to obtain at least one cluster cluster, the same or similar image features can be quickly clustered into the same cluster cluster, and the character images corresponding to the image features in the same cluster cluster represent the same character and can be divided into the same character category, so that each character in each film and television video can be quickly classified, thereby improving the efficiency of film and television character classification. In addition, cutting out the character image from the target image and then performing clustering processing based on the image features of the character image can avoid the influence of other factors in the target image other than the character image, such as lighting, background, image size, etc., thereby improving the accuracy and robustness of film and television character classification.
[0201] In one embodiment, the acquisition module 902 is further used to acquire at least one film and television video; for each film and television video, at least one target image is extracted at every preset playback duration on the playback time axis of the film and television video.
[0202] In one embodiment, the above-mentioned detection module 904 is also used to perform subject detection on each target image respectively to obtain a subject detection result; if the subject detection result indicates that there is a character object in the target image, the character area where the character object is located is determined based on the subject detection result; based on the character area, the character image including the character object is cropped out from the target image.
[0203] In one embodiment, the above-mentioned film and television character classification device also includes an adjustment module, which is used to obtain the first input image size of the subject detection model; if the size of the target image does not match the first input image size, the size of the target image is adjusted to the first input image size to obtain a first image; the first image is used as a new target image; the above-mentioned detection module 904 is also used to perform subject detection on each target image separately.
[0204] In one embodiment, the first input image size includes a first pixel size of each preset edge; the adjustment module is also used to delete pixels of the target image in the direction of the edge if the pixel size of the edge of the target image is larger than the first pixel size of the corresponding preset edge, so as to reduce the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; if the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, then insert pixels in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; based on the image processed by pixel deletion and / or pixel insertion, an adjusted first image is obtained.
[0205] In one embodiment, the above-mentioned adjustment module is also used to obtain the second input image size of the feature extraction network; if the size of the character image does not match the size of the second input image, the size of the character image is adjusted to the size of the second input image to obtain the second image; the above-mentioned feature extraction module 906 is also used to perform feature extraction on each second image respectively to obtain corresponding image features.
[0206] In one embodiment, the above-mentioned classification module 908 is also used to take each image feature in the corresponding feature subset as an initial image node, calculate the similarity between any two image nodes in the current round; combine the two image nodes with the highest similarity into a new image node, and continue to execute the next round until the clustering cutoff condition is met, and finally obtain at least one target image node, and take each of the target image nodes obtained in the end as a cluster cluster; wherein each of the target image nodes obtained in the end includes a single image feature, or includes more than one image feature.
[0207] In one embodiment, the classification module 908 is also used to determine, for each cluster in each feature subset, an average image feature corresponding to the corresponding cluster based on each image feature under the corresponding cluster; for each cluster, calculate the degree of deviation between each image feature in the corresponding cluster and the average image feature of the corresponding cluster; filter out image features whose degree of deviation is greater than a preset deviation threshold, and classify character images corresponding to image features under the same cluster whose degree of deviation is less than or equal to the preset deviation threshold into the same character category.
[0208] In one embodiment, the above-mentioned film and television character classification device also includes a elimination module, which is used for obtaining a elimination instruction for each character category when it is determined that a specified image in the character images does not belong to the corresponding character category after comparing the character images under the corresponding character category; and eliminating the specified image from the corresponding character category based on the elimination instruction.
[0209] In one embodiment, the above-mentioned film and television role classification device also includes a training module, which is used to use the role images included in each role category as training data to train the role recognition model until the training cutoff condition is met to obtain a trained role recognition model; the trained role recognition model is used to process the image to be recognized to predict the role category of the image to be recognized.
[0210] In one embodiment, the above-mentioned film and television character classification device also includes a construction module, which is used to obtain image features of character images under each character category; based on the image features of the character images under each character category, determine the reference image features that match the corresponding character category; and associate the reference image features corresponding to each character category with the corresponding character category to construct a character category library.
[0211] In one embodiment, the above-mentioned film and television character classification device also includes a recognition module, which is used to obtain an image to be recognized; calculate the feature similarity between the target feature vector corresponding to the image to be recognized and each reference image feature, and obtain at least one feature similarity corresponding to the image to be recognized; determine the target reference image feature corresponding to the maximum feature similarity, and use the character category corresponding to the target reference image feature as the character category corresponding to the image to be recognized.
[0212] For the specific definition of the film and television role classification device, please refer to the definition of the film and television role classification method above, which will not be repeated here. Each module in the above-mentioned film and television role classification device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0213] In one embodiment, a computer device is provided. The computer device may be a terminal or a server. The internal structure diagram thereof may be as follows: Fig.10 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as film and television videos, target images, and character images. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for classifying film and television characters is implemented.
[0214] Those skilled in the art will understand that Fig.10The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0215] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0216] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0217] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0218] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database 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 or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0219] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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.
[0220] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for classifying film and television roles, It is characterized in that The method comprises: Acquire a target image from at least one film or television video; Performing subject detection on each of the target images respectively, and cutting out the character image from the target image based on the subject detection result; Extracting features from each character image to obtain corresponding image features; Dividing the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character images corresponding to the image features in each feature subset are from the same film and television video; For each feature subset, multiple rounds of clustering are performed on the image features in the corresponding feature subset to obtain at least one clustering cluster; wherein, in each clustering process, different image nodes are combined to update the image nodes, and clustering is stopped when a clustering cutoff condition is met, and finally at least one target image node is obtained as the at least one clustering cluster; wherein the initial image node is the image feature; For each cluster in each of the feature subsets, based on the individual image features under the targeted cluster, the average image feature corresponding to the targeted cluster is determined, the degree of deviation between each image feature in the targeted cluster and the average image feature of the corresponding cluster is calculated, the image features whose degree of deviation is greater than a preset deviation threshold are filtered out, and the character images corresponding to the image features whose degree of deviation is less than or equal to the preset deviation threshold under the same cluster are classified into the same character category.
2. The method according to claim 1, It is characterized in that The obtaining of a target image from at least one film or television video includes: Get at least one movie video; For each film and television video, at least one target image is extracted at every preset playback duration on the playback time axis of the film and television video.
3. The method according to claim 1, It is characterized in that The subject detection is performed on each of the target images respectively, and the character image is cut out from the target image based on the subject detection result, including: Performing subject detection on each of the target images to obtain subject detection results; If the subject detection result indicates that there is a character object in the target image, determining a character region where the character object is located based on the subject detection result; Based on the character area, a character image including the character object is cut out from the target image.
4. The method according to claim 1, It is characterized in that The method further comprises: Get the first input image size of the subject detection model; If the size of the target image does not match the size of the first input image, adjusting the size of the target image to the size of the first input image to obtain a first image; The first image is used as a new target image, and the new target image is input into the subject detection model, and the step of performing subject detection on each of the target images is performed through the subject detection model.
5. The method according to claim 4, It is characterized in that The first input image size includes a first pixel size of each preset side; if the size of the target image does not match the size of the first input image, adjusting the size of the target image to the size of the first input image to obtain a first image, comprising: If the pixel size of the edge of the target image is larger than the first pixel size corresponding to the preset edge, then deleting the pixels of the target image in the direction of the edge to reduce the pixel size of the edge of the target image to the first pixel size corresponding to the preset edge; If the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, inserting pixels in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; A first image is obtained based on the image processed by pixel deletion and / or pixel insertion.
6. The method according to claim 1, It is characterized in that The extracting features of each character image to obtain corresponding image features includes: Get the second input image size of the feature extraction network; If the size of the character image does not match the size of the second input image, adjusting the size of the character image to the size of the second input image to obtain a second image; The feature extraction network is used to extract features from each of the second images to obtain corresponding image features.
7. The method according to claim 1, It is characterized in that The step of performing multiple rounds of clustering on the image features in the corresponding feature subset to obtain at least one clustering cluster comprises: Take each image feature in the corresponding feature subset as an initial image node and calculate the similarity between any two image nodes in the current round; The two image nodes with the highest similarity are combined into a new image node, and the next round is continued until the clustering cutoff condition is met, and finally at least one target image node is obtained, and each of the target image nodes obtained in the end is used as a cluster cluster; wherein each of the target image nodes obtained in the end includes a single image feature, or includes more than one image feature.
8. The method according to claim 1, It is characterized in that The method further comprises: For each of the character categories, after comparing the character images under the corresponding character category, if it is determined that a designated image in the character images does not belong to the corresponding character category, obtaining a removal instruction for the designated image; The designated image is removed from the corresponding character category based on the removal instruction.
9. The method according to any one of claims 1 to 8, It is characterized in that The method further comprises: The character images included in each of the character categories are used as training data to train the character recognition model until the training cutoff condition is met to obtain a trained character recognition model; the trained character recognition model is used to process the image to be recognized to predict the character category of the image to be recognized.
10. The method according to any one of claims 1 to 8, It is characterized in that The method further comprises: Obtain image features of character images under each character category; Based on the image features of the character images under each character category, determining reference image features that match the corresponding character category; The reference image features corresponding to each character category are associated with the corresponding character category to construct a character category library.
11. The method according to claim 10, It is characterized in that The method further comprises: Obtain an image to be recognized; Calculating the feature similarity between the target feature vector corresponding to the image to be identified and each reference image feature to obtain at least one feature similarity corresponding to the image to be identified; The target reference image feature corresponding to the maximum feature similarity is determined, and the role category corresponding to the target reference image feature is used as the role category corresponding to the image to be identified.
12. A device for classifying film and television characters, It is characterized in that The device comprises: An acquisition module, used for acquiring a target image from at least one film or television video; A detection module, used to perform subject detection on each of the target images, and cut out a character image from the target image based on the subject detection result; A feature extraction module, used to extract features from each character image to obtain corresponding image features; A classification module is used to divide the image features into at least one feature subset according to the film and television video to which the corresponding character image belongs; the character image corresponding to the image features in each feature subset comes from the same film and television video; for each feature subset, multiple rounds of clustering are performed on the image features in the corresponding feature subset to obtain at least one cluster cluster; wherein, in each clustering process, different image nodes are combined to update the image nodes, and clustering is stopped when the clustering cutoff condition is met, so that at least one target image node is finally obtained as the at least one cluster cluster; wherein the initial image node is the image feature; for each cluster cluster in each of the feature subsets, based on each image feature under the targeted cluster cluster, the average image feature corresponding to the targeted cluster cluster is determined, the degree of deviation between each image feature in the targeted cluster cluster and the average image feature of the corresponding cluster cluster is calculated, the image features whose degree of deviation is greater than a preset deviation threshold are filtered out, and the character images corresponding to the image features whose degree of deviation is less than or equal to the preset deviation threshold under the same cluster cluster are classified into the same character category.
13. The device according to claim 12, It is characterized in that The acquisition module is further used for: Get at least one movie video; For each film and television video, at least one target image is extracted at every preset playback duration on the playback time axis of the film and television video.
14. The device according to claim 12, It is characterized in that The detection module is further used for: Performing subject detection on each of the target images to obtain subject detection results; If the subject detection result indicates that there is a character object in the target image, determining a character region where the character object is located based on the subject detection result; Based on the character area, a character image including the character object is cut out from the target image.
15. The device according to claim 12, It is characterized in that The device further comprises an adjustment module, wherein the adjustment module is configured to: Get the first input image size of the subject detection model; If the size of the target image does not match the size of the first input image, adjusting the size of the target image to the size of the first input image to obtain a first image; The first image is used as a new target image, and the new target image is input into the subject detection model, and the step of performing subject detection on each of the target images is performed through the subject detection model.
16. The device according to claim 15, It is characterized in that The first input image size includes a first pixel size of each preset side; the adjustment module is further used to: If the pixel size of the edge of the target image is larger than the first pixel size corresponding to the preset edge, then deleting the pixels of the target image in the direction of the edge to reduce the pixel size of the edge of the target image to the first pixel size corresponding to the preset edge; If the pixel size of the edge of the target image is smaller than the first pixel size of the corresponding preset edge, inserting pixels in the direction of the edge of the target image to enlarge the pixel size of the edge of the target image to the first pixel size of the corresponding preset edge; A first image is obtained based on the image processed by pixel deletion and / or pixel insertion.
17. The device according to claim 12, It is characterized in that The device also includes an adjustment module, which is used to: Get the second input image size of the feature extraction network; If the size of the character image does not match the size of the second input image, adjusting the size of the character image to the size of the second input image to obtain a second image; The feature extraction network is used to extract features from each of the second images to obtain corresponding image features.
18. The device according to claim 12, It is characterized in that The classification module is further used for: Take each image feature in the corresponding feature subset as an initial image node and calculate the similarity between any two image nodes in the current round; The two image nodes with the highest similarity are combined into a new image node, and the next round is continued until the clustering cutoff condition is met, and finally at least one target image node is obtained, and each of the target image nodes obtained in the end is used as a cluster cluster; wherein each of the target image nodes obtained in the end includes a single image feature, or includes more than one image feature.
19. The device according to claim 12, It is characterized in that The device also includes a rejection module, which is used to: For each of the character categories, after comparing the character images under the corresponding character category, if it is determined that a designated image in the character images does not belong to the corresponding character category, obtaining a removal instruction for the designated image; The designated image is removed from the corresponding character category based on the removal instruction.
20. The device according to any one of claims 12 to 19, It is characterized in that The device also includes a training module for: The character images included in each of the character categories are used as training data to train the character recognition model until the training cutoff condition is met to obtain a trained character recognition model; the trained character recognition model is used to process the image to be recognized to predict the character category of the image to be recognized.
21. The device according to any one of claims 12 to 19, It is characterized in that The device further comprises a building block, wherein the building block is configured to: Obtain image features of character images under each character category; Based on the image features of the character images under each character category, determining reference image features that match the corresponding character category; The reference image features corresponding to each character category are associated with the corresponding character category to construct a character category library.
22. The device according to claim 21, It is characterized in that The device also includes an identification module, which is used to: Obtain an image to be recognized; Calculating the feature similarity between the target feature vector corresponding to the image to be identified and each reference image feature to obtain at least one feature similarity corresponding to the image to be identified; The target reference image feature corresponding to the maximum feature similarity is determined, and the role category corresponding to the target reference image feature is used as the role category corresponding to the image to be identified.
23. A computer device comprising a memory and a processor, wherein the memory stores a computer program, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
24. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
25. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Cited By
Method and system for role alignment in cross-scene long video based on large model
CN121838232A
