CN112967356A - Image filling method and device, electronic device and medium - Google Patents

Image filling method and device, electronic device and medium Download PDF

Info

Publication number
CN112967356A
CN112967356A CN202110247367.3A CN202110247367A CN112967356A CN 112967356 A CN112967356 A CN 112967356A CN 202110247367 A CN202110247367 A CN 202110247367A CN 112967356 A CN112967356 A CN 112967356A
Authority
CN
China
Prior art keywords
image
filled
region
background
features
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110247367.3A
Other languages
Chinese (zh)
Inventor
李超
高源�
李甫
何栋梁
孙昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202110247367.3A priority Critical patent/CN112967356A/en
Publication of CN112967356A publication Critical patent/CN112967356A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • G06T3/053Detail-in-context presentations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Image Analysis (AREA)

Abstract

The present disclosure provides an image filling method, an image filling apparatus, an electronic device, a computer-readable storage medium, and a computer program product, which relate to the field of artificial intelligence, and in particular to the technical field of computer vision and deep learning. The implementation scheme is as follows: the method comprises the steps of obtaining an image to be filled, and a first mask image and a second mask image which correspond to the image to be filled, wherein the image to be filled comprises a region to be filled and a background region, the first mask image indicates the relative position relationship between the region to be filled and the background region, and the second mask image indicates the relative position relationship between a user clue region and an external region thereof; extracting background features corresponding to the background area based on the image to be filled and the first mask image; extracting clue features corresponding to the user clue regions based on the image to be filled and the second mask image; calculating similarity scores of the background features and the clue features; and inputting the image to be filled, the first mask image and the similarity score into the trained first neural network to obtain a filled image.

Description

