Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Before introducing the image processing method, the image processing apparatus, the readable medium, and the electronic device provided by the present disclosure, an application scenario related to various embodiments of the present disclosure is first introduced. The application scene may be any scene that needs to detect whether an image is an abnormal image, for example, the scene may be a scene that performs video content security detection on a video by detecting whether an image in the video is an abnormal image. The abnormal image may be an image containing high-risk information such as pornography, drug addiction, violence, evil education, various customs and the like, and the image may be a single image (for example, a head portrait of a user on a network) or a video frame in a video (for example, a short video platform, a video uploaded by a user in social media), which is not particularly limited in this disclosure.
FIG. 1 is a flow diagram illustrating an image processing method according to an exemplary embodiment. As shown in fig. 1, the method may include the steps of:
step 101, acquiring a target image in a video to be processed.
For example, to avoid adverse effects caused by the flow of high-risk videos on the network, content detection may be performed on the videos on the network in a video content security detection manner to determine whether high-risk information exists in the videos. Firstly, a video needing content detection can be used as a video to be processed, and a target image is selected from the video to be processed. The way of selecting the target image may be: and according to a preset rule, performing frame extraction on the video to be processed, and taking the extracted video frame in the video to be processed as a target image. Wherein the preset rule may include at least one of the following:
1) selecting a video frame corresponding to a designated time in a video to be processed, wherein the designated time can be a certain time point in the preset video to be processed or a time point corresponding to each division point after the video to be processed is uniformly divided, which is equivalent to performing uniform frame extraction on the video to be processed, and taking the video frame obtained by uniform frame extraction as a target image.
2) And selecting a key frame in the video to be processed, wherein the key frame is a video frame (namely the most complete frame picture in the video to be processed) containing most information in the video to be processed. For example, an I-frame (english: Intra-coded picture, chinese: Intra-coded picture frame) in the video to be processed may be selected as the key frame.
3) Selecting a scene conversion frame in a video to be processed, wherein the similarity between the scene conversion frame and an adjacent video frame is smaller than or equal to a preset similarity threshold value, the adjacent video frame is a video frame which is adjacent to the scene conversion frame and is positioned before the scene conversion frame in the video to be processed, and the scene conversion frame is used for indicating that the video enters a new scene. For example, a video scene extraction algorithm may be adopted to select a scene change frame according to the similarity between video frames in the video to be processed, and if the similarity between a previous video frame and a next video frame in the video to be processed is less than or equal to a preset similarity threshold, the next video frame is used as the scene change frame.
And 102, determining image detection information corresponding to the target image through a pre-trained image detection model according to the target image.
The image detection model comprises a target convolutional layer and a processing layer, the target convolutional layer is used for extracting the characteristics of a target image, the processing layer is used for determining image detection information according to the characteristics of the target image, the image detection information is used for indicating whether the target image is an abnormal image or not, the target convolutional layer is a convolutional layer in a first encoder, the first encoder is obtained by utilizing an unmarked sample set to train a preset network, and the processing layer is obtained by utilizing an marked sample set to train a preset neural network layer.
In an example, after the target image is acquired, it is necessary to determine whether the video to be processed is a high-risk video by judging whether the target image is an abnormal image. In order to reduce the dependence on the annotation data in the process of judging whether the target image is an abnormal image, a model for detecting whether the image is an abnormal image can be trained in a mode of combining unsupervised (or semi-supervised) and supervision in advance. Specifically, a preset network including the first encoder may be trained by using a large amount of label-free data (i.e., a large amount of images of various types) on the network as a label-free sample set, and after the preset network is trained, the convolutional layer (which may be all or part of the convolutional layer in the first encoder) in the first encoder is used as a target convolutional layer. The first encoder is configured to perform feature extraction on an image in a label-free sample set, and the preset network may be obtained by training the label-free sample set in a contrast learning (english: contrast learning) manner, for example.
Then, the manually labeled labeling data can be used as a labeling sample set, and supervised fine tuning is performed on the target convolutional layer on the labeling sample set, so as to obtain an image detection model. The image detection model may output, based on the input image, image detection information corresponding to the image and indicating whether the image is an abnormal image. For example, the labeled sample set may be used to train the preset neural network layer, and after the training of the preset neural network layer is completed, the trained preset neural network layer may be used as the processing layer. And splicing the target convolution layer and the processing layer, and taking the neural network obtained after splicing as an image detection model. The processing layer is used for outputting image detection information corresponding to an input certain image according to the image characteristics of the image. By training the image detection model in a mode of combining unsupervised (or semi-supervised) and supervised, a large amount of label-free data on a network can be efficiently utilized, so that an accurate image detection model is obtained on the premise of not increasing the labeling cost, the performance of the image detection model is improved, and the accuracy of the image detection information determined by the image detection model is further improved.
Further, after obtaining the image detection model, the target image may be input into the image detection model to obtain the image detection information output by the image detection model. The image detection information may be any information that can indicate that the target image is an abnormal image. For example, the image detection information may be an image type of the target image, and the image type may include a normal image type and an abnormal image type, and when the image type of the target image is the abnormal image type, the image detection information indicates that the target image is the abnormal image. The abnormal image types may include pornography, drug abuse, violence, evil education, darkness, and vulgar, where the processing layer is used to perform classification tasks for the image types. For another example, the image detection information may be an abnormal object image in the target image, which can reflect that the target image is an abnormal image, and when the image detection information includes the abnormal object image, the image detection information indicates that the target image is the abnormal image, and the processing layer is configured to perform a task of detecting the abnormal object image or perform a task of dividing the abnormal object image.
And 103, performing abnormal image processing on the target image when the image detection information indicates that the target image is an abnormal image.
In this step, in a case where the image detection information indicates that the target image is an abnormal image, abnormal image processing may be performed on the target image. The abnormal image processing may include any one of deleting the target image, blurring the target image, and marking the target image. In addition, the target image can be combined with text information and audio information in the video to be processed to further judge whether the target image is an abnormal image, so that the accuracy of judging whether the target image is an abnormal image is improved.
In summary, the present disclosure first obtains a target image in a video to be processed, and determines image detection information corresponding to the target image according to the target image through a pre-trained image detection model, where the image detection model includes a target convolution layer and a processing layer, the target convolution layer is used to extract features of the target image, the processing layer is used to determine the image detection information according to the features of the target image, the image detection information is used to indicate whether the target image is an abnormal image, the target convolution layer is a convolution layer in a first encoder, the first encoder is obtained by training a preset network using a non-labeled sample set, the processing layer is obtained by training a preset neural network layer using a labeled sample set, and then, when the image detection information indicates that the target image is an abnormal image, the target image is subjected to abnormal image processing. The image detection model is obtained by training the marked sample set on the basis of the unmarked sample set, the image detection model does not need to be trained by relying on a large amount of marked data, the accurate image detection model can be obtained even under the condition of no large amount of marked data, the accuracy of the image detection information determined by the image detection model is improved, and the target image detected as the abnormal image is processed in time.
Fig. 2 is a flow chart illustrating one step 102 according to the embodiment shown in fig. 1. As shown in fig. 2, step 102 may include the steps of:
step 1021, preprocessing the target image to obtain a processed target image, wherein the preprocessing includes at least one of graying processing, geometric transformation processing and image enhancement processing.
Step 1022, using the processed target image as the input of the image detection model, to obtain the image detection information output by the image detection model.
For example, after the target image is acquired, the target image may be preprocessed to obtain a processed target image. For example, the graying process, the geometric transformation process, and the image enhancement process may be sequentially performed on the target image to obtain a processed target image. The preprocessing can eliminate irrelevant information in the target image, recover the relevant information, enhance the detectability of the relevant information and simplify the data to the maximum extent, thereby ensuring the accuracy of determining the image detection information through the image detection model. Then, the processed target image may be input into the image detection model, so as to obtain the image detection information output by the image detection model.
FIG. 3 is a flow diagram illustrating training an image detection model according to an exemplary embodiment. As shown in fig. 3, the predetermined network includes a first encoder and a second encoder, and the image detection model is trained by:
step 201, obtaining a non-labeled sample set and a labeled sample set.
The annotated sample set comprises annotated image samples and image detection information samples corresponding to the annotated image samples.
In one scenario, an unlabeled sample set including unlabeled image samples may first be obtained. For example, a large number of videos may be collected from a network (e.g., on a short video platform), 5 frames of video may be sampled at equal intervals for each video, and a set of unlabeled samples may be constructed using the 5 frames of video sampled for each video. Furthermore, the unlabeled sample set can be packed into an Arnold _ dataset format and uploaded to an HDFS (Hadoop Distributed File System, Chinese) so as to facilitate access and reading on the Arnold cluster. Then, an annotated sample set comprising annotated image samples, image detection information samples corresponding to the annotated image samples, may be obtained. For example, when a certain annotated image sample is an image that includes violence information, if the processing layer is used to perform a classification task for an image type, the image detection information sample (i.e., the image type) corresponding to the annotated image sample may be the violence type.
Step 202, training the preset network according to the unmarked sample set, and determining a target convolutional layer from the convolutional layers of the first encoder included in the trained preset network.
And 203, training the preset neural network layer according to the labeled sample set, and taking the trained preset neural network layer as a processing layer.
For example, if the preset network is trained in a contrast learning manner, when the first encoder is trained, a second encoder having the same structure as the first encoder needs to be maintained, that is, the preset network includes the first encoder and the second encoder. After the label-free sample set is obtained, the preset network can be trained according to the label-free sample set, and after the preset network is trained, the convolutional layer in the first encoder is used as a target convolutional layer. Then, the preset neural network layer can be trained according to the labeled sample set, and after the training of the preset neural network layer is completed, the trained preset neural network layer is used as a processing layer. The preset neural network Layer may be any decoder (chinese: encoder) structure, or may be an MLP (english: Muti-Layer persistence, chinese: multilayer perceptron), and the disclosure does not specifically limit this. Finally, the processing layer can be spliced after the target convolution layer to obtain the image detection model.
Fig. 4 is a flow chart illustrating one step 202 according to the embodiment shown in fig. 3. As shown in fig. 4, the unlabeled image sample is plural, and step 202 may include the following steps:
step 2021, select a first number of unlabeled image samples from the plurality of unlabeled image samples.
Step 2022, for each unlabeled image sample in the first number of unlabeled image samples, performing data amplification on the unlabeled image sample, and inputting the unlabeled image sample into the first encoder and the second encoder respectively to obtain a first feature vector output by the first encoder and a second feature vector output by the second encoder.
For example, in training the preset network, a first number of unlabeled image samples (the first number may be 256, for example) may be selected from a plurality of unlabeled image samples included in the unlabeled sample set to form a Batch (chinese: Batch). Then, each unmarked image sample x in the first number of unmarked image samples can be sequentially aimed at
iUsing random data augmentation transform to the unlabeled image sample x
iCarrying out data amplification processing to obtain x
iCorresponding positive sample pair
And
and will be
And
respectively inputting the first characteristic vector q and the second characteristic vector q into a first coder and a second coder to obtain a first characteristic vector q output by the first coder
iAnd a second eigenvector k output by the second encoder
i。
Step 2023, updating the first encoder and the second encoder according to the first feature vector and the second feature vector corresponding to each unlabeled image sample.
And circularly executing the steps 2021 to 2023 until the number of times of circularly executing reaches a preset number.
Illustratively, the first feature vector q corresponding to each sample of the label-free image is obtainediAnd a second feature vector kiThen, the second feature vector k corresponding to each unlabeled image sample can be obtainediAnd sequentially inputting the data into a preset queue, and updating the preset queue. The number of the elements of the preset queue is a second number, the second number is smaller than or equal to the First number, the preset queue may be a Memory queue (english: Memory Bank) with a fixed size of 65536, and the preset queue is updated in an FIFO (english: First in First out) updating manner. The first encoder may then be updated according to the first feature vector corresponding to each unlabeled image sample and the preset queue, for example, the first feature vector q corresponding to each unlabeled image sample may be usediAnd calculating a contrast loss function (English) according to the second number of elements in the preset queue, calculating the gradient of the first encoder, and updating the first encoder according to a random gradient descent method. After the first encoder is updated, the first encoder can be updated according to the updated first encoderAnd the coder updates the second coder (namely, the second coder does not calculate the gradient in the training process, but the second coder is updated after the first coder is updated every time). After the second encoder is updated, a round of iterative training on the preset network is equivalently completed, and then the process can be repeatedly executed until the iterative training on the preset network reaches the preset times, so as to complete the training on the preset network.
FIG. 5 is a flow diagram illustrating another method of training an image detection model according to an example embodiment. As shown in fig. 5, the predetermined network includes a first encoder and a second encoder, and the image detection model is trained by:
step 201, obtaining a non-labeled sample set and a labeled sample set.
The annotated sample set comprises annotated image samples and image detection information samples corresponding to the annotated image samples.
Step 202, training the preset network according to the unmarked sample set, and determining a target convolutional layer from the convolutional layers of the first encoder included in the trained preset network.
And 204, training a preset model according to the labeled sample set, wherein the preset model comprises a target convolution layer and a preset neural network layer, and the preset neural network layer included in the trained preset model is used as a processing layer.
In another scenario, an unlabeled sample set including unlabeled image samples may be obtained first, and an labeled sample set including labeled image samples and image detection information samples corresponding to the labeled image samples may be obtained. If the preset network is trained in a contrast learning manner, after the label-free sample set is obtained, the preset network can be trained according to the label-free sample set, and after the preset network is trained, the convolutional layer in the first encoder is used as a target convolutional layer. Then, the target convolution layer and the preset neural network layer may be used as an integrated preset model, the preset model is trained according to the labeled sample set (that is, the whole neural network formed by the target convolution layer and the preset neural network layer is jointly trained), and after the preset model is trained, the preset neural network layer included in the trained preset model is used as a processing layer.
In summary, the present disclosure first obtains a target image in a video to be processed, and determines image detection information corresponding to the target image according to the target image through a pre-trained image detection model, where the image detection model includes a target convolution layer and a processing layer, the target convolution layer is used to extract features of the target image, the processing layer is used to determine the image detection information according to the features of the target image, the image detection information is used to indicate whether the target image is an abnormal image, the target convolution layer is a convolution layer in a first encoder, the first encoder is obtained by training a preset network using a non-labeled sample set, the processing layer is obtained by training a preset neural network layer using a labeled sample set, and then, when the image detection information indicates that the target image is an abnormal image, the target image is subjected to abnormal image processing. The image detection model is obtained by training the marked sample set on the basis of the unmarked sample set, the image detection model does not need to be trained by relying on a large amount of marked data, the accurate image detection model can be obtained even under the condition of no large amount of marked data, the accuracy of the image detection information determined by the image detection model is improved, and the target image detected as the abnormal image is processed in time.
Fig. 6 is a block diagram illustrating an image processing apparatus according to an exemplary embodiment. As shown in fig. 5, the apparatus 300 includes:
an obtaining module 301, configured to obtain a target image in a video to be processed.
The determining module 302 is configured to determine, according to the target image, image detection information corresponding to the target image through a pre-trained image detection model.
The image detection model comprises a target convolutional layer and a processing layer, the target convolutional layer is used for extracting the characteristics of a target image, the processing layer is used for determining image detection information according to the characteristics of the target image, the image detection information is used for indicating whether the target image is an abnormal image or not, the target convolutional layer is a convolutional layer in a first encoder, the first encoder is obtained by utilizing an unmarked sample set to train a preset network, and the processing layer is obtained by utilizing an marked sample set to train a preset neural network layer.
And the processing module 303 is configured to perform abnormal image processing on the target image when the image detection information indicates that the target image is an abnormal image.
Optionally, the obtaining module 301 is configured to:
and according to a preset rule, performing frame extraction on the video to be processed, and taking the extracted video frame in the video to be processed as a target image.
Wherein the preset rule comprises at least one of the following:
and selecting a video frame corresponding to the specified time in the video to be processed.
And selecting a key frame in the video to be processed, wherein the key frame is a video frame containing most information in the video to be processed.
And selecting a scene conversion frame in the video to be processed, wherein the similarity between the scene conversion frame and an adjacent video frame is less than or equal to a preset similarity threshold, and the adjacent video frame is a video frame which is adjacent to the scene conversion frame and is positioned before the scene conversion frame in the video to be processed.
FIG. 7 is a block diagram illustrating a determination module according to the embodiment shown in FIG. 1. As shown in fig. 7, the determining module 302 includes:
the preprocessing submodule 3021 is configured to preprocess the target image to obtain a processed target image, where the preprocessing includes at least one of graying processing, geometric transformation processing, and image enhancement processing.
The determining submodule 3022 is configured to use the processed target image as an input of the image detection model, and obtain image detection information output by the image detection model.
Optionally, the preset network includes a first encoder and a second encoder, and the determining module 302 is configured to train to obtain the image detection model by:
and acquiring a non-labeled sample set and a labeled sample set. The label-free sample set comprises label-free image samples, and the label sample set comprises label image samples and image detection information samples corresponding to the label image samples.
And training the preset network according to the unmarked sample set, and determining a target convolutional layer from the convolutional layers of the first encoder included in the trained preset network.
And training the preset neural network layer according to the labeled sample set, and taking the trained preset neural network layer as a processing layer.
Optionally, the preset network includes a first encoder and a second encoder, and the determining module 302 is configured to train to obtain the image detection model by:
and acquiring a non-labeled sample set and a labeled sample set. The label-free sample set comprises label-free image samples, and the label sample set comprises label image samples and image detection information samples corresponding to the label image samples.
And training the preset network according to the unmarked sample set, and determining a target convolutional layer from the convolutional layers of the first encoder included in the trained preset network.
And training a preset model according to the labeled sample set, wherein the preset model comprises a target convolution layer and a preset neural network layer, and the preset neural network layer included in the trained preset model is used as a processing layer.
Optionally, the determining module 302 is configured to:
a first number of unlabeled image samples are selected from the plurality of unlabeled image samples.
And for each unmarked image sample in the first quantity of unmarked image samples, performing data amplification processing on the unmarked image sample, and respectively inputting the unmarked image sample into the first encoder and the second encoder to obtain a first feature vector output by the first encoder and a second feature vector output by the second encoder.
And updating the first encoder and the second encoder according to the first characteristic vector and the second characteristic vector corresponding to each unmarked image sample.
And circularly executing the steps of selecting a first number of unmarked image samples from the unmarked image samples, and updating the first encoder and the second encoder according to the first eigenvector and the second eigenvector corresponding to each unmarked image sample until the number of times of circularly executing reaches the preset number.
Optionally, the determining module 302 is configured to:
and sequentially inputting the second feature vectors corresponding to each unmarked image sample into a preset queue, and updating the preset queue, wherein the number of elements of the preset queue is a second number, and the second number is less than or equal to the first number.
And updating the first encoder according to the first feature vector corresponding to each unmarked image sample and the preset queue.
And after the first encoder is updated, updating the second encoder according to the updated first encoder.
In summary, the present disclosure first obtains a target image in a video to be processed, and determines image detection information corresponding to the target image according to the target image through a pre-trained image detection model, where the image detection model includes a target convolution layer and a processing layer, the target convolution layer is used to extract features of the target image, the processing layer is used to determine the image detection information according to the features of the target image, the image detection information is used to indicate whether the target image is an abnormal image, the target convolution layer is a convolution layer in a first encoder, the first encoder is obtained by training a preset network using a non-labeled sample set, the processing layer is obtained by training a preset neural network layer using a labeled sample set, and then, when the image detection information indicates that the target image is an abnormal image, the target image is subjected to abnormal image processing. The image detection model is obtained by training the marked sample set on the basis of the unmarked sample set, the image detection model does not need to be trained by relying on a large amount of marked data, the accurate image detection model can be obtained even under the condition of no large amount of marked data, the accuracy of the image detection information determined by the image detection model is improved, and the target image detected as the abnormal image is processed in time.
Referring now to fig. 8, a schematic diagram of an electronic device (e.g., the terminal device or the server of fig. 1) 400 suitable for implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 8, electronic device 400 may include a processing device (e.g., central processing unit, graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 8 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a target image in a video to be processed; determining image detection information corresponding to the target image through a pre-trained image detection model according to the target image; the image detection model comprises a target convolution layer and a processing layer, wherein the target convolution layer is used for extracting the characteristics of the target image, the processing layer is used for determining the image detection information according to the characteristics of the target image, and the image detection information is used for indicating whether the target image is an abnormal image or not; the target convolutional layer is a convolutional layer in a first encoder, the first encoder is obtained by training a preset network by using a label-free sample set, and the processing layer is obtained by training a preset neural network layer by using a label sample set; and performing abnormal image processing on the target image under the condition that the image detection information indicates that the target image is an abnormal image.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of the module does not in some cases constitute a limitation of the module itself, and for example, the acquiring module may also be described as a "module that acquires a target image in a video to be processed".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides an image processing method according to one or more embodiments of the present disclosure, including: acquiring a target image in a video to be processed; determining image detection information corresponding to the target image through a pre-trained image detection model according to the target image; the image detection model comprises a target convolution layer and a processing layer, wherein the target convolution layer is used for extracting the characteristics of the target image, the processing layer is used for determining the image detection information according to the characteristics of the target image, and the image detection information is used for indicating whether the target image is an abnormal image or not; the target convolutional layer is a convolutional layer in a first encoder, the first encoder is obtained by training a preset network by using a label-free sample set, and the processing layer is obtained by training a preset neural network layer by using a label sample set; and performing abnormal image processing on the target image under the condition that the image detection information indicates that the target image is an abnormal image.
Example 2 provides the method of example 1, in accordance with one or more embodiments of the present disclosure, the acquiring a target image in a video to be processed, including: according to a preset rule, performing frame extraction on the video to be processed, and taking the extracted video frame in the video to be processed as the target image; wherein the preset rule comprises at least one of: selecting a video frame corresponding to a designated moment in the video to be processed; selecting a key frame in the video to be processed, wherein the key frame is a video frame containing most information in the video to be processed; and selecting a scene change frame in the video to be processed, wherein the similarity between the scene change frame and an adjacent video frame is less than or equal to a preset similarity threshold, and the adjacent video frame is a video frame which is adjacent to the scene change frame and is positioned before the scene change frame in the video to be processed.
Example 3 provides the method of example 1, wherein determining, according to the target image and through a pre-trained image detection model, image detection information corresponding to the target image includes: preprocessing the target image to obtain a processed target image, wherein the preprocessing comprises at least one of graying processing, geometric transformation processing and image enhancement processing; and taking the processed target image as the input of the image detection model to obtain the image detection information output by the image detection model.
Example 4 provides the method of example 1, the preset network including a first encoder and a second encoder, the image detection model being trained by: acquiring the label-free sample set and the label sample set; the annotated sample set comprises annotated image samples, and the annotated sample set comprises annotated image samples and image detection information samples corresponding to the annotated image samples; training the preset network according to the label-free sample set, and determining the target convolutional layer from the convolutional layers of the first encoder included in the trained preset network; and training the preset neural network layer according to the labeled sample set, and taking the trained preset neural network layer as the processing layer.
Example 5 provides the method of example 1, the preset network including a first encoder and a second encoder, the image detection model being trained by: acquiring the label-free sample set and the label sample set; the annotated sample set comprises annotated image samples, and the annotated sample set comprises annotated image samples and image detection information samples corresponding to the annotated image samples; training the preset network according to the label-free sample set, and determining the target convolutional layer from the convolutional layers of the first encoder included in the trained preset network; and training a preset model according to the labeled sample set, wherein the preset model comprises the target convolution layer and the preset neural network layer, and the preset neural network layer included in the trained preset model is used as the processing layer.
Example 6 provides the method of example 4 or 5, wherein the unlabeled image sample is a plurality of samples, and the training the preset network according to the unlabeled sample set includes: selecting a first number of unlabeled image samples from the unlabeled image samples; for each unmarked image sample in a first number of unmarked image samples, performing data amplification processing on the unmarked image sample, and respectively inputting the unmarked image sample into the first encoder and the second encoder to obtain a first feature vector output by the first encoder and a second feature vector output by the second encoder; updating the first encoder and the second encoder according to the first feature vector and the second feature vector corresponding to each label-free image sample; and circularly executing the step of selecting a first number of unmarked image samples from the plurality of unmarked image samples, and updating the first encoder and the second encoder according to the first feature vector and the second feature vector corresponding to each unmarked image sample until the number of times of circularly executing reaches a preset number.
Example 7 provides the method of example 6, wherein updating the first encoder and the second encoder according to the first feature vector and the second feature vector corresponding to each of the unlabeled image samples, includes: sequentially inputting the second feature vectors corresponding to each unmarked image sample into a preset queue, and updating the preset queue, wherein the number of elements of the preset queue is a second number, and the second number is less than or equal to the first number; updating the first encoder according to the first feature vector corresponding to each unmarked image sample and the preset queue; and after the first encoder is updated, updating the second encoder according to the updated first encoder.
Example 8 provides an image processing apparatus according to one or more embodiments of the present disclosure, the apparatus including: the acquisition module is used for acquiring a target image in a video to be processed; the determining module is used for determining image detection information corresponding to the target image through a pre-trained image detection model according to the target image; the image detection model comprises a target convolution layer and a processing layer, wherein the target convolution layer is used for extracting the characteristics of the target image, the processing layer is used for determining the image detection information according to the characteristics of the target image, and the image detection information is used for indicating whether the target image is an abnormal image or not; the target convolutional layer is a convolutional layer in a first encoder, the first encoder is obtained by training a preset network by using a label-free sample set, and the processing layer is obtained by training a preset neural network layer by using a label sample set; and the processing module is used for performing abnormal image processing on the target image under the condition that the image detection information indicates that the target image is an abnormal image.
Example 9 provides a computer-readable medium having stored thereon a computer program that, when executed by a processing apparatus, implements the steps of the methods of examples 1-7, in accordance with one or more embodiments of the present disclosure.
Example 10 provides, in accordance with one or more embodiments of the present disclosure, an electronic device comprising: a storage device having a computer program stored thereon; processing means for executing the computer program in the storage means to implement the steps of the methods of examples 1-7.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.