Picture segmentation method and apparatus, medium, and electronic device
By combining the clustering and segmentation modules of the image semantic segmentation model with text descriptions and matching clustering features and text features, the problem of limited segmentation granularity and number of categories in the existing technology is solved, and high-accuracy and flexible image semantic segmentation is achieved. , suitable for large-scale data sets.
Patent Information
- Application Number
- PCT/CN2024/081474
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-13
- Filing Date
- 2024-03-13
- Publication Date
- 2024-10-17
AI Technical Summary
Existing image semantic segmentation technology relies on manual annotation of data and is difficult to expand to large-scale flexible applications. Moreover, the segmentation granularity and number of categories are limited, and there are problems with noise and inaccurate boundaries.
The clustering module in the image semantic segmentation model is used to cluster spatially similar areas in the image to be segmented, and the segmentation module is used for segmentation in combination with the text description. The cross-entropy loss function is used to match text features and clustering features to achieve image and text segmentation.
Effectively utilizes spatial consistency clustering information, reduces dependence on manual annotation, improves segmentation accuracy and generalization performance, supports open vocabulary segmentation, is suitable for large-scale data sets, and reduces labor costs.
Smart Images

Figure CN2024081474_17102024_PF_FP_ABST
Abstract
Description
Image segmentation method, device, medium and electronic device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on April 13, 2023, with application number 202310400232.5, and invention name “Image segmentation method, device, medium and electronic device”, the entire contents of which are incorporated into this application by reference. Technical Field
[0002] The present disclosure relates to the field of computer technology, and in particular to a method, device, medium, and electronic device for image segmentation. Background Art
[0003] In related technologies, image semantic segmentation technology mostly uses an "encoder-decoder" structure. After inputting an image, the encoder encodes the input image into an image vector in a specific feature space. The decoder decodes the image vector output by the encoder and classifies it at the pixel level. The classification result of each pixel is the type of image semantic segmentation. As shown in Figure 1, the left image is the original image. The encoder encodes the left image to obtain the image vector. The decoder decodes and classifies the image vector, and the output result is the right image. In the right image, number 1 indicates pixels classified as "background class" and number 2 indicates pixels classified as "aircraft class".
[0004] The segmentation granularity and number of segmentation types of the above-mentioned image semantic segmentation technologies all rely on manually labeled data, making it difficult to expand to large-scale flexible applications.
[0005] Summary of the Invention
[0006] This summary is provided to briefly introduce concepts that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0007] In a first aspect, the present disclosure provides an image segmentation method, comprising: receiving a picture to be segmented and a text description of the picture to be segmented input by a user; clustering regions with spatially similar relationships in the picture to be segmented using a clustering module in a picture semantic segmentation model to obtain cluster regions; and obtaining a segmentation result based on the text description, the picture to be segmented, and the cluster regions using the segmentation module in the picture semantic segmentation model.
[0008] In a second aspect, the present disclosure provides an image segmentation device, comprising: a receiving unit for receiving a picture to be segmented and a text description of the picture to be segmented input by a user; a clustering unit for clustering regions with spatially similar relationships in the picture to be segmented using a clustering module in a picture semantic segmentation model to obtain cluster regions; and a segmentation unit for obtaining a segmentation result based on the text description, the picture to be segmented and the cluster regions using the segmentation module in the picture semantic segmentation model.
[0009] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of any one of the methods described in the first aspect of the present disclosure.
[0010] In a fourth aspect, the present disclosure provides an electronic device comprising: a storage device storing a computer program; and a processing device for executing the computer program in the storage device to implement the steps of any one of the methods described in the first aspect of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale. In the drawings:
[0012] FIG1 is a schematic diagram of image semantic segmentation according to related art.
[0013] FIG2 is a flowchart of a method for image segmentation according to an embodiment of the present disclosure.
[0014] FIG3 shows a flowchart of training a clustering module in an image semantic segmentation model according to an embodiment of the present disclosure.
[0015] FIG4 is a schematic diagram showing a clustering result of a clustering module according to an embodiment of the present disclosure.
[0016] FIG5 shows a flowchart of training a segmentation module in an image semantic segmentation model according to an embodiment of the present disclosure.
[0017] FIG6 shows a schematic diagram of unidirectionally matching cluster regions with phrases according to an embodiment of the present disclosure.
[0018] FIG7 is a schematic diagram of an image segmentation result according to an embodiment of the present disclosure.
[0019] FIG8 is another schematic diagram of an image segmentation result according to an embodiment of the present disclosure.
[0020] FIG9 is a schematic block diagram of an image segmentation apparatus according to an embodiment of the present disclosure.
[0021] FIG10 is a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0022] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0023] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0024] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "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," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0025] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0026] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0027] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0028] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0029] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.
[0030] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0031] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0032] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0033] FIG2 is a flow chart of a method for image segmentation according to an embodiment of the present disclosure. As shown in FIG2 , the method for image segmentation includes the following steps S21 to S23 .
[0034] In step S21 , a picture to be segmented and a text description of the picture to be segmented input by a user are received.
[0035] Taking the image to be segmented as the left image in FIG. 1 as an example, the user can input the image to be segmented and a text description for the image to be segmented, for example, the text description can be “there is an airplane flying”.
[0036] In step S22, the clustering module in the image semantic segmentation model is used to cluster the regions with spatially similar relationships in the image to be segmented to obtain clustered regions.
[0037] Spatially similar regions refer to regions in an image that have spatially similar image content. For example, if the image content at spatial coordinate 1 refers to a cat's head, and the image content at spatial coordinate 2 refers to a cat's tail, then spatial coordinates 1 and 2 are considered spatially similar regions.
[0038] During the clustering process of the clustering module, the clustering module may first encode the image to be segmented to obtain image features, and then cluster the image features based on the spatial similarity of the image features to obtain various clustering regions of the image to be segmented.
[0039] In step S23, based on the text description, the image to be segmented and the clustered area, a segmentation module in the image semantic segmentation model is used to obtain a segmentation result.
[0040] During the segmentation process of the segmentation module, the segmentation module can first encode the image to be segmented, obtain image features indexed by the spatial coordinates of the image to be segmented, and obtain clustering features of each clustering area based on the image features. For example, the image features located in the same clustering area in the encoded image features are averaged or the root mean square value is taken to obtain the clustering features of each clustering area. In addition, the segmentation module also extracts each phrase (for example, noun) from the text description, encodes each phrase separately, and obtains the text features of each phrase; then, the segmentation module can unidirectionally match the text features to each clustering feature, that is, for each text feature, calculate the cross entropy loss between the text feature and the clustering feature, and determine the clustering feature that best matches the text feature based on the cross entropy loss, thereby determining the clustering area that best matches each phrase, and obtaining the final segmentation result.
[0041] The above technical solution has the following beneficial effects:
[0042] (1) By first clustering the spatially similar regions in the image to be segmented into one category and then performing image and text segmentation based on the clustering results, the spatial consistency clustering information in the image to be segmented is effectively utilized. This not only ensures that the semantic segmentation of the image can be performed accurately and solves the problem of too much noise in the segmentation image and the problem of inaccurate boundaries, but also effectively alleviates the reliance of segmentation tasks on manual pixel-level fine annotation, so that the image semantic segmentation model can be expanded to a larger dataset for self-supervised training, reducing labor costs while increasing the generalization performance of the image semantic segmentation model, and making downstream application deployment not limited to the limited scenarios of manual annotation, making large-scale applications more flexible.
[0043] (2) Thanks to the “image-text” segmentation, it is possible to support open vocabulary segmentation and return segmentation results for any natural language input by the user.
[0044] In some embodiments, the clustering module in the image semantic segmentation model is a module that clusters spatially similar regions in the image into one category. FIG3 shows a flowchart of training the clustering module in the image semantic segmentation model according to an embodiment of the present disclosure.
[0045] As shown in FIG3 , first, spatial transformation is performed on the first picture I in the first picture set to obtain a first spatially transformed picture I1 and a second spatially transformed picture I2 .
[0046] The first picture set is a set including multiple first pictures I. In this step, spatial transformation can be performed on each first picture I in the first picture set. For example, spatial transformation is performed on the first first picture I to obtain a first spatially transformed picture corresponding to the first first picture I and a second spatially transformed picture corresponding to the first first picture I. Spatial transformation is performed on the Nth first picture I to obtain a first spatially transformed picture corresponding to the Nth first picture I and a second spatially transformed picture corresponding to the Nth first picture I, and so on.
[0047] The spatial transformation may include, for example, stretching, mirroring, cropping, color transformation, etc. The spatial transformation may be a multi-scale, reversible spatial transformation.
[0048] For example, one of the first images I in the first image set is stretched to obtain a first spatially transformed image I1, and the same first image I is color-transformed to obtain a second spatially transformed image I2. For another example, one of the first images I in the first image set is stretched to obtain a first spatially transformed image I1, and the same first image I is stretched again at the same scale to obtain a second spatially transformed image I2. For another example, one of the first images I in the first image set is stretched at a first scale to obtain a first spatially transformed image I1, and the same first image I is stretched at a second scale to obtain a second spatially transformed image I2. That is, by performing different spatial transformation operations on the same first image I (for example, two spatial transformation operations, one is a stretching operation and the other is a color transformation operation, two spatial transformation operations, one is a mirroring operation and the other is a cropping operation, two spatial transformation operations, one is a stretching operation of the first scale and the other is a stretching operation of the second scale, etc.), or performing the same spatial transformation operation (for example, both spatial transformation operations are stretching operations of the first scale, both spatial transformation operations are the same color transformation, etc.), a first spatially transformed image I1 and a second spatially transformed image I2 can be obtained.
[0049] Then, the first spatially transformed image I1 is encoded to obtain first image features, and the second spatially transformed image I2 is encoded to obtain second image features. In some embodiments, the first spatially transformed image I1 and the second spatially transformed image I2 can be encoded separately using the same image encoder. In some examples, the first spatially transformed image I1 and the second spatially transformed image I2 can be encoded separately to obtain first image features and second image features, both of which are indexed by spatial coordinates in the first image I.
[0050] Then, a spatial consistency loss function (ie, a spatial consistency self-supervised learning loss function) is used to calculate the loss between the first image feature and the second image feature.
[0051] For example, if both the first image feature and the second image feature carry the spatial coordinate index in the first image I, a spatial consistency loss function can be used to calculate the loss between the first image feature and the image features with the same spatial coordinate index in the second image feature. That is, the image features with the same spatial coordinate index in the first image feature and the second image feature are matched, and the cross entropy loss between these corresponding image features is calculated.
[0052] The purpose of calculating the loss between the first image feature and the second image feature is to ensure that the features in the first image feature and the second image feature corresponding to the same position in the first image I are as consistent as possible. For example, assuming that the spatial coordinate index corresponding to feature 1 in the first image feature is index 1, and the spatial coordinate index corresponding to feature 2 in the second image feature is also index 1, this means that feature 1 and feature 2 correspond to the same position in the first image I. By calculating the spatial consistency loss, feature 1 and feature 2 are ensured to be as consistent as possible.
[0053] Then, based on the calculated loss, the clustering module is trained to obtain the clustering module in the image semantic segmentation model.
[0054] In some embodiments, the clustering module may be trained by minimizing the cross entropy loss between the first image feature and the image features with the same spatial coordinate index in the second image feature.
[0055] Through the above-mentioned training method, each first image in the first image set can be used as self-supervised training data, and the training of the clustering module in the image semantic segmentation model can be realized through self-supervised learning. That is, there is no need to manually label the first image, but the image itself is used as self-supervised training data, which effectively utilizes the spatial consistency clustering information brought by the self-supervision of a large number of images to self-supervise and train the spatial consistency clustering features of images in a large number of natural images, effectively alleviating the dependence of segmentation tasks on manual pixel-level fine labeling, so that the image semantic segmentation model can be expanded to a larger-scale data set for self-supervised training, reducing labor costs while increasing the generalization performance of the image semantic segmentation model, and also enabling the trained clustering module to cluster areas with similar spatial relationships in the image into one category.
[0056] Figure 4 shows a schematic diagram of the clustering results of a clustering module according to an embodiment of the present disclosure. The left image is the original image, and the right image is a diagram of the cluster regions obtained using the trained clustering module. Figure 4 shows that the dog is clustered into one cluster region, the ball is clustered into one cluster region, and the background is clustered into one cluster region, demonstrating that the trained clustering module is capable of accurate clustering.
[0057] In some embodiments, the segmentation module in the image semantic segmentation model is a module that segments the image based on the image and the text description of the image. Figure 5 shows a flowchart of training the segmentation module in the image semantic segmentation model according to an embodiment of the present disclosure.
[0058] As shown in FIG5 , first, in step S51 , based on the clustering module in the image semantic segmentation model, the second image in the second image set is processed to obtain the clustered regions of the second image.
[0059] The second picture set is a collection including a plurality of second pictures.
[0060] The second picture set may be a picture set that is completely identical to the first picture set, the second picture set may partially overlap with the first picture set, or the second picture set may not overlap with the first picture set at all.
[0061] In this step, the trained clustering module may be used to process the second images in the second image set to obtain cluster regions of the second images. For example, for each second image in the second image set, the trained clustering module may encode each second image to obtain image features corresponding to each second image, and then process the encoded image features (e.g., clustering the image features based on spatial similarity of the image features) to obtain cluster regions for each second image.
[0062] In step S52, based on the second picture, a third picture feature with a spatial coordinate index in the second picture is obtained, and based on the third picture feature, a cluster feature of each cluster area is obtained.
[0063] The third image feature with the spatial coordinate index in the second image refers to the third image feature with the spatial coordinate in the second image as the index.
[0064] The third picture feature may be obtained in the following manner: that is, for each second picture, the second picture is encoded to obtain the third picture feature indexed by the spatial coordinates in the second picture.
[0065] The clustering features of each clustering area can be obtained in the following manner, that is, first, based on the spatial coordinate index, determine the image features in the third image feature that are located in the same clustering area, and then take the average of the image features located in the same clustering area to obtain the clustering features of each clustering area. For example, assuming that the trained clustering module clusters the second image into three clustering areas, namely cluster area 1, cluster area 2 and cluster area 3, and based on the spatial coordinate index, determine that features 1, 2 and 3 in the third image feature are located in cluster area 2, features 4 and 5 are located in cluster area 3, and features 6 and 7 are located in cluster area 1, then the average of features 1, 2 and 3 can be taken to obtain the clustering features of cluster area 2, the average of features 4 and 5 can be taken to obtain the clustering features of cluster area 3, and the average of features 6 and 7 can be taken to obtain the clustering features of cluster area 1.
[0066] In step S53, the phrases (eg, nouns) in the text description are extracted to obtain text features of each phrase. For example, each phrase may be encoded to obtain its own text features.
[0067] In step S54, the cross entropy loss between the cluster features and the text features is calculated.
[0068] In some embodiments, each text feature can be used as an object to calculate the similarity between the text feature and each cluster feature. For example, the similarity between the text feature and each cluster feature can be calculated by calculating the Euclidean distance, cosine distance, etc. between the text feature and each cluster feature. Then, based on the similarity, the cross entropy loss between the text feature and each cluster feature is calculated. For example, the similarity between each text feature and each cluster feature can be constructed as a similarity matrix, and the cross entropy loss is calculated based on the similarity matrix. In this way, the text feature can be used to match the cluster feature in a unidirectional manner, thereby achieving unidirectional matching of the phrases in the text description to each cluster area. Then, while learning more fine-grained image and text matching, the background and irrelevant areas in the image are filtered out, effectively reducing the background class and noise cluster results in the segmented image results, making the image-text matching results more accurate and reducing a large number of misclassifications. FIG6 shows a schematic diagram of unidirectionally matching cluster regions with phrases (e.g., nouns) according to an embodiment of the present disclosure. In FIG6 , the left side is a similarity matrix constructed by the similarity between text features and cluster features, and the right side is a similarity score schematic diagram. “broccoli” and “plate” represent nouns extracted from text descriptions, n1,…,n N Represents the text features corresponding to each noun, r1,…,r MIndicates the cluster features corresponding to each cluster area. As can be seen from Figure 6, when performing image-text matching, the text features are matched unidirectionally towards the cluster features.
[0069] In step S55, the segmentation module is trained based on the cross entropy loss to obtain the segmentation module in the image semantic segmentation model.
[0070] In some embodiments, the segmentation module can be trained by making the cross entropy loss between the text features and each cluster feature as small as possible.
[0071] The above technical solution has the following beneficial effects: since the clustering module in the image semantic segmentation model processes each second image in the second image set separately to obtain the clustering area of each second image, and uses the text description of each second image, each second image itself and the clustering area of each second image as training data, the segmentation module in the image semantic segmentation model is trained. Therefore, thanks to the "image-text" form of comparison learning, it is possible to support open vocabulary segmentation, and segmentation results can be returned for any natural language input by the user.
[0072] Figure 7 is a schematic diagram of the image segmentation results according to an embodiment of the present disclosure, wherein the leftmost image is the image to be segmented, and the text description input by the user is "a pile of oranges placed on a plate on the table", then the clustering result of the clustering module is the middle image, and the segmentation module extracts the nouns "oranges", "plates" and "desktop" in the text description, and matches these three nouns with the most corresponding clustering areas, and finally obtains the segmentation result of the rightmost image, wherein area a is the desktop, area b is the plate, and area c is the oranges. Figure 7 shows the segmentation results of multiple objects in the image to be segmented. The present disclosure can also segment a single object in the image to be segmented, as shown in Figure 8. The left image is the image to be segmented. When the user's text description is "sofa", the output segmentation result is shown in the right image in Figure 8, which shows that the sofa has been segmented.
[0073] Figure 9 is a schematic block diagram of an image segmentation apparatus according to an embodiment of the present disclosure. As shown in Figure 9, the image segmentation apparatus includes: a receiving unit 91 for receiving a user-input image to be segmented and a text description of the image to be segmented; a clustering unit 92 for clustering spatially similar regions in the image to be segmented using a clustering module in an image semantic segmentation model to obtain clustered regions; and a segmentation unit 93 for obtaining a segmentation result based on the text description, the image to be segmented, and the clustered regions using the segmentation module in the image semantic segmentation model.
[0074] The above technical solution has the following beneficial effects:
[0075] (1) By first clustering the spatially similar regions in the image to be segmented into one category and then performing image and text segmentation based on the clustering results, the spatial consistency clustering information in the image to be segmented is effectively utilized. This not only ensures that the semantic segmentation of the image can be performed accurately and solves the problem of too much noise in the segmentation image and the problem of inaccurate boundaries, but also effectively alleviates the reliance of segmentation tasks on manual pixel-level fine annotation, so that the image semantic segmentation model can be expanded to a larger dataset for self-supervised training, reducing labor costs while increasing the generalization performance of the image semantic segmentation model, and making downstream application deployment not limited to the limited scenarios of manual annotation, making large-scale applications more flexible.
[0076] (2) Thanks to the “image-text” segmentation, it is possible to support open vocabulary segmentation and return segmentation results for any natural language input by the user.
[0077] Optionally, the clustering module in the image semantic segmentation model is a module that clusters spatially similar regions in the image into one category, and the clustering module is trained in the following manner: performing spatial transformation on the first image in the first image set to obtain a first spatially transformed image and a second spatially transformed image; encoding the first spatially transformed image and the second spatially transformed image respectively to obtain a first image feature and a second image feature; using a spatial consistency loss function to calculate the loss between the first image feature and the second image feature; based on the calculated loss, training the clustering module to obtain the clustering module in the image semantic segmentation model.
[0078] Optionally, the encoding the first spatially transformed picture and the second spatially transformed picture respectively to obtain the first picture feature and the second picture feature includes: encoding the first spatially transformed picture and the second spatially transformed picture respectively to obtain the first picture feature and the second picture feature both of which are indexed by spatial coordinates in the first picture;
[0079] The using of a spatial consistency loss function to calculate the loss between the first picture feature and the second picture feature includes: using the spatial consistency loss function to calculate the loss between the first picture feature and the picture features with the same spatial coordinate index in the second picture feature.
[0080] Optionally, the spatial transformation is a multi-scale, reversible spatial transformation.
[0081] Optionally, the segmentation module in the image semantic segmentation model is a module that segments the image based on the image and the text description of the image, and the segmentation module is trained in the following manner: based on the clustering module in the image semantic segmentation model, the second image in the second image set is processed separately to obtain the clustering area of the second image; based on the second image, a third image feature with a spatial coordinate index in the second image is obtained; based on the third image feature, a clustering feature of each clustering area is obtained; phrases in the text description are extracted to obtain text features of each phrase; the cross entropy loss between the clustering features and the text features is calculated; based on the cross entropy loss, the segmentation module is trained to obtain the segmentation module in the image semantic segmentation model.
[0082] Optionally, obtaining the clustering features of each of the clustering areas based on the third image features includes: determining the image features located in the same clustering area in the third image features based on the spatial coordinate index; and taking the average of the image features located in the same clustering area to obtain the clustering features of each of the clustering areas.
[0083] Optionally, the calculating the cross entropy loss between the clustering feature and the text feature includes: taking each of the text features as an object, calculating the similarity between the text feature and each of the clustering features; and calculating the cross entropy loss between the text feature and each of the clustering features based on the similarity.
[0084] The present disclosure also provides a computer-readable medium having a computer program stored thereon, and the steps of any method in the present disclosure are performed when the program is executed by a processing device.
[0085] The present disclosure further provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of any method in the present disclosure.
[0086] Reference is now made to FIG10 , which illustrates a schematic diagram of the structure of an electronic device 600 suitable for implementing embodiments of the present disclosure. Terminal devices in embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device illustrated in FIG10 is merely an example and should not limit the functionality or scope of use of embodiments of the present disclosure.
[0087] As shown in Figure 10, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0088] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although FIG10 illustrates the electronic device 600 with various devices, it should be understood that not all of the devices shown are required to be implemented or present. More or fewer devices may alternatively be implemented or present.
[0089] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0090] It should be noted that the computer-readable medium mentioned above in the present disclosure may 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 electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0091] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0092] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0093] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: receives a picture to be segmented and a text description of the picture to be segmented input by a user; uses a clustering module in a picture semantic segmentation model to cluster regions with spatially similar relationships in the picture to be segmented to obtain cluster regions; and uses a segmentation module in the picture semantic segmentation model to obtain a segmentation result based on the text description, the picture to be segmented, and the cluster regions.
[0094] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving 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 may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0095] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0096] The modules described in the embodiments of the present disclosure may be implemented in software or hardware. The name of a module does not, in some cases, limit the module itself. For example, a clustering unit may be described as "a module for clustering spatially similar regions in the image to be segmented using a clustering module in an image semantic segmentation model to obtain clustered regions."
[0097] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and 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 chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0098] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0099] According to one or more embodiments of the present disclosure, Example 1 provides an image segmentation method, including: receiving a picture to be segmented and a text description of the picture to be segmented input by a user; using a clustering module in an image semantic segmentation model to cluster regions with spatially similar relationships in the picture to be segmented to obtain cluster regions; based on the text description, the picture to be segmented and the cluster regions, using the segmentation module in the image semantic segmentation model to obtain a segmentation result.
[0100] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the clustering module in the image semantic segmentation model is a module that clusters regions in the image that have spatially similar relationships into one category, and the clustering module is trained in the following manner: performing spatial transformation on the first image in the first image set to obtain a first spatially transformed image and a second spatially transformed image; encoding the first spatially transformed image and the second spatially transformed image respectively to obtain a first image feature and a second image feature; using a spatial consistency loss function to calculate the loss between the first image feature and the second image feature; based on the calculated loss, training the clustering module to obtain the clustering module in the image semantic segmentation model.
[0101] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein the encoding the first spatially transformed picture and the second spatially transformed picture respectively to obtain the first picture feature and the second picture feature includes: encoding the first spatially transformed picture and the second spatially transformed picture respectively to obtain the first picture feature and the second picture feature, both of which are indexed by spatial coordinates in the first picture;
[0102] The using of a spatial consistency loss function to calculate the loss between the first picture feature and the second picture feature includes: using the spatial consistency loss function to calculate the loss between the first picture feature and the picture features with the same spatial coordinate index in the second picture feature.
[0103] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 2, wherein the spatial transformation is a multi-scale, reversible spatial transformation.
[0104] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, wherein the segmentation module in the image semantic segmentation model is a module that segments the image based on the image and the text description of the image, and the segmentation module is trained in the following manner: based on the clustering module in the image semantic segmentation model, the second image in the second image set is processed separately to obtain the clustering area of the second image; based on the second image, a third image feature with a spatial coordinate index in the second image is obtained; based on the third image feature, a clustering feature of each of the clustering areas is obtained; phrases in the text description are extracted to obtain text features of each of the phrases; the cross entropy loss between the clustering features and the text features is calculated; based on the cross entropy loss, the segmentation module is trained to obtain the segmentation module in the image semantic segmentation model.
[0105] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 5, wherein the clustering features of each of the clustering areas are obtained based on the third image features, including: determining the image features located in the same clustering area in the third image features based on the spatial coordinate index; and taking the average of the image features located in the same clustering area to obtain the clustering features of each of the clustering areas.
[0106] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 5, wherein the calculating the cross entropy loss between the clustering features and the text features includes: taking each of the text features as an object, calculating the similarity between the text feature and each of the clustering features; and calculating the cross entropy loss between the text feature and each of the clustering features based on the similarity.
[0107] According to one or more embodiments of the present disclosure, Example 8 provides an image segmentation device, including: a receiving unit for receiving a picture to be segmented and a text description of the picture to be segmented input by a user; a clustering unit for clustering regions with spatially similar relationships in the picture to be segmented using a clustering module in a picture semantic segmentation model to obtain cluster regions; a segmentation unit for obtaining a segmentation result based on the text description, the picture to be segmented and the cluster regions using the segmentation module in the picture semantic segmentation model.
[0108] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of the method described in any one of Examples 1-7 when executed by a processing device.
[0109] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-7.
[0110] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0111] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0112] Although the subject matter has been described using language specific to structural features and / or methodological logical acts, it should 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 merely example forms of implementing the claims. Regarding the apparatus in the above-described embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method and will not be elaborated upon here.
Claims
1. A method for image segmentation, comprising: Receiving a picture to be segmented and a text description of the picture to be segmented input by a user; Using a clustering module in a picture semantic segmentation model, clustering regions with spatially similar relationships in the picture to be segmented to obtain cluster regions; Based on the text description, the image to be segmented and the clustered area, a segmentation result is obtained by utilizing a segmentation module in the image semantic segmentation model.
2. The method according to claim 1, wherein the clustering module in the image semantic segmentation model is a module that clusters regions in the image that have spatially similar relationships into one category, and the clustering module is trained in the following manner: Performing spatial transformation on the first picture in the first picture set to obtain a first spatially transformed picture and a second spatially transformed picture; Encoding the first spatial transformation picture and the second spatial transformation picture respectively to obtain a first picture feature and a second picture feature; Using a spatial consistency loss function to calculate the loss between the first picture feature and the second picture feature; Based on the calculated loss, the clustering module is trained to obtain the clustering module in the image semantic segmentation model.
3. The method according to claim 2, wherein the encoding of the first spatial transformation picture and the second spatial transformation picture to obtain the first picture feature and the second picture feature comprises: Encode the first spatial transformation picture and the second spatial transformation picture respectively to obtain the first picture feature and the second picture feature both of which are indexed by the spatial coordinates in the first picture; The using of a spatial consistency loss function to calculate the loss between the first picture feature and the second picture feature includes: using the spatial consistency loss function to calculate the loss between the first picture feature and the picture features of the second picture feature that have the same spatial coordinate index.
4. The method according to claim 2, wherein the spatial transformation is a multi-scale, reversible spatial transformation.
5. The method according to claim 1, wherein the segmentation module in the image semantic segmentation model is a module for segmenting the image based on the image and the text description of the image, and the segmentation module is trained in the following manner: Based on the clustering module in the picture semantic segmentation model, the second pictures in the second picture set are processed respectively to obtain clustering regions of the second pictures; Based on the second picture, obtaining a third picture feature with a spatial coordinate index in the second picture; Based on the third image feature, obtaining a cluster feature of each of the cluster regions; Extracting phrases from the text description to obtain text features of each phrase; Calculating the cross entropy loss between the clustering feature and the text feature; Based on the cross entropy loss, the segmentation module is trained to obtain the segmentation module in the image semantic segmentation model.
6. The method according to claim 5, wherein obtaining the clustering features of each of the clustering regions based on the third image features comprises: Based on the spatial coordinate index, determining picture features in the third picture features that are located in the same clustering area; Take the average of the image features in the same cluster area to obtain the average of each cluster area. The clustering features of .
7. The method according to claim 5, wherein the calculating the cross entropy loss between the clustering feature and the text feature comprises: Taking each of the text features as an object, calculating the similarity between the text feature and each of the cluster features; Based on the similarity, the cross entropy loss between the text feature and each of the cluster features is calculated.
8. A picture segmentation device, comprising: A receiving unit, configured to receive a picture to be segmented and a text description of the picture to be segmented input by a user; A clustering unit, used to cluster regions with spatially similar relationships in the image to be segmented using a clustering module in the image semantic segmentation model to obtain cluster regions; The segmentation unit is used to obtain a segmentation result based on the text description, the image to be segmented and the cluster area by using a segmentation module in the image semantic segmentation model.
9. A computer readable medium having a computer program stored thereon, wherein when the program is executed by a processing device, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, comprising: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for optimizing image semantic segmentation model and electronic equipment
CN112990218A
Unsupervised semantic segmentation model training method and related device
CN115063585A
Image processing method and terminal equipment
CN115294150A
Zero sample semantic segmentation method, system and equipment based on knowledge distillation and medium
CN115761235A
Picture segmentation method and device, medium and electronic equipment
CN116503596A