Image filling method and device, electronic device and medium
Technical Field
The present disclosure relates to the field of artificial intelligence, and in particular, to the field of computer vision and deep learning technologies, and in particular, to an image filling method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
Background
Artificial intelligence is the subject of research that makes computers simulate some human mental processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), both at the hardware level and at the software level. The artificial intelligence hardware technology generally comprises technologies such as a sensor, a special artificial intelligence chip, cloud computing, distributed storage, big data processing and the like, and the artificial intelligence software technology mainly comprises a computer vision technology, a voice recognition technology, a natural language processing technology, machine learning/deep learning, a big data processing technology, a knowledge graph technology and the like.
The image filling technology has wide application scenes, such as image editing, image repairing, removing a specific object in an image, and the like. The conventional image filling technology is based on data driving, fills the missing area according to data experience distribution in a training set, cannot perform manual intervention, and cannot understand the filling intention of a user.
Disclosure of Invention
The present disclosure provides an image filling method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
According to an aspect of the present disclosure, there is provided an image filling method including: acquiring an image to be filled, and a first mask image and a second mask image corresponding to the image to be filled, wherein the image to be filled comprises a region to be filled and a background region outside the region to be filled, the first mask image is used for indicating the relative position relationship between the region to be filled and the background region, and the second mask image is used for indicating the relative position relationship between a user clue region and a region outside the user clue region; extracting background features corresponding to the background area based on the image to be filled and the first mask image; extracting cue features corresponding to the user cue region based on the image to be filled and the second mask image; calculating similarity scores of the background features and the clue features; and inputting the image to be filled, the first mask image and the similarity score into a trained first neural network to obtain a filled image.
According to another aspect of the present disclosure, there is provided an image filling apparatus including: the image acquisition module is configured to acquire an image to be filled, and a first mask image and a second mask image which correspond to the image to be filled, wherein the image to be filled comprises a region to be filled and a background region outside the region to be filled, the first mask image is used for indicating the relative position relationship between the region to be filled and the background region, and the second mask image is used for indicating the relative position relationship between a user clue region and a region outside the user clue region; a background feature extraction module configured to extract a background feature corresponding to the background region based on the image to be filled and the first mask image; a cue feature extraction module configured to extract cue features corresponding to the user cue region based on the image to be padded and the second mask image; a similarity calculation module configured to calculate a similarity score for the background features and the cue features; and an image filling module configured to input the image to be filled, the first mask image and the similarity score into a trained first neural network to obtain a filled image.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the image filling method of the present disclosure.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the image filling method of the present disclosure.
According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the image filling method of the present disclosure.
According to one or more embodiments of the disclosure, the filling intention of the user can be accurately understood, image filling is performed based on a user clue, and a filling effect meeting the user expectation is achieved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments of the embodiments and, together with the description, serve to explain the exemplary implementations of the embodiments. The illustrated embodiments are for purposes of illustration only and do not limit the scope of the claims. Throughout the drawings, identical reference numbers designate similar, but not necessarily identical, elements.
FIG. 1 illustrates a schematic diagram of an exemplary system in which various methods described herein may be implemented, according to an embodiment of the present disclosure;
FIG. 2 shows a flow diagram of an image filling method according to an embodiment of the present disclosure;
FIG. 3 shows a schematic image containing an object to be removed and user cues according to an embodiment of the disclosure;
FIG. 4 shows a schematic view of the corresponding region of the couch of FIG. 3 after filling, in accordance with an embodiment of the disclosure;
FIG. 5 shows a schematic diagram of image filling according to a method of the present disclosure;
fig. 6 shows a block diagram of the structure of an image filling apparatus according to an embodiment of the present disclosure; and
FIG. 7 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, the timing relationship, or the importance relationship of the elements, and such terms are used only to distinguish one element from another. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, based on the context, they may also refer to different instances.
The terminology used in the description of the various described examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the elements may be one or more. Furthermore, the term "and/or" as used in this disclosure is intended to encompass any and all possible combinations of the listed items.
Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
Fig. 1 illustrates a schematic diagram of an exemplary system 100 in which various methods and apparatus described herein may be implemented in accordance with embodiments of the present disclosure. Referring to fig. 1, the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. Client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
In embodiments of the present disclosure, the server 120 may run one or more services or software applications that enable the image filling method to be performed.
In some embodiments, the server 120 may also provide other services or software applications that may include non-virtual environments and virtual environments. In certain embodiments, these services may be provided as web-based services or cloud services, for example, provided to users of client devices 101, 102, 103, 104, 105, and/or 106 under a software as a service (SaaS) model.
In the configuration shown in fig. 1, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof, which may be executed by one or more processors. A user operating a client device 101, 102, 103, 104, 105, and/or 106 may, in turn, utilize one or more client applications to interact with the server 120 to take advantage of the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from system 100. Accordingly, fig. 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
Client devices 101, 102, 103, 104, 105, and/or 106 may be used to receive images to be populated, and so on. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although fig. 1 depicts only six client devices, those skilled in the art will appreciate that any number of client devices may be supported by the present disclosure.
Client devices 101, 102, 103, 104, 105, and/or 106 may include various types of computer devices, such as portable handheld devices, general purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, and so forth. These computer devices may run various types and versions of software applications and operating systems, such as Microsoft Windows, Apple iOS, UNIX-like operating systems, Linux, or Linux-like operating systems (e.g., Google Chrome OS); or include various Mobile operating systems, such as Microsoft Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular telephones, smart phones, tablets, Personal Digital Assistants (PDAs), and the like. Wearable devices may include head mounted displays and other devices. The gaming system may include a variety of handheld gaming devices, internet-enabled gaming devices, and the like. The client device is capable of executing a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), Short Message Service (SMS) applications, and may use a variety of communication protocols.
Network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP/IP, SNA, IPX, etc. By way of example only, one or more networks 110 may be a Local Area Network (LAN), an ethernet-based network, a token ring, a Wide Area Network (WAN), the internet, a virtual network, a Virtual Private Network (VPN), an intranet, an extranet, a Public Switched Telephone Network (PSTN), an infrared network, a wireless network (e.g., bluetooth, WIFI), and/or any combination of these and/or other networks.
The server 120 may include one or more general purpose computers, special purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-end servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and/or combination. The server 120 may include one or more virtual machines running a virtual operating system, or other computing architecture involving virtualization (e.g., one or more flexible pools of logical storage that may be virtualized to maintain virtual storage for the server). In various embodiments, the server 120 may run one or more services or software applications that provide the functionality described below.
The computing units in server 120 may run one or more operating systems including any of the operating systems described above, as well as any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and/or middle tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, and the like.
In some implementations, the server 120 may include one or more applications to analyze and consolidate data feeds and/or event updates received from users of the client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and/or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
In some embodiments, the server 120 may be a server of a distributed system, or a server incorporating a blockchain. The server 120 may also be a cloud server, or a smart cloud computing server or a smart cloud host with artificial intelligence technology. The cloud Server is a host product in a cloud computing service system, and is used for solving the defects of high management difficulty and weak service expansibility in the traditional physical host and Virtual Private Server (VPS) service.
The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store data such as images to be populated or images after being populated. The data store 130 may reside in various locations. For example, the data store used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The data store 130 may be of different types. In certain embodiments, the data store used by the server 120 may be a database, such as a relational database. One or more of these databases may store, update, and retrieve data to and from the database in response to the command.
In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the application may be different types of databases, such as key-value stores, object stores, or regular stores supported by a file system.
The system 100 of fig. 1 may be configured and operated in various ways to enable application of the various methods and apparatus described in accordance with the present disclosure.
In image processing, situations that a target object in an image needs to be removed are often encountered, such as removing a certain passer-by in a picture, removing a certain object that is not completely taken, and the like. At present, the image filling technology is used for filling a missing area according to data experience distribution after an image is analyzed, manual intervention cannot be carried out, and the filling intention of a user cannot be understood. For example, where a user desires to fill in a missing region with features of object a, conventional methods may give the result of filling in with features of object B.
There is therefore provided, in accordance with an embodiment of the present disclosure, an image filling method 200, as shown in fig. 2, including: acquiring an image to be filled, and a first mask image and a second mask image corresponding to the image to be filled (step 210); extracting background features corresponding to the background region based on the image to be filled and the first mask image (step 220); extracting cue features corresponding to the user cue region based on the image to be filled and the second mask image (step 230); calculating similarity scores of the background features and the clue features (step 240); and inputting the image to be padded, the first mask image and the similarity score into the trained first neural network to obtain a padded image (step 250).
According to the embodiment of the disclosure, the filling intention of the user can be accurately understood, image filling is carried out based on the clues of the user, and the filling effect meeting the expectation of the user is achieved.
In step 210, an image to be filled, and a first mask image and a second mask image corresponding to the image to be filled are obtained. The image to be filled comprises a region to be filled and a background region outside the region to be filled, the first mask image is used for indicating the relative position relation between the region to be filled and the background region, and the second mask image is used for indicating the relative position relation between the user clue region and the region outside the user clue region.
In some embodiments, the target image may be pre-processed: and removing the target area in the target image to obtain an image to be filled, wherein the area missing in the image to be filled is the area to be filled.
Referring to fig. 3, which schematically shows an image containing an object to be removed and a user's clue, for convenience of description, the object desired to be removed is marked in fig. 3 in a painted manner, i.e., a pair of lounges chairs on a seaside beach. In the embodiment of fig. 3, the target original image is a beach picture containing a couch, the couch can be scratched from the original picture by a known image segmentation technique (e.g., edge segmentation, semantic segmentation), and an image to be padded, i.e., a beach image of a missing couch region, is obtained, and the missing region is the region to be padded.
The user clue area may be roughly marked by, for example, a user in a frame or the like in the image to be filled. For example, a user is to circle a user-clue region in the image with a frame (e.g., a dashed frame or a solid frame), where the user-clue region is a region that the user desires to use for image filling, and a region where the dashed frame is located in fig. 3 is the user-clue region. The frame may be any shape, including but not limited to a rectangular frame, an oval frame, etc., as long as the user's intent to fill in the image is identified.
In some embodiments, the target raw image may have a variety of forms including, but not limited to, a still image taken, a video frame image extracted from a video frame, and the like. The video frame can be from a video which is made in advance, and can also be a video corresponding to a real-time video stream, such as a live video, an instant communication video and the like. In some embodiments, the number of the to-be-filled regions in the to-be-filled image obtained by segmenting the original target image may be one or more.
In some embodiments, after acquiring the image to be padded, the first mask image may be further acquired. The first mask image includes a region to be filled and a background region outside the region to be filled. In the mask image, the data of the pixel points in the region to be filled is different from the data of the pixel points in the background region, so that the data of each pixel point in the first mask image can represent whether the pixel point is located in the region to be filled or the background region, that is, the relative position relationship between the region to be filled and the background region in the image to be filled can be represented by the first mask image.
The relative position relation is represented by the first mask image corresponding to the image to be filled, so that the relative position relation between the area to be filled and a background area outside the area to be filled can be accurately obtained, and the image filling can be more accurately realized.
According to some embodiments, the first mask image may be a two-dimensional matrix including a first data region corresponding to the region to be filled and a second data region corresponding to the background region. The first data and the second data are different. The value of each pixel point in the region to be filled can be set as first data, and the value of each pixel point in the background region can be set as second data. For example, the first data may be 1, the second data may be 0 (or vice versa), and the relative position relationship between the region to be filled and the background region in the image to be filled is characterized by the difference of the values of "1" and "0".
In some embodiments, a second mask image may be further acquired. The second mask image includes a region including the user cue region and a region outside the user cue region. In the mask image, the data of the pixel points in the user clue area is different from the data of the pixel points in the area outside the user clue area, so that the data of each pixel point in the second mask image can represent whether the pixel point is located in the user clue area or the area outside the user clue area, that is, the relative position relationship between the user clue area in the image to be filled and the area outside the user clue area can be represented by the second mask image.
The relative position relation is represented by the second mask image corresponding to the image to be filled, so that the relative position relation between the user clue area and the area outside the user clue area can be accurately known, and the filling intention of the user can be more accurately understood.
According to some embodiments, the second mask image may be a two-dimensional matrix including a third data region corresponding to the user cue region and a fourth data region corresponding to a region outside the user cue region. The third data and the fourth data are different. The value of each pixel point in the user clue region may be set as the third data, and the value of each pixel point in the region outside the user clue region may be set as the fourth data. For example, the third data may be 1, the fourth data may be 0 (or vice versa), and the relative position relationship between the user cue region and the region outside the user cue region in the image to be filled is characterized by the difference between the values of "1" and "0".
In some embodiments, the first mask image and the second mask image may be acquired using an image segmentation network. For example, the original image marked by the user may be input into the trained image segmentation network, so that the image segmentation network identifies a region to be removed (i.e., a region to be filled) of the user mark in the original image, and performs binarization processing on the region to be filled and a background region outside the region to be filled to obtain a first mask image, and a value of each pixel point in the binarized first mask image may be used to represent the relative position relationship. The marked region to be filled in the image to be filled is identified through the trained image segmentation network, the region to be filled is further distinguished from other regions (background regions) in the image to be filled, and then the first mask image is generated according to the position relation between the region to be filled and the background regions, so that the value of each pixel point in the first mask image can be ensured to accurately represent the relative position relation. The second mask image is also as described above and will not be described in detail here.
In step 220, background features corresponding to the background area are extracted based on the image to be filled and the first mask image. In step 230, cue features corresponding to the user cue regions are extracted based on the image to be filled and the second mask image.
To enable a computer to "understand" an image, it is necessary to extract useful data or information from the image, resulting in a representation or description of the image, such as values, vectors, symbols, and the like, that is "non-image". This process is a feature extraction and the representations or descriptions of these "non-images" extracted are the features of the images.
According to some embodiments, extracting the background feature corresponding to the background region comprises: the image to be filled and the first mask image are input into a trained second neural network to obtain background features corresponding to the background region.
According to some embodiments, extracting cue features corresponding to the user cue regions comprises: and inputting the image to be filled and the second mask image into a trained third neural network to obtain the clue characteristics corresponding to the clue areas of the user.
In some examples, either one of the second neural network and the third neural network may be a convolutional neural network, such as a U-Net neural network, to fully exploit the algorithmic advantages of the U-Net structure in image restoration through down-sampling and up-sampling. The image features can be automatically extracted through the trained convolutional neural network, and the method is convenient and fast.
It should be understood that other methods of extracting image features are possible and not limited herein.
At step 240, a similarity score is calculated for the background features and the cue features.
In some examples, the similarity of the clue features to the background features is calculated, and a similarity score with a value range between [0,1] is output.
According to some embodiments, step 240 comprises: calculating the similarity of each feature in the background features and each feature in the clue features; and for each of the background features, calculating an average of the similarity of the feature and all of the clue features as a similarity score of the feature in the background features and the clue features.
At step 250, the image to be padded, the first mask image and the similarity score are input into a trained first neural network to obtain a padded image.
In some examples, the region to be filled in the image is filled based on the background feature with a large similarity score according to the similarity score of the clue feature and the background feature. FIG. 4 shows a schematic view of the couch corresponding to FIG. 3 after filling.
According to some embodiments, the first neural network is generated by training a neural network with training data based on a repair loss of a first mask image generated from the training data. The restoration loss can be used to represent the deviation of the restored image from its corresponding original image. Illustratively, the repair loss may be a Mean Absolute Error (MAE). Therefore, the neural network trained based on the repair loss has higher precision so as to realize the refined image filling effect.
In one embodiment according to the present disclosure, as shown in fig. 5, a background feature 504 is extracted based on the acquired image to be filled 502 and the first mask image 501 (process 511); cue features 505 are extracted based on the acquired image to be filled 502 and the second mask image 503 (process 522). Calculating the similarity between the clue feature 505 and the background feature 504, and outputting a similarity score 506 with a value range of [0,1] (process 533). The similarity score 506, the image to be padded 502, and the first mask image 501 are input into the trained neural network to obtain a padded image 507 (process 544).
The image filling method can understand the intention of the user and enable the filling effect to be natural and real.
According to some embodiments, the method 200 may further comprise: optimizing the filled image based on a convolutional neural network. And based on the filled image, the details are further optimized, so that the filling effect is more natural and real.
There is also provided an image filling apparatus 600 according to an embodiment of the present disclosure, as shown in fig. 6, including: the image obtaining module 610 is configured to obtain an image to be filled, and a first mask image and a second mask image corresponding to the image to be filled, where the image to be filled includes a region to be filled and a background region outside the region to be filled, the first mask image is used to indicate a relative position relationship between the region to be filled and the background region, and the second mask image is used to indicate a relative position relationship between a user cue region and a region outside the user cue region; a background feature extraction module 620 configured to extract a background feature corresponding to the background region based on the image to be filled and the first mask image; a cue feature extraction module 630 configured to extract cue features corresponding to the user cue region based on the image to be padded and the second mask image; a similarity calculation module 640 configured to calculate similarity scores of the background features and the cue features; and an image population module 650 configured to input the image to be populated, the first mask image, and the similarity score into a trained first neural network to obtain a populated image.
Here, the operations of the above units 610 to 650 of the image filling apparatus 600 are similar to the operations of the steps 210 to 250 described above, and are not described herein again.
There is also provided, in accordance with an exemplary embodiment of the present disclosure, an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the image fill method described above.
There is also provided, in accordance with an exemplary embodiment of the present disclosure, a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to execute the above-described image filling method.
There is also provided, in accordance with an exemplary embodiment of the present disclosure, a computer program product, comprising a computer program, wherein the computer program, when executed by a processor, implements the image filling method described above.
Referring to fig. 7, a block diagram of a structure of an electronic device 700, which may be a server or a client of the present disclosure, which is an example of a hardware device that may be applied to aspects of the present disclosure, will now be described. Electronic device is intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the device 700 comprises a computing unit 701, which may perform various suitable actions and processes according to a computer program stored in a Read Only Memory (ROM)702 or a computer program loaded from a storage unit 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Various components in the device 700 are connected to the I/O interface 705, including: an input unit 706, an output unit 707, a storage unit 708, and a communication unit 709. The input unit 706 may be any type of device capable of inputting information to the device 700, and the input unit 706 may receive input numeric or character information and generate key signal inputs related to user settings and/or function controls of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and/or a remote controller. Output unit 707 may be any type of device capable of presenting information and may include, but is not limited to, a display, speakers, a video/audio output terminal, a vibrator, and/or a printer. Storage unit 708 may include, but is not limited to, magnetic or optical disks. The communication unit 709 allows the device 700 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsets, such as bluetooth (TM) devices, 1302.11 devices, WiFi devices, WiMax devices, cellular communication devices, and/or the like.
Computing unit 701 may be a variety of general purpose and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The computing unit 701 performs the various methods and processes described above, such as the method 200. For example, in some embodiments, the method 200 may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of a computer program may be loaded onto and/or installed onto device 700 via ROM 702 and/or communications unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method 200 described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the method 200 by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
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.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be performed in parallel, sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the above-described methods, systems and apparatus are merely exemplary embodiments or examples and that the scope of the present invention is not limited by these embodiments or examples, but only by the claims as issued and their equivalents. Various elements in the embodiments or examples may be omitted or may be replaced with equivalents thereof. Further, the steps may be performed in an order different from that described in the present disclosure. Further, various elements in the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced with equivalent elements that appear after the present disclosure.

Claims (19)

1. An image filling method comprising:
acquiring an image to be filled, and a first mask image and a second mask image corresponding to the image to be filled, wherein the image to be filled comprises a region to be filled and a background region outside the region to be filled, the first mask image is used for indicating the relative position relationship between the region to be filled and the background region, and the second mask image is used for indicating the relative position relationship between a user clue region and a region outside the user clue region;
extracting background features corresponding to the background area based on the image to be filled and the first mask image;
extracting cue features corresponding to the user cue region based on the image to be filled and the second mask image;
calculating similarity scores of the background features and the clue features; and
inputting the image to be filled, the first mask image and the similarity score into a trained first neural network to obtain a filled image.
2. The method as claimed in claim 1, wherein the first mask image is a two-dimensional matrix including a first data area corresponding to the area to be filled and a second data area corresponding to the background area, wherein the first data and the second data are different.
3. The method of claim 1, wherein the second mask image is a two-dimensional matrix including a third data region corresponding to the user cue region and a fourth data region corresponding to a region outside the user cue region, wherein the third data and the fourth data are different.
4. The method of claim 1, wherein calculating the similarity score for the background features and the cue features comprises:
calculating a similarity of each of the background features and each of the cue features; and
for each of the background features, calculating an average of the similarity of the feature to all of the cue features as a similarity score for the feature in the background features to the cue features.
5. The method of claim 1, wherein extracting the background features corresponding to the background region comprises:
inputting the image to be filled and the first mask image into a trained second neural network to obtain background features corresponding to the background region.
6. The method of claim 1, wherein extracting cue features corresponding to the user cue region comprises:
inputting the image to be filled and the second mask image into a trained third neural network to obtain cue features corresponding to the user cue regions.
7. The method of claim 1, wherein the first neural network is generated by training a neural network with training data based on a repair loss of a first mask image generated from the training data.
8. The method of claim 1, further comprising: optimizing the filled image based on a convolutional neural network.
9. An image filling apparatus comprising:
the image acquisition module is configured to acquire an image to be filled, and a first mask image and a second mask image which correspond to the image to be filled, wherein the image to be filled comprises a region to be filled and a background region outside the region to be filled, the first mask image is used for indicating the relative position relationship between the region to be filled and the background region, and the second mask image is used for indicating the relative position relationship between a user clue region and a region outside the user clue region;
a background feature extraction module configured to extract a background feature corresponding to the background region based on the image to be filled and the first mask image;
a cue feature extraction module configured to extract cue features corresponding to the user cue region based on the image to be padded and the second mask image;
a similarity calculation module configured to calculate a similarity score for the background features and the cue features; and
an image filling module configured to input the image to be filled, the first mask image, and the similarity score into a trained first neural network to obtain a filled image.
10. The apparatus of claim 9, wherein the first mask image is a two-dimensional matrix including a first data area corresponding to the area to be filled and a second data area corresponding to the background area, wherein the first data and the second data are different.
11. The apparatus of claim 9, wherein the second mask image is a two-dimensional matrix including a third data region corresponding to the user cue region and a fourth data region corresponding to a region outside the user cue region, wherein the third data and the fourth data are different.
12. The apparatus of claim 9, wherein the similarity calculation module is configured to:
calculating a similarity of each of the background features and each of the cue features; and
for each of the background features, calculating an average of the similarity of the feature to all of the cue features as a similarity score for the feature in the background features to the cue features.
13. The apparatus of claim 9, wherein the background feature extraction module is configured to:
inputting the image to be filled and the first mask image into a trained second neural network to obtain background features corresponding to the background region.
14. The apparatus of claim 9, wherein the cue feature extraction module is configured to:
inputting the image to be filled and the second mask image into a trained third neural network to obtain cue features corresponding to the user cue regions.
15. The apparatus of claim 9, wherein the first neural network is generated by training a neural network with training data based on a repair loss of a first mask image generated from the training data.
16. The apparatus of claim 9, further comprising an optimization module configured to:
optimizing the filled image based on a convolutional neural network.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-8.
19. A computer program product comprising a computer program, wherein the computer program realizes the method of any one of claims 1-8 when executed by a processor.
CN202110247367.3A 2021-03-05 2021-03-05 Image filling method and device, electronic device and medium Pending CN112967356A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110247367.3A CN112967356A (en) 2021-03-05 2021-03-05 Image filling method and device, electronic device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110247367.3A CN112967356A (en) 2021-03-05 2021-03-05 Image filling method and device, electronic device and medium

Publications (1)

Publication Number Publication Date
CN112967356A true CN112967356A (en) 2021-06-15

Family

ID=76276723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110247367.3A Pending CN112967356A (en) 2021-03-05 2021-03-05 Image filling method and device, electronic device and medium

Country Status (1)

Country Link
CN (1) CN112967356A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114449345A (en) * 2022-02-08 2022-05-06 腾讯科技(深圳)有限公司 Video processing method, device, equipment and storage medium
CN116385641A (en) * 2023-03-29 2023-07-04 北京百度网讯科技有限公司 Image processing method and device, electronic equipment and storage medium
WO2024045701A1 (en) * 2022-08-31 2024-03-07 荣耀终端有限公司 Data processing method and apparatus, and device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190385292A1 (en) * 2018-04-25 2019-12-19 Seesure Single image completion from retrieved image collections
CN111768468A (en) * 2020-06-30 2020-10-13 北京百度网讯科技有限公司 Image filling method, device, equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190385292A1 (en) * 2018-04-25 2019-12-19 Seesure Single image completion from retrieved image collections
CN111768468A (en) * 2020-06-30 2020-10-13 北京百度网讯科技有限公司 Image filling method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
冉清;冯结青;: "人体前景的自动抠图算法", 计算机辅助设计与图形学学报, no. 02 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114449345A (en) * 2022-02-08 2022-05-06 腾讯科技(深圳)有限公司 Video processing method, device, equipment and storage medium
CN114449345B (en) * 2022-02-08 2023-06-23 腾讯科技(深圳)有限公司 Video processing method, device, equipment and storage medium
WO2024045701A1 (en) * 2022-08-31 2024-03-07 荣耀终端有限公司 Data processing method and apparatus, and device and storage medium
CN116385641A (en) * 2023-03-29 2023-07-04 北京百度网讯科技有限公司 Image processing method and device, electronic equipment and storage medium
CN116385641B (en) * 2023-03-29 2024-03-19 北京百度网讯科技有限公司 Image processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112967355B (en) Image filling method and device, electronic equipment and medium
CN112967356A (en) Image filling method and device, electronic device and medium
CN113313650B (en) Image quality enhancement method, device, equipment and medium
CN114648638A (en) Training method of semantic segmentation model, semantic segmentation method and device
CN112967196A (en) Image restoration method and device, electronic device and medium
CN116228867B (en) Pose determination method, pose determination device, electronic equipment and medium
CN114120412B (en) Image processing method and device
CN114140547B (en) Image generation method and device
CN114119935B (en) Image processing method and device
CN115393514A (en) Training method of three-dimensional reconstruction model, three-dimensional reconstruction method, device and equipment
CN114120448B (en) Image processing method and device
CN113139095B (en) Video retrieval method and device, computer equipment and medium
CN114429548A (en) Image processing method, neural network and training method, device and equipment thereof
CN114494797A (en) Method and apparatus for training image detection model
CN114429678A (en) Model training method and device, electronic device and medium
CN114327718A (en) Interface display method and device, equipment and medium
CN113627534A (en) Method and device for identifying type of dynamic image and electronic equipment
CN115423827B (en) Image processing method, image processing device, electronic equipment and storage medium
CN116740510B (en) Image processing method, model training method and device
CN116881485B (en) Method and device for generating image retrieval index, electronic equipment and medium
CN113793290B (en) Parallax determining method, device, equipment and medium
CN115345981B (en) Image processing method, image processing device, electronic equipment and storage medium
CN115131562B (en) Three-dimensional scene segmentation method, model training method, device and electronic equipment
CN114758114A (en) Model updating method, image processing method, device, electronic device and medium
CN115512131A (en) Image detection method and training method of image detection model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination