A model processing method, device, equipment, medium and product

By processing the image segmentation model and prompt information through bilateral optimization, the problem in the existing technology that the image segmentation model requires manual design of prompt information is solved, and the efficiency and flexibility of the image segmentation processing are improved.

CN118470466BActive Publication Date: 2024-09-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410913546.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-09-27
Estimated Expiration
2044-07-09

AI Technical Summary

Technical Problem

In the existing technology, image segmentation models require manual design of prompt information, which is inefficient and insufficiently flexible, making it difficult to adapt to different image segmentation tasks.

Method used

A model processing method is proposed. By obtaining the sample image set and image segmentation prompt information, using bilateral optimization processing, the image segmentation model and prompt information are optimized to achieve automatic segmentation of any image and avoid manual design of prompt information.

Benefits of technology

It improves the efficiency of image segmentation processing, realizes efficient optimization of image segmentation models, and can be applied to different image segmentation tasks without the need for manual design of prompt information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470466B
    Figure CN118470466B
Patent Text Reader

Abstract

The present application provides a model processing method, device, equipment, medium and product, the method comprising: obtaining a sample image set for training an image segmentation model; wherein the sample image set includes multiple sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images; obtaining image segmentation prompt information, the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model; using the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and the optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information. The present application can perform bilateral optimization on the image segmentation model and the image segmentation prompt information to improve the efficiency of image segmentation processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model processing method, apparatus, device, medium and product, and specifically to a model processing method, a model processing apparatus, a computer device, a computer-readable storage medium and a computer program product. Background Art

[0002] In the field of image processing, image segmentation, image recognition and other processing tasks are often involved. Image segmentation refers to a processing technology that segments one or more specified objects from any image, such as segmenting the location of skin lesions from medical images; or segmenting specified game characters from game images, etc. In image segmentation scenarios, image segmentation models are often used to perform segmentation processing on images, so how to train image segmentation models has become an important technology in image segmentation technology.

[0003] At present, any input image of the image segmentation model requires manual design of corresponding prompt information, which is not flexible enough and inefficient. Summary of the invention

[0004] The embodiments of the present application provide a model processing method, apparatus, device, medium and product, which can bilaterally optimize the image segmentation model and image segmentation prompt information to improve the efficiency of image segmentation processing.

[0005] On the one hand, an embodiment of the present application provides a model processing method, the method comprising:

[0006] Acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images;

[0007] Obtaining image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model;

[0008] The image segmentation model and the image segmentation prompt information are bilaterally optimized using a sample image set to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to segment objects in any image according to the prompts of the optimized image segmentation prompt information.

[0009] In one aspect, an embodiment of the present application provides a model processing device, the device comprising:

[0010] An acquisition unit, used to acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images;

[0011] The acquisition unit is further used to acquire image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model;

[0012] The processing unit is used to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information using a sample image set to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information.

[0013] In a possible implementation, the sample image set is divided into a first sample subset and a second sample subset; the processing unit uses the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0014] Using the first sample subset to perform inner optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; or,

[0015] The first sample subset is used to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, the second sample subset is used to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0016] In a possible implementation, the first sample subset includes M first sample images, any first sample image is represented as a first sample image i, and the first sample image i carries a first sample label, M, i are positive integers, 1≤i≤M; let the image segmentation prompt information before optimization be represented as P0, and the image segmentation prompt information after optimization be represented as P1;

[0017] The processing unit uses the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, which is used to perform the following operations:

[0018] Based on the image segmentation prompt information P0, the image segmentation model is called to perform image segmentation processing on the first sample image i to obtain a predicted label of the first sample image i;

[0019] Calculate the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label;

[0020] According to the calculated loss data of the M first sample images, the model parameters to be optimized in the image segmentation model are iteratively optimized to obtain an optimized image segmentation model.

[0021] In a possible implementation, the processing unit calculates the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label, and performs the following operations:

[0022] Obtaining a target loss function for training an image segmentation model, where the target loss function includes a first loss function and a second loss function;

[0023] Based on the predicted label of the first sample image i and the first sample label, a first loss of the first sample image i is calculated using a first loss function;

[0024] Based on the predicted label of the first sample image i and the first sample label, a second loss of the first sample image i is calculated using a second loss function;

[0025] The first loss and the second loss are weightedly fused to obtain loss data of the first sample image i.

[0026] In a possible implementation, the second sample subset includes N second sample images, any second sample image is represented as a second sample image j, and the second sample image j carries a second sample label, N and j are positive integers, 1≤j≤N;

[0027] The processing unit uses the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information for performing the following operations:

[0028] Call the optimized image segmentation model to perform image segmentation processing on the second sample image j to obtain a predicted label of the second sample image j;

[0029] Calculate the loss data of the second sample image j based on the difference between the predicted label of the second sample image j and the second sample label;

[0030] According to the calculated loss data of the N second sample images, the image segmentation prompt information P0 is iteratively optimized to obtain the optimized image segmentation prompt information P1.

[0031] In a possible implementation, the processing unit uses the first sample subset to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, uses the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0032] Based on the image segmentation prompt information P0, the first sample image i is used to optimize and update the model parameter W0 to be optimized in the image segmentation model to obtain the optimized model parameter W1;

[0033] Based on the optimized model parameter W1, the image segmentation prompt information P0 is optimized and updated using the second sample image j to obtain the optimized image segmentation prompt information P1;

[0034] The optimized image segmentation prompt information P1 is used as the new image segmentation prompt information, and the optimized model parameter W1 is used as the new model parameter, and M first sample images and N second sample images are used for iterative optimization;

[0035] When the iteratively optimized image segmentation model meets the model convergence condition, the optimized image segmentation model and the optimized image segmentation prompt information are obtained.

[0036] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder and a segmentation decoder; wherein the segmentation decoder is composed of: a convolutional low-rank fine-tuning model, a transposed convolutional layer module, and a multi-layer perceptron, the convolutional low-rank fine-tuning model refers to a convolution mechanism of introducing an expert mixture model in a reweighted model, and the convolutional low-rank fine-tuning model injects an inductive bias prior into the image segmentation model based on the convolution mechanism; the processing unit is further used to perform the following operations:

[0037] Obtain a first parameter to be optimized from the convolutional low-rank fine-tuning model;

[0038] Obtain a second parameter to be optimized from the transposed convolutional layer module;

[0039] Obtaining a third parameter to be optimized from the multilayer perceptron;

[0040] The first parameter, the second parameter, and the third parameter to be optimized are determined as model parameters to be optimized in the image segmentation model.

[0041] In a possible implementation, the image segmentation prompt information includes a prompt vector; the acquiring unit acquires the image segmentation prompt information to perform the following operations:

[0042] Obtaining initial prompt data input to the image segmentation model; wherein the type of the initial prompt data includes any one of the following: text, box, point, and mask;

[0043] The second encoder in the image segmentation model is called to perform feature extraction processing on the initial prompt data to obtain a prompt vector of the image segmentation model.

[0044] In a possible implementation, the acquisition unit acquires a sample image set for training an image segmentation model, and performs the following operations:

[0045] Obtain multiple images to be trained for training an image segmentation model;

[0046] Performing image preprocessing on each image to be trained to obtain a preprocessed image; wherein the image preprocessing includes: any one or more of normalization processing, denoising processing, and image flipping processing;

[0047] The preprocessed images are used as sample images for training the image segmentation model, and a sample image set is generated based on each sample image.

[0048] In a possible implementation, the processing unit is further configured to perform the following operations:

[0049] The sample image set is divided into a first sample subset and a second sample subset by using a preset data division method; the preset data division method includes any one of the following: randomly dividing each sample image in the sample image set, dividing each sample image in the sample image set according to a specified number;

[0050] The number of first sample images included in the first sample subset and the number of second sample images included in the second sample subset are the same or different.

[0051] In a possible implementation, the processing unit is further configured to perform the following operations:

[0052] Obtaining business images to be processed in a business field, where the business field includes any one of the following: medical field, game field, live broadcast field, and transportation field;

[0053] According to the optimized image segmentation prompt information, the optimized image segmentation model is called to perform image segmentation processing on the business image to obtain the segmentation result of the business image;

[0054] Based on the segmentation result of the business image, business processing is performed on the business image in the business domain; wherein the business processing includes: any one of medical data analysis, game testing and optimization, and traffic situation analysis.

[0055] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder, and a segmentation decoder; the segmentation result includes a segmentation mask matrix, the segmentation mask matrix includes a mask label of each pixel in the business image, and any of the mask labels is used to reflect the category to which the corresponding pixel belongs;

[0056] The processing unit calls the optimized image segmentation model to perform image segmentation processing on the business image according to the optimized image segmentation prompt information, and obtains the segmentation result of the business image, which is used to perform the following operations:

[0057] Calling the first encoder to perform image feature extraction processing on the business image to obtain an image feature vector of the business image; wherein the image feature extraction processing includes: any one or more of image convolution processing, position encoding processing, and attention mechanism processing;

[0058] The segmentation decoder is called to decode the image feature vector and the optimized image segmentation prompt information to obtain the segmentation mask matrix of the business image.

[0059] On the one hand, an embodiment of the present application provides a computer device, which includes a processor, an input device, an output device and a memory; a computer program is stored in the memory; when the computer program is executed by the processor, the above-mentioned model processing method is executed.

[0060] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned model processing method is executed.

[0061] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned model processing method is executed.

[0062] In an embodiment of the present application, a sample image set for training an image segmentation model is obtained, the sample image set includes multiple sample images, and the image segmentation model is used to perform segmentation processing on objects in the sample images; image segmentation prompt information is obtained, and the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model; the sample image set is used to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information. It can be seen that the present application provides a bilateral optimization method based on image segmentation, which can optimize the image segmentation model and the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can prompt the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, realizing efficient optimization of the image segmentation model, and thus improving the efficiency of the image segmentation processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0064] Figure 1 It is a schematic diagram of the architecture of a model processing system provided in an embodiment of the present application;

[0065] Figure 2 It is a structural schematic diagram of a split-everything model provided in an embodiment of the present application;

[0066] Figure 3 It is a flow chart of a model processing method provided in an embodiment of the present application;

[0067] Figure 4 It is a structural schematic diagram of an image segmentation model provided in an embodiment of the present application;

[0068] Figure 5a It is a structural schematic diagram of a convolutional low-rank fine-tuning model provided in an embodiment of the present application;

[0069] Figure 5b It is a structural schematic diagram of a convolutional low-rank fine-tuning model based on an expert mixture mechanism provided in an embodiment of the present application;

[0070] Figure 6It is a flowchart of another model processing method provided in an embodiment of the present application;

[0071] Figure 7 This is a complete flow chart of an image segmentation process provided by an embodiment of the present application;

[0072] Figure 8 is a schematic diagram of an image segmentation scenario processed by a model provided in an embodiment of the present application;

[0073] Fig. 9 is a structural schematic diagram of a model processing device provided in an embodiment of the present application;

[0074] Fig.10 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0075] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0076] This application provides a model processing solution, which is applicable to image segmentation in any business field such as medical field, game field, live broadcast field, transportation field, etc. This solution mainly involves an efficient fine-tuning mechanism for bilateral optimization of the image segmentation model, that is, during the model training process, the model parameters of the image segmentation model can be optimized and updated, and the image segmentation prompt information can be optimized and learned, so as to achieve automatic image segmentation by optimizing the learned image segmentation prompt information (such as prompt embedding). This solution does not require manual design of prompt information, thereby improving the efficiency of image segmentation processing. The principle of the model processing solution proposed in this application is roughly explained below:

[0077] (1) Obtain a sample image set for training an image segmentation model; wherein the sample image set includes multiple sample images, the sample images contain objects, and the image segmentation model is used to segment the objects in the sample images. The sample images here can be sampled and generated from any business field, such as the medical field, the game field, the transportation field, etc.

[0078] (2) Obtaining image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation process performed by the image segmentation model. The prompt type here can be a text prompt, or a segmentation prompt in the form of a point, a box, etc., which is intended to assist the image segmentation model to better segment the sample image, thereby better segmenting the object in the sample image; optionally, the image segmentation prompt information in this application can specifically be a prompt vector, which can be an Embedding vector obtained by encoding the prompt data through an encoder.

[0079] (3) Using the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information. Optionally, the above sample image set can be divided into a first sample subset and a second sample subset. The bilateral optimization processing here mainly includes the following two methods: ① Using the first sample subset to perform inner optimization processing on the image segmentation model, and in the process of inner optimization processing, using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information; ② Using the first sample subset to perform inner optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information. Subsequently, the optimized image segmentation model is used to segment objects in any image according to the prompt of the optimized image segmentation prompt information.

[0080] From the above, it can be seen that, on the one hand, the present application relates to a model bilateral optimization method, which can not only optimize the image segmentation model, but also optimize the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can provide prompts for the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, and realizing efficient optimization of the image segmentation model, thereby improving the efficiency of image segmentation processing; on the other hand, the present application allows the sample image set to be divided into a first sample subset and a second sample subset that are independent of each other, thereby using two different sample subsets to iteratively optimize the image segmentation prompt information and model parameters respectively, which can alleviate the risk of overfitting to a certain extent and improve the accuracy of the trained image segmentation model.

[0081] The key technical terms involved in this application are introduced below.

[0082] 1. Image segmentation technology.

[0083] Image segmentation technology is a technology used to segment images. Specifically, image segmentation technology can be divided into instance segmentation technology, foreground segmentation technology, and interactive segmentation technology according to the segmentation task. Among them, instance segmentation technology (Instance Segmentation) refers to: a technology that separates each object in the image and gives its category information; instance segmentation technology (Foreground Segmentation) refers to: a technology that treats each object in the image as a foreground category and separates it separately; interactive segmentation technology (Interactive Segmentation) refers to: a technology that segments objects in the image through interaction between the user and the machine. In the image segmentation processing process in this application, any of the above-mentioned image segmentation technologies can be used to perform image segmentation processing.

[0084] 2. Image segmentation model.

[0085] The image segmentation model, as the name implies, refers to a model used to perform segmentation processing on an image. The so-called segmentation processing refers to segmenting or identifying a specified object in an image, so as to determine the position or area of ​​the specified object in the image, or determine the category of the specified object. In this solution, the image segmentation model is suitable for segmenting images in any business field, such as the medical field, the game field, the live broadcast field, the transportation field, etc., and then subsequent business processing can be performed according to the segmentation results. For example, in the medical field, the image segmentation model can be used to identify the location of lesions in medical images to facilitate medical diagnosis by medical staff; in the game field, the image segmentation model can be used to identify game characters in the game screen to facilitate a better gaming experience for game operators; in the transportation field, the image segmentation model can be used to identify specified vehicles on the traffic road to facilitate traffic control, etc.

[0086] For example, the image segmentation model can be a neural network model or a large model with image segmentation function, such as a SAM model (Segment Anything Model). The so-called SAM model refers to a model that allows segmentation of any object in any image. Figure 2 , Figure 2 Schematic diagram of a structure of a segmentation model provided in an embodiment of the present application. Figure 2As shown in the figure, the SAM model mainly includes the following three modules: Image Encoder, Prompt Encoder, and Mask Decoder; among them, Prompt encoder and Mask decoder are lightweight structures with fewer parameters; Image Encoder includes more parameters. Specifically, ① the image encoder is used to extract image features from the input image of the model to obtain Image embedding; ② the prompt encoder is used to extract prompt features from the input prompt data Prompt to obtain Prompt embedding, where the prompt data Prompt type can include: point, box, mask, text; ③ the segmentation decoder is used to decode and recognize the image feature Image embedding and the prompt feature Prompt embedding, so as to obtain the segmentation result of the input image (i.e., multiple valid masks and the confidence score corresponding to each mask), so the segmentation result here can be used to indicate the category of the object in the image.

[0087] 3. Image segmentation prompt information.

[0088] Image segmentation prompt information (Prompt) refers to information used to prompt the segmentation process performed by the image segmentation model. It is used to indicate any information about the content that needs to be segmented in the image. Therefore, the image segmentation prompt information can be understood as a segmentation task about the image. Specifically, the image segmentation prompt information can be generated by processing a prompt data input by the user into the model. The processing here usually refers to encoding the prompt data using the above-mentioned prompt encoder (PromptEncoder). Therefore, the image segmentation prompt information obtained after processing can be understood as a prompt embedding or prompt vector (Prompt Embedding). Among them, the types of image segmentation prompt information Prompt include but are not limited to: point, box, mask, text, etc.

[0089] 4. Bilateral optimization processing.

[0090] Bilateral optimization refers to the optimization of the image segmentation model and image segmentation prompt information during the image segmentation process. That is, bilateral optimization mainly involves inner optimization and outer optimization. The so-called inner optimization refers to an optimization performed on the model parameters inside the image segmentation model, specifically, the optimization performed on the model parameters associated with the segmentation decoder in the image segmentation model; the so-called outer optimization refers to an optimization performed on the image segmentation prompt information (Prompt Embedding) input externally to the image segmentation model. It can be seen that this solution will not only optimize the model parameters of the image segmentation model itself, but also learn and optimize the image segmentation prompt information, so that the optimized image segmentation prompt information can be applied to the segmentation prompt of any image, that is, the trained image segmentation model can segment objects in any image according to the prompt of the optimized image segmentation prompt information.

[0091] 5. Artificial intelligence.

[0092] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Artificial intelligence technology is an interdisciplinary subject that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, large image processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0093] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to the use of cameras and computers to replace human eyes to identify, detect and measure targets, and further perform image processing so that the computer processes the images into images that are more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the field of vision such as swin-transformer (a transformer), ViT (Vision Transformer, a vision-related transformer), V-MOE (a visual architecture), and MAE (Masked autoencoder) can be quickly and widely applied to downstream specific tasks after fine tuning. Computer vision technology generally includes: image processing, image recognition, image semantic understanding, image retrieval, OCR (Optical Character Recognition), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, etc. It also includes common biometric recognition technologies such as face recognition and fingerprint recognition.

[0094] The image processing scheme provided in this application mainly involves computer vision technology in the field of artificial intelligence. Specifically, computer vision technology can be used to train an image segmentation model, that is, after fine-tuning the pre-trained model (such as the SAM image segmentation model) in the visual field through computer vision technology, the fine-tuned SAM model is used to segment any image; wherein, the so-called pre-training model (Pre-training model), also known as the cornerstone model or large model, refers to a deep neural network (DNN) with large parameters, which is trained on a large amount of unlabeled data, and the function approximation ability of the large parameter DNN is used to enable PTM to extract common features from the data, and after fine tuning (fine tune), parameter efficient fine tuning (PEFT), prompt-tuning and other technologies, it is suitable for downstream tasks (such as image segmentation tasks). For example, calling a trained SAM model can segment medical images to identify the location of lesions in medical images; for example, calling a trained SAM model can segment game images to identify game characters from the game screen, so as to guide users to perform related game operations.

[0095] 6. Cloud technology.

[0096] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0097] In the embodiments of the present application, the prompt data is encoded to obtain image segmentation prompt information (such as prompt vectors), and the image is feature extracted to obtain image features; and the image segmentation model and the image segmentation prompt information are bilaterally optimized using a sample image set. These processes all involve a large amount of data calculation and data storage services. The above processes require a large amount of computer operating costs. Therefore, the present application can be based on cloud computing technology to implement data encoding processing, model training and other related operation processes. Among them, the so-called cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.

[0098] 7. Blockchain.

[0099] Blockchain is essentially a decentralized database, a string of data blocks generated using cryptographic methods. Each data block contains relevant information, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block.

[0100] In this application, the model processing process specifically involves: sample image set, image segmentation prompt information, model parameters of the image segmentation model and many other data. Optionally, this application can send the above data to the blockchain for storage. Based on the characteristics of blockchain such as immutability and traceability, the above data can be prevented from being tampered with or leaked, thereby improving the data security and reliability of the model processing process.

[0101] It should be noted that the relevant data involved in the model processing process of this application (for example: sample image sets, image segmentation prompt information, and model parameters of the image segmentation model, etc.). When the above embodiments of this application are applied to specific products or technologies, the permission or consent of the object must be obtained, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the region, comply with the principles of legality, legitimacy and necessity, and do not involve the acquisition of data types prohibited or restricted by laws and regulations. In some optional embodiments, the relevant data involved in the embodiments of this application are obtained after the object has been authorized separately. In addition, when obtaining the separate authorization of the object, the purpose of the relevant data involved is indicated to the object.

[0102] The model processing system provided by this application is introduced in detail below.

[0103] See also Figure 1 , Figure 1 Schematic diagram of the architecture of a model processing system provided in an embodiment of the present application. Figure 1 As shown, the architecture diagram of the model processing system may at least include: a server 104 and a terminal device cluster, wherein the terminal device cluster includes: a plurality of terminal devices such as a terminal device 101, a terminal device 102, and a terminal device 103, and the number of terminal devices in the terminal device cluster is only used for example, and the embodiment of the present application does not limit the number and type of terminal devices. Among them, any terminal device in the terminal device cluster can be directly or indirectly connected to the server 104 through a network; the above network may include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network, and a wide area network, and the wireless network includes: Bluetooth, WIFI, and other networks that realize wireless communication.

[0104] Each terminal device in the terminal device cluster may be a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), a vehicle-mounted device, an aircraft, a wearable device (smart devices such as smart watches, smart bracelets, pedometers, etc.), a virtual reality device (such as VR (Virtual Reality) devices, AR (Augmented Reality) devices), etc. It is understandable that the types of each terminal device in the terminal device cluster may be the same or different, for example: terminal device 101 may be a mobile phone, and terminal device 102 may also be a mobile phone. For another example: terminal device 101 may be a tablet computer, and terminal device 103 may be a vehicle-mounted device. This application does not limit the number and type of terminal devices in the terminal device cluster.

[0105] Server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0106] The following takes any terminal device (such as the terminal device 101) in the model processing system as an example to explain the data interaction process between the terminal device 101 and the server 104:

[0107] ① The user can collect sample images from any business field (such as medical field, game field, live broadcast field, transportation field, etc.) through the terminal device 101 to form a sample image set. Optionally, the collected sample images can be preprocessed (such as normalization, denoising, image flipping, etc.), and the preprocessed sample images can be used to form a sample image set.

[0108] ② The terminal device 101 obtains image segmentation prompt information, which is used to prompt the segmentation processing process performed by the image segmentation model.

[0109] ③ The terminal device 101 sends data such as the sample image set, image segmentation prompt information, and the image segmentation model to be trained (such as the SAM model) to the server 104.

[0110] ④ The server 104 can use the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information. Specifically, the bilateral optimization processing includes the following two methods: 1. Use the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, and use the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; 2. Use the first sample subset to perform inner layer optimization processing on the image segmentation model, and during the inner layer optimization processing, use the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0111] ⑤ The server 104 sends the optimized image segmentation model and the optimized image segmentation prompt information to the terminal device 101. The optimized image segmentation model is used to segment objects in any image according to the prompt of the optimized image segmentation prompt information. For example, the terminal device 101 can receive a business image in a business field (such as the medical field, the game field, and the transportation field), and perform image segmentation processing on the business image through the optimized image segmentation model according to the prompt of the optimized image segmentation prompt information, thereby accurately and efficiently generating the segmentation result of the business image.

[0112] It should be noted that the data interaction process of the above model processing is only for example and does not limit the specific execution process of the terminal device and the server. Optionally, the process of obtaining the sample image set and the image segmentation prompt information can also be executed by the server; or, the bilateral optimization process of the image segmentation model and the image segmentation prompt information can be executed by the terminal device; or, the complete process of the above model processing can be executed separately by any terminal device or server in the image processing system.

[0113] In a possible implementation, the model processing system provided in the embodiment of the present application can be deployed in the node of the blockchain. For example, the server 104 and each terminal device included in the terminal device cluster (such as terminal device 101, terminal device 102, and terminal device 103, etc.) can be regarded as a node device of the blockchain to jointly constitute a blockchain network. Therefore, the model processing flow of the image segmentation model in the present application can be executed on the blockchain, which can ensure the fairness and justice of the model processing flow, and at the same time make the model processing flow traceable, and at the same time ensure the data security during the model processing process, thereby improving the security and reliability of the entire model processing flow.

[0114] Through the model processing system provided in the present application, it is possible to optimize the image segmentation model and the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can provide prompts for the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, achieving efficient optimization of the image segmentation model, and thus improving the efficiency of image segmentation processing.

[0115] It can be understood that the model processing system described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. It is known to those skilled in the art that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.

[0116] The following is a detailed description of the embodiments of the model processing scheme in conjunction with the accompanying drawings.

[0117] See also Figure 3 , Figure 3 is a flow chart of a model processing method provided in an embodiment of the present application. The model processing method can be executed by a computer device, which can be Figure 1 The model shown deals with any terminal device or server in the system. Figure 3 As shown, the model processing method mainly includes but is not limited to the following steps S301-S303:

[0118] S301: Obtain a sample image set for training an image segmentation model.

[0119] The sample image set includes multiple sample images, the sample images contain objects, and the image segmentation model is used to segment the objects in the sample images. It should be noted that the sample images can be labeled images in any business field, such as the business fields of: medical field, game field, live broadcast field, transportation field, etc.; the so-called labeled image means that any sample image carries a sample label, and the sample label is used to indicate the category or segmentation result of the object in the sample image.

[0120] The following is a detailed description of the process of obtaining the sample data set.

[0121] Method 1: The sample data set is generated by collecting images through online or offline collection methods. Specifically, ① the corresponding business images can be collected in real time from at least one business field (such as medical field, game field, live broadcast field, transportation field, etc.), and each collected business image is annotated, so that the annotated business image is used as a sample image to construct a sample image set. This online collection method can collect business images in the business field in real time and maintain the timeliness of the business image. ② The annotated business images can be directly obtained from the preset image library, so that the obtained annotated business images are used as sample images to construct a sample image set. This offline collection method saves time and effort, can reduce workload, and can improve the efficiency of image acquisition.

[0122] Method 2: Each sample image in the sample data set is generated after preprocessing. In a possible implementation method, the process of obtaining the sample image set includes the following steps (1)-(3):

[0123] (1) Obtain multiple training images for training the image segmentation model. The training images here can be collected in real time from one or more business fields (such as medical field, game field, live broadcast field, transportation field, etc.). This real-time image collection method can ensure the timeliness of the images; or, the training images can be obtained from a preset image library, which stores business images in various fields. This method of obtaining images from the database does not require real-time image collection, which can improve the efficiency and convenience of image acquisition.

[0124] (2) Perform image preprocessing on each image to be trained to obtain a preprocessed image; wherein image preprocessing includes: any one or more of normalization processing, denoising processing, and image flipping processing. For example: ① Each image to be trained can be subjected to mean normalization processing or variance normalization processing. Normalization processing can unify the format of the image, thereby providing a robust input image for the model processing process. ② The so-called denoising processing refers to suppressing or eliminating unnecessary noise signals in the training image to improve the quality of the image. Specifically, a filtering algorithm or filter can be used for image denoising, such as: Gaussian Low Pass Filter, mean filter, bilateral filter, etc. ③ The so-called image flipping processing can include: horizontal mirror flipping and vertical mirror flipping and other flipping methods. The present application can perform random horizontal mirror flipping and random vertical mirror flipping on each image to be trained with a probability of 0.5, thereby improving the richness and diversity of the images to be trained, and thus providing more comprehensive sample images.

[0125] (3) The preprocessed images are used as sample images for training the image segmentation model, and a sample image set is generated based on each sample image. Optionally, the preprocessed images (i.e., preprocessed images) can be manually annotated, that is, each preprocessed image is annotated to generate a sample label for each preprocessed image, so that the preprocessed image carrying the sample label is used as a sample image.

[0126] In the above steps (1)-(3), each sample image in the sample image set is a preprocessed image. The sample images obtained after being processed by the above preprocessing method have higher quality, and the sample images in the sample image set are more comprehensive and rich, thereby being able to provide high-quality sample images for model training.

[0127] Further, after the sample image set is acquired, the sample image set may be divided into a first sample subset and a second sample subset. Specifically, the computer device may divide the sample image set into the first sample subset and the second sample subset using a preset data division method; it should be noted that the number of first sample images included in the first sample subset and the number of second sample images included in the second sample subset are the same or different. The preset data division method includes any one of the following:

[0128] ① Randomly divide each sample image in the sample image set; for example, the sample image set includes N+M sample images, then M sample images can be randomly selected from the sample image set to form a first sample subset, and N sample images can be randomly selected from the sample image set to form a second sample subset, N=M, or N>M, or N<M.

[0129] ② Divide each sample image in the sample image set according to a specified number; wherein the so-called specified number can be understood as allocating each sample image in the sample image set according to a preset ratio, for example, dividing each sample image in the sample image set equally, or dividing each sample image in the sample image set according to a ratio of 2:1.

[0130] Based on this, after the sample image set is acquired, the sample image set can be divided into two independent subsets, namely a first sample subset and a second sample subset, to provide a data source for subsequent bilateral optimization processing.

[0131] S302: Obtain image segmentation prompt information, where the image segmentation prompt information is used to prompt a segmentation processing process performed by an image segmentation model.

[0132] Specifically, the image segmentation prompt information is used to prompt the segmentation processing performed by the image segmentation model. The image segmentation prompt information here can be prompt data input by the user to the image segmentation model; or, the image segmentation prompt information can also be data (such as a prompt vector) obtained after the prompt data input by the user is processed by the image segmentation model, that is, the image segmentation prompt information refers to the prompt vector obtained after encoding the prompt data. For ease of explanation, this application takes the example that the image segmentation prompt information refers to the prompt vector processed by the image segmentation model for corresponding explanation.

[0133] In one possible implementation, the process of obtaining image segmentation prompt information (i.e., prompt vector) is as follows: obtain initial prompt data input into the image segmentation model; wherein the type of the initial prompt data includes any one of the following: text, box, point, and mask; call the second encoder (i.e., prompt encoder: PromptEncoder) in the image segmentation model, perform feature extraction processing on the initial prompt data, and obtain the prompt vector of the image segmentation model.

[0134] S303: using the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0135] The optimized image segmentation model is used to segment objects in any image according to the optimized image segmentation prompt information. That is, the optimized image segmentation prompt information can be applied to the segmentation of images in any business field and provide prompts for the segmentation process of any image. There is no need to design different prompt data for different images, thereby improving the efficiency of image segmentation.

[0136] In the present application, when bilateral optimization processing is performed on the image segmentation model and the image segmentation prompt information, it specifically includes: dividing the sample image set into a first sample subset and a second sample subset; thereby bilateral optimization processing is performed on the image segmentation model and the image segmentation prompt information based on the first sample subset and the second sample subset, respectively. In specific implementation, the bilateral optimization processing can also include the following two optimization methods: alternating optimization processing and sequential optimization processing; (1) The alternating optimization processing method refers to: using the first sample subset to perform inner layer optimization processing on the image segmentation model, and in the process of the inner layer optimization processing, using the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain the optimized image segmentation model and the optimized image segmentation prompt information. (2) The sequential optimization processing method refers to: using the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain the optimized image segmentation model, and using the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain the optimized image segmentation prompt information. It should be noted that in practical applications, the above-mentioned alternating optimization processing method (1) is usually used to perform bilateral optimization processing. Compared with the sequential optimization processing method (2), the alternating optimization processing method (1) can train a better image segmentation model and image segmentation prompt information. Based on this, the embodiment of the present application allows the sample image set to be divided into two independent sample subsets, and bilateral optimization processing is performed on the image segmentation model and the image segmentation prompt information based on the two independent sample subsets, which can alleviate the risk of model overfitting to a certain extent.

[0137] It should be understood that the optimization process of the image segmentation model mainly involves optimizing the model parameters in the image segmentation model. Therefore, the model structure of the image segmentation model and the specific process of how to obtain the model parameters to be optimized in the image segmentation model are described below in conjunction with the accompanying drawings:

[0138] See also Figure 4 , Figure 4 Schematic diagram of the structure of an image segmentation model provided in an embodiment of the present application. Figure 4 As shown, the structure of the image segmentation model mainly includes: a first encoder (such as an image encoder, Image Encoder), a second encoder (such as a prompt encoder, Prompt Encoder), and a segmentation decoder (such as a Mask Decoder); wherein the first encoder is used to perform image feature extraction processing on the input image of the image segmentation model to obtain image features (ImageEmbedding); the second encoder is used to perform feature vector extraction processing on the prompt data input to the image segmentation model to obtain a prompt vector (Prompt Embedding); the segmentation decoder is used to decode the above-mentioned image features and prompt vectors, so as to obtain a segmentation result corresponding to the input image.

[0139] Further, Figure 4 The segmentation decoder shown is composed of: Convolutional Low Rank Fine-tuning Model (Conv-LoRA), Transposed Convoltuion Layer Module (Transposed Convoltuion), and Multi-Layer Perceptron (MLP). See Figure 5a , Figure 5a Schematic diagram of the structure of a convolutional low-rank fine-tuning model provided in an embodiment of the present application. Figure 5a As shown, the pre-trained model weights (i.e., Pretrained Weights, which can be expressed as W0) are fine-tuned for Conv-LoRA, and the updated model parameters are: W'=W0+A(MoE-Conv)B, where the low-rank matrix A (Encoder) and the low-rank matrix B (Decoder) are concepts in LoRA (Low-Rank Adaptation, low-rank fine-tuning model). For further information, please refer to Figure 5b , Figure 5b Schematic diagram of the structure of a convolutional low-rank fine-tuning model based on an expert mixture mechanism provided in an embodiment of the present application. Figure 5bAs shown in FIG. 1 , the convolutional low-rank fine-tuning model in this application is a convolutional LoRA model that introduces a mixture of experts (MoE) mechanism into the LoRA model. The convolutional LoRA model injects an inductive bias prior into the image segmentation model based on the convolution mechanism, thereby facilitating the capture of local knowledge of the image during the image segmentation process and improving the accuracy of image segmentation. In summary, Figure 5a and Figure 5b As shown in the figure, the network structure of the Conv-LoRA model is different from the fine-tuning operation based on LoRA. The operation mode of the Conv-LoRA layer introduces the Conv convolution operation, so that the inductive bias prior can be injected; and the structure introduces the MoE mechanism, which increases the flexibility of fine-tuning and the adaptability to multi-scale data.

[0140] based on Figure 4 For the model structure shown, the process of obtaining the model parameters to be optimized in the image segmentation model is as follows: obtaining the first parameter to be optimized from the convolutional low-rank fine-tuning model; obtaining the second parameter to be optimized from the transposed convolutional layer module; obtaining the third parameter to be optimized from the multilayer perceptron; determining the first parameter, the second parameter, and the third parameter to be optimized as the model parameters to be optimized in the image segmentation model.

[0141] In an embodiment of the present application, a sample image set for training an image segmentation model is obtained, the sample image set includes multiple sample images, and the image segmentation model is used to perform segmentation processing on objects in the sample images; image segmentation prompt information is obtained, and the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model; the sample image set is used to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information. It can be seen that the present application provides a bilateral optimization method based on image segmentation, which can optimize the image segmentation model and the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can prompt the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, realizing efficient optimization of the image segmentation model, and thus improving the efficiency of the image segmentation processing.

[0142] See also Figure 6 , Figure 6 is a flow chart of another model processing method provided in an embodiment of the present application. The model processing method can be executed by a computer device, which can be Figure 1The model shown deals with any terminal device or server in the system. Figure 6 As shown, the model processing method mainly includes but is not limited to the following steps S601-S605:

[0143] S601: Obtain a sample image set for training an image segmentation model.

[0144] The sample image set includes multiple sample images, the sample images include objects, and the image segmentation model is used to segment the objects in the sample images. The sample image set can be generated by collecting images online or offline; or the collection process of the sample image set is as follows: obtaining multiple images to be trained for training the image segmentation model; performing image preprocessing on each image to be trained to obtain a preprocessed image; the image preprocessing includes: any one or more of normalization, denoising, and image flipping; using the preprocessed image as a sample image for training the image segmentation model, and generating a sample image set based on each sample image.

[0145] It should be noted that the specific process of how to collect the sample image set can be detailed with reference to the relevant process in step S301 in the above embodiment, and the embodiment of the present application will not be repeated here.

[0146] S602: Divide the sample image set into a first sample subset and a second sample subset.

[0147] In specific implementation, any of the following division methods can be used when performing subset division:

[0148] ① Randomly divide each sample image in the sample image set to obtain a first sample set and a second sample subset. For example, if the sample image set includes N+M sample images, then M sample images can be randomly selected from the sample image set to form a first sample subset, and N sample images can be randomly selected from the sample image set to form a second sample subset, where N=M, or N>M, or N<M.

[0149] ② Divide each sample image in the sample image set according to a specified number to obtain a first sample set and a second sample subset. The so-called specified number can be understood as allocating each sample image in the sample image set according to a preset ratio, such as evenly dividing each sample image in the sample image set, or dividing each sample image in the sample image set according to a 2:1 ratio.

[0150] S603: Obtain image segmentation prompt information, where the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model.

[0151] The image segmentation prompt information here can be understood as a prompt vector (Prompt Embedding) after being encoded by the prompt encoder. It should be understood that the image segmentation prompt information here refers to an initial prompt vector set for the image segmentation model, that is, the image segmentation prompt information here is an untrained initial vector. Specifically, the process of obtaining the initial image segmentation prompt information (i.e., the initial prompt vector) is as follows: obtain the initial prompt data input to the image segmentation model; wherein the type of the initial prompt data includes any of the following: text, box, point, and mask; call the second encoder in the image segmentation model (i.e., prompt encoder: Prompt Encoder), perform feature extraction on the initial prompt data, and obtain the prompt vector of the image segmentation model.

[0152] Furthermore, after obtaining the initial image segmentation prompt information and the sample image set (the first sample subset and the second sample subset), the image segmentation model can be trained. As can be seen from the above, during the model training process, the sample image set can be used to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information. The bilateral optimization processing here mainly includes the following two methods: method 1, sequential optimization processing (S6041); method 2, alternating optimization processing (S6042). The above two bilateral optimization methods are described in detail below.

[0153] S6041: using the first sample subset to perform inner optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information.

[0154] (1) Inner layer optimization process.

[0155] In a possible implementation, the first sample subset includes M first sample images, any first sample image is represented as a first sample image i, and a sample image i carries a first sample label, M, i are positive integers, 1≤i≤M; let the image segmentation prompt information before optimization be represented as P0, and the image segmentation prompt information after optimization be represented as P1. Specifically, the computer device uses the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain the optimized image segmentation model, including the following steps ①-③:

[0156] ① Based on the image segmentation prompt information P0, call the image segmentation model to perform image segmentation processing on the first sample image i to obtain the predicted label of the first sample image i. Specifically, when performing image segmentation on the first sample image i, the present application needs to fix the image segmentation prompt information P0 (that is, any first sample image uses the same image segmentation prompt information P0), and then use the first encoder (that is, the image encoder) in the image segmentation model to perform feature extraction processing on the first sample image i to obtain the image feature Image embedding_i of the first sample image i; finally, based on the segmentation decoder, decode Image embedding_i and the fixed image segmentation prompt information P0 to obtain the predicted label of the first sample image i. Among them, the image encoder here can be: MAE (Masked autoencoder), ViT (Vision Transformer, pre-trained visual transformer), etc.

[0157] ② Based on the difference between the predicted label of the first sample image i and the first sample label, calculate the loss data of the first sample image i. Specifically, the calculation process of the loss data of the first sample image i is as follows: obtain the target loss function for training the image segmentation model, the target loss function includes a first loss function and a second loss function; based on the predicted label of the first sample image i and the first sample label, use the first loss function to calculate the first loss of the first sample image i; based on the predicted label of the first sample image i and the first sample label, use the second loss function to calculate the second loss of the first sample image i; perform weighted fusion on the first loss and the second loss to obtain the loss data of the first sample image i. The weighted fusion here may include any one of averaging, addition, and weighted operations.

[0158] For example, assume that the first loss function is the cross entropy loss function , the second loss function is the dice loss function Among them, the cross entropy loss function The expression is:

[0159] Formula 1-1

[0160] In the above formula 1-1, y refers to the first sample label of the first sample image i. It refers to the predicted label of the first sample image i. According to the above formula 1-1, the first loss of the first sample image i can be calculated.

[0161] In addition, the dice loss function The expression is:

[0162] Formula 1-2

[0163] In the above formula 1-2, |X| refers to the first sample label of the first sample image i, and |Y| refers to the predicted label of the first sample image i; the second loss of the first sample image i is calculated according to the formula 1-2.

[0164] Furthermore, the first loss and the second loss of the first sample image i may be weightedly fused to obtain the loss data of the first sample image i. For example, if the weighted fusion method is an addition operation, the expression of the target loss function is:

[0165] Formula 1-3

[0166] It should be noted that the embodiment of the present application allows the loss data of the same sample image to be calculated according to different types of loss functions, and then the two parts of the loss are weightedly fused to obtain the final total loss. This method can improve the accuracy of calculating the loss data of each sample image.

[0167] ③ According to the calculated loss data of the M first sample images, the model parameters to be optimized in the image segmentation model are iteratively optimized to obtain the optimized image segmentation model. Based on the above steps ①-②, the present application can fix the initial image segmentation prompt information P0, use the image segmentation model to calculate the loss data of the M first sample images, and then back-propagate to the image segmentation model according to the loss data of the M first sample images, calculate the gradient and update the model parameters of the image segmentation model.

[0168] In a possible implementation, the structure of the image segmentation model mainly includes: a first encoder (such as an image encoder), a second encoder (such as a prompt encoder), and a segmentation decoder; wherein the segmentation decoder here is composed of: a convolutional low-rank fine-tuning model (Conv-LoRA), a transposed convolutional layer module (Transposed Convoltuion), and a multi-layer perceptron (MLP); wherein the convolutional low-rank fine-tuning model refers to a convolution mechanism that introduces an expert mixture model in a reweighted model, and the convolutional low-rank fine-tuning model injects an inductive bias prior into the image segmentation model based on the convolution mechanism. Therefore, the process of obtaining the model parameters to be optimized in the image segmentation model is as follows: obtaining the first parameter to be optimized from the convolutional low-rank fine-tuning model (Conv-LoRA); obtaining the second parameter to be optimized from the transposed convolutional layer module (Transposed Convoltuion); obtaining the third parameter to be optimized from the multi-layer perceptron (MLP); and determining the first parameter to be optimized, the second parameter, and the third parameter as the model parameters to be optimized in the image segmentation model.

[0169] In summary, the above inner optimization process means: based on the first sample subset D1, fix the initial image segmentation hint information P0, optimize the learnable model parameters W in the Mask Decoder of the image segmentation model. The learnable model parameters W here are mainly composed of: convolutional low-rank fine-tuning model Conv-LoRA, transposed convolution layer module TransposedConvoltuion, and multi-layer perceptron MLP. Therefore, the expression of the model parameters to be optimized is as follows:

[0170] Formula 2

[0171] In the above formula 2, Refers to the fixed parameter set in the SAM model. The fixed parameter set is composed of Figure 4 The parameters of the Image Encoder, Prompt Encoder, Transformer Blocks, and Token-t0-ImageAttention shown in the figure; It indicates that the optimal model parameters depend on the selection of the image segmentation hint information P, that is, W is related to P; D1 represents the first sample subset.

[0172] In the inner layer optimization processing of the image segmentation model, it is necessary to fix the initial prompt vector P0 and use the M first sample images in the first sample subset to iteratively optimize the trainable model parameters, so as to stop optimizing the image segmentation model when the optimized image segmentation model meets the model convergence condition.

[0173] (2) Outer layer optimization process.

[0174] In a possible implementation, the second sample subset includes N second sample images, any second sample image is represented as a second sample image j, and the second sample image j carries a second sample label, N and j are positive integers, 1≤j≤N. Specifically, the second sample subset is used to perform outer layer optimization processing on the image segmentation prompt information to obtain the optimized image segmentation prompt information, including the following steps ①-③:

[0175] ① Call the optimized image segmentation model to perform image segmentation on the second sample image j to obtain the predicted label of the second sample image j. Specifically, the second sample image j can be encoded by the image encoder in the image segmentation model to obtain the image feature Image embedding_j of the second sample image j, and then the prompt data of the second sample image j can be obtained. The prompt data of the second sample image j is encoded by the prompt encoder to obtain the prompt vector Promt embedding_j of the second sample image j; finally, Image embedding_j and Promtembedding_j are decoded based on the segmentation decoder to obtain the predicted label of the second sample image j.

[0176] ② Based on the difference between the predicted label of the second sample image j and the second sample label, calculate the loss data of the second sample image j. As can be seen from the above inner layer optimization process, the embodiment of the present application can adopt the cross entropy loss function And dice loss function To comprehensively calculate the loss data of the second sample image j, it should be noted here that the calculation process of different types of loss functions can refer to the detailed steps recorded in the above-mentioned inner layer optimization process, and the embodiments of the present application will not be repeated here.

[0177] ③ According to the calculated loss data of the N second sample images, the image segmentation prompt information P0 is iteratively optimized to obtain the optimized image segmentation prompt information P1. Based on the above steps ①-②, the present application can fix the model parameters of the segmentation decoder, so as to use the image segmentation model to calculate the loss data of the N second sample images, and then back-propagate to the image segmentation model according to the loss data of the N first sample images, calculate the gradient and update the image segmentation prompt information.

[0178] In summary, the above outer optimization process specifically refers to: based on the second sample subset D2, fixing the learnable model parameters in the segmentation decoder (Mask Decoder), optimizing the image segmentation prompt information P, the corresponding expression is as follows:

[0179] Formula 3

[0180] In the above formula 3, refers to the fixed parameter set in the SAM model; P represents the image segmentation hint information; D2 refers to the second sample subset; Therefore, Formula 3 shows that the optimal hint input With learnable model parameters There is a correlation between them.

[0181] In the outer layer optimization processing of the image segmentation model, it is necessary to fix the learnable model parameters in the segmentation decoder in the image segmentation model, and use N second sample images in the second sample subset to iteratively optimize the trainable image segmentation prompt information (such as the initial prompt vector P0), so as to obtain the optimized image segmentation prompt information (such as the optimized prompt vector P1).

[0182] Furthermore, based on the bilateral optimization process (i.e., the inner optimization process and the outer optimization process) of (1)-(2) above, the present application can use two independent training subsets to iteratively optimize the image segmentation model and the image segmentation prompt information. Therefore, the final bilateral optimization fine-tuning scheme is expressed as follows:

[0183] Formula 4-1

[0184] Formula 4-2

[0185] In the above formula 4-1 and formula 4-2, L represents the target loss function in the iterative optimization process, for example, it may include the above cross entropy loss function and dice loss function. Of course, the type and number of loss functions are not specifically limited here; D1 refers to the first training subset, and D2 refers to the second training subset. Optionally, until the iteratively optimized image segmentation model meets the model convergence condition, the optimized image segmentation model and the optimized image segmentation prompt information are obtained. It should be noted that the model convergence condition here may include any of the following situations: when the total number of training epochs of the image segmentation model reaches a preset number threshold (such as 100 times), the image segmentation model meets the model convergence condition; when the error between the predicted label of any sample image and the sample label is less than the error threshold, the image segmentation model meets the model convergence condition; when the change between the predicted labels obtained by two adjacent trainings of the image segmentation model is less than the change threshold, the image segmentation model meets the model convergence condition.

[0186] To summarize, the embodiment of the present application can reduce the overfitting phenomenon in the model training process to a certain extent by performing double-layer iterative optimization of image segmentation prompt information and model parameters of the image segmentation model on two independent training sample subsets, thereby improving the accuracy and efficiency of model training.

[0187] S6042: Use the first sample subset to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, use the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0188] Specifically, the image segmentation prompt information before optimization can be set to P0, and the model parameter before optimization can be set to W0. Then, the sequential optimization process shown in step S6042 mainly includes the following steps ①-③:

[0189] ① Based on the image segmentation prompt information P0, the first sample image i is used to optimize and update the model parameter W0 to be optimized in the image segmentation model to obtain the optimized model parameter W1. It should be noted that the optimization logic here can be referred to the inner layer optimization process shown in the above step S6041 (that is, the inner layer optimization of the image segmentation model is performed according to the above formula 2), which will not be repeated here.

[0190] ② Based on the optimized model parameter W1, the second sample image j is used to optimize and update the image segmentation prompt information P0 to obtain the optimized image segmentation prompt information P1. It should be noted that the optimization logic here can be referred to the outer layer optimization process shown in the above step S6041 (that is, the outer layer optimization of the image segmentation prompt information is performed according to the above formula 3), which will not be repeated here.

[0191] ③ Use the optimized image segmentation prompt information P1 as the new image segmentation prompt information, and use the optimized model parameter W1 as the new model parameter, and use M first sample images and N second sample images for iterative optimization; for example, based on the image segmentation prompt information P1, use the first sample image i+1 to optimize and update the model parameter W1 to obtain the optimized model parameter W2; and based on the model parameter W2, use the second sample image j+1 to optimize and update the model parameter W1 to obtain the optimized model parameter W2, and so on, until the iteratively optimized image segmentation model meets the model convergence conditions, and the optimized image segmentation model and the optimized image segmentation prompt information are obtained.

[0192] Optionally, the present application solution can be updated and optimized based on the Adam algorithm (Adaptive moment estimation) Figure 4 The trainable parameters shown in (including the learnable model parameters W in the segmentation decoder and the prompt vector P input to the image segmentation model). In each iterative optimization process, the prediction result error can be calculated and back-propagated to the image segmentation model, the gradient can be calculated and the model parameters of the image segmentation model can be updated. It should be noted that the model training process is mainly end-to-end, and the learning rate during the training process can be set to 1 , the total number of training epochs (rounds) is 100.

[0193] In the above-mentioned sequential optimization process, the image segmentation prompt information can be fixed, and the model parameters can be optimized using the first sample image i to obtain the optimized model parameters, and based on the optimized model parameters, the image segmentation prompt information can be optimized using the second sample image j to obtain the optimized image segmentation prompt information; further, the optimized image segmentation prompt information can be fixed, and the above-mentioned optimized model parameters can be optimized again using the first sample image i+1 to obtain the re-optimized model parameters, and based on the re-optimized model parameters, the above-mentioned optimized image segmentation prompt information can be optimized again using the second sample image j+1 to obtain the re-optimized image segmentation prompt information. And so on, until the sample images in the first sample image set and the second sample image set all participate in the above-mentioned optimization process. It can be seen that the sequential optimization process involved in step S6042 refers to sequentially optimizing the image segmentation model and the image segmentation prompt information using different sample subsets.

[0194] S605: Segment the business image in the business domain according to the optimized image segmentation prompt information.

[0195] In a possible implementation, a business image to be processed in a business field can be obtained, and the business field here includes: any one of the medical field, the game field, the live broadcast field, and the transportation field; according to the optimized image segmentation prompt information, the optimized image segmentation model is called to perform image segmentation processing on the business image to obtain the segmentation result of the business image; based on the segmentation result of the business image, business processing is performed on the business image in the business field; wherein the business processing here includes any one of the following: ① Medical data analysis in the medical field: according to the segmentation results in the medical image, medical staff can be helped to diagnose the location of lesions in the medical image; ② Game testing and optimization in the game field: the game characters in the specified area can be automatically segmented or identified in the game screen, which is beneficial to the optimization of the game; ③ Traffic situation analysis in the transportation field: in the field of smart transportation, the image segmentation model can be used to automatically identify the target vehicle in the traffic road, so as to facilitate the automatic and timely positioning of the specific position of the target vehicle.

[0196] In a possible implementation, the image segmentation model includes: a first encoder (image encoder), a second encoder (prompt encoder), and a segmentation decoder. Specifically, the computer device calls the optimized image segmentation model to perform image segmentation processing on the business image according to the optimized image segmentation prompt information to obtain the segmentation result of the business image, including the following steps (1)-(2):

[0197] (1) Calling the first encoder (i.e., image encoder) to perform image feature extraction processing on the business image to obtain an image feature vector of the business image; wherein the image feature extraction processing includes: any one or more of image convolution processing, position encoding processing, and attention mechanism processing. For example, the business image can be subjected to image convolution processing through a fully convolutional network, where the fully convolutional network refers to a convolutional network commonly used in image segmentation technology, which is composed of a convolution layer and a pooling layer; for another example, a position-sensitive feature map constructed by a set of dedicated convolutional layers can be used, and each score map encodes the position information of the relative spatial position (e.g., "to the left of the object") to obtain the position encoding feature (Position-sensitivefeature maps) of the business image; for another example, any one of the self-attention mechanism, the mutual attention mechanism, and the cross-attention mechanism can be used to perform attention processing on the image feature map, thereby improving the accuracy of the image feature extraction process.

[0198] (2) Call the segmentation decoder to decode the image feature vector and the optimized image segmentation hint information to obtain the segmentation mask matrix of the business image. The segmentation mask matrix includes the mask label (such as mask probability) of each pixel in the business image. Any mask label is used to reflect the category to which the corresponding pixel belongs, that is, the mask label represents the probability that each pixel in the image belongs to the foreground or background.

[0199] In summary, the bilateral optimization process shown in the above steps S6041-S6042, this application provides a large model efficient fine-tuning method based on bilateral optimization for image segmentation, as shown in the following Table 1:

[0200] Table 1. Efficient fine-tuning of large models based on bilateral optimization for image segmentation

[0201]

[0202] Based on the fine-tuning algorithm based on bilateral optimization shown in Table 1, further see Figure 7 , Figure 7 This is a complete flow chart of an image segmentation process provided by an embodiment of the present application. Figure 7 As shown, the complete process based on bilateral optimization for image segmentation in this application includes the following S1-S11:

[0203] S1. Start.

[0204] S2: Determine whether it is training or testing. If it is training, execute S3; if it is testing, execute S8.

[0205] S3. Preprocess the image.

[0206] S4. Load the preprocessed image and iteratively train the image segmentation model according to the bilateral optimization fine-tuning algorithm (as shown in Table 1 above).

[0207] S5. Update the model parameters to be optimized according to the target loss function and the optimization algorithm.

[0208] S6: Whether the set number of iterations (such as 100) is reached. If yes, execute S7; if not, execute S4.

[0209] S7. Maintain the optimized image segmentation model.

[0210] S8. Preprocessing of the image to be segmented.

[0211] S9. Load the trained image segmentation model.

[0212] S10. Obtain the segmentation mask matrix through forward calculation of the bilateral fine-tuning model.

[0213] S11. Output segmentation mask matrix.

[0214] The following uses the image segmentation scenario in the gaming field as an example to illustrate the image segmentation process.

[0215] See also Figure 8 , Figure 8 Schematic diagram of an image segmentation scenario processed by a model provided in an embodiment of the present application. Figure 8As shown, taking the business field of the game field as an example, the image segmentation scenario in the game field mainly involves: game terminals and game servers. Among them, a game is running in the game terminal, and the game screen is presented to the user during the game; the image segmentation model obtained by bilateral optimization of this solution is deployed in the game server (such as the optimized SAM model, the specific optimization process can refer to the detailed process in the above embodiment), in the process of automated game testing, this application can send the game image to the game server in real time, and the game server automatically identifies the target game character in the game screen, so as to automatically control the target game character to perform game operations during the game, thereby realizing the automated testing and operation of the game. Specifically, in the automated testing process of the above-mentioned game, it is necessary to automatically segment the target game character in the game screen, so the segmentation processing of the game image can be completed based on the solution of this application, and the specific process is as follows: ① The game terminal can obtain the game image in any game screen (such as S800) in real time, and send the game image to the game server. ② The game server can call the image encoder (such as ViT encoder) in the SAM model to perform image encoding extraction processing on the game image to obtain the image feature vector of the current game image; and call the segmentation decoder to decode the image feature vector and the optimized image segmentation prompt information to obtain the segmentation result of the game image (such as the segmentation mask matrix). ③ The game server returns the segmentation result (such as the segmentation mask matrix) to the game terminal, wherein the segmentation mask matrix includes the mask label (such as the mask probability) of each pixel in the game image, and the mask probability indicates the probability that each pixel in the image belongs to the foreground or background. ④ Based on the segmentation mask matrix, the game terminal can display the target game character 801 to be segmented in the game screen S800, and then can automatically control the target game character 801 to perform game operations during the game.

[0216] In the embodiment of the present application, an efficient fine-tuning scheme for bilateral optimization of the image segmentation model is proposed, which can realize the automatic segmentation processing of any image by optimizing the learnable prompt vector. On the one hand, the prompt vector and model parameters can be bilaterally iteratively optimized through two independent sample subsets, which can reduce the risk of overfitting and realize efficient optimization of the image segmentation model, thereby improving the efficiency of image segmentation processing; on the other hand, when fine-tuning the model, convolution operation is introduced on the basis of the LoRA model to inject the inductive bias prior, so as to better characterize the intrinsic local characteristics of the image and provide the accuracy of image segmentation; on the other hand, the optimized image segmentation model can realize automatic segmentation of natural images such as medical images and game images, without the need for manual prompt design, which is efficient and convenient.

[0217] The following is an explanation of the related devices of the model processing solution provided in the embodiments of the present application.

[0218] It should be noted that in the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0219] See also Fig. 9 , Fig. 9 Schematic diagram of a model processing device provided in an embodiment of the present application. Fig. 9 As shown, the model processing device 900 can be applied to the computer device (terminal device or server) mentioned in the above embodiments. Specifically, the model processing device 900 can be a computer program (including program code) running in a blockchain node. For example, the model processing device 900 is an application software; the model processing device 900 can be used to execute the corresponding steps in the model processing method provided in the embodiment of the present application. In specific implementation, the model processing device 900 can specifically include:

[0220] The acquisition unit 901 is used to acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images;

[0221] The acquisition unit 901 is further used to acquire image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model;

[0222] The processing unit 902 is used to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information using a sample image set to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information.

[0223] In a possible implementation, the sample image set is divided into a first sample subset and a second sample subset; the processing unit 902 uses the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0224] Using the first sample subset to perform inner optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; or,

[0225] The first sample subset is used to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, the second sample subset is used to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0226] In a possible implementation, the first sample subset includes M first sample images, any first sample image is represented as a first sample image i, and the first sample image i carries a first sample label, M, i are positive integers, 1≤i≤M; let the image segmentation prompt information before optimization be represented as P0, and the image segmentation prompt information after optimization be represented as P1;

[0227] The processing unit 902 uses the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, which is used to perform the following operations:

[0228] Based on the image segmentation prompt information P0, the image segmentation model is called to perform image segmentation processing on the first sample image i to obtain a predicted label of the first sample image i;

[0229] Calculate the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label;

[0230] According to the calculated loss data of the M first sample images, the model parameters to be optimized in the image segmentation model are iteratively optimized to obtain an optimized image segmentation model.

[0231] In a possible implementation, the processing unit 902 calculates the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label, and performs the following operations:

[0232] Obtaining a target loss function for training an image segmentation model, where the target loss function includes a first loss function and a second loss function;

[0233] Based on the predicted label of the first sample image i and the first sample label, a first loss of the first sample image i is calculated using a first loss function;

[0234] Based on the predicted label of the first sample image i and the first sample label, a second loss of the first sample image i is calculated using a second loss function;

[0235] The first loss and the second loss are weightedly fused to obtain loss data of the first sample image i.

[0236] In a possible implementation, the second sample subset includes N second sample images, any second sample image is represented as a second sample image j, and the second sample image j carries a second sample label, N and j are positive integers, 1≤j≤N;

[0237] The processing unit 902 uses the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information for performing the following operations:

[0238] Call the optimized image segmentation model to perform image segmentation processing on the second sample image j to obtain a predicted label of the second sample image j;

[0239] Calculate the loss data of the second sample image j based on the difference between the predicted label of the second sample image j and the second sample label;

[0240] According to the calculated loss data of the N second sample images, the image segmentation prompt information P0 is iteratively optimized to obtain the optimized image segmentation prompt information P1.

[0241] In a possible implementation, the processing unit 902 uses the first sample subset to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, uses the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0242] Based on the image segmentation prompt information P0, the first sample image i is used to optimize and update the model parameter W0 to be optimized in the image segmentation model to obtain the optimized model parameter W1;

[0243] Based on the optimized model parameter W1, the image segmentation prompt information P0 is optimized and updated using the second sample image j to obtain the optimized image segmentation prompt information P1;

[0244] The optimized image segmentation prompt information P1 is used as the new image segmentation prompt information, and the optimized model parameter W1 is used as the new model parameter, and M first sample images and N second sample images are used for iterative optimization;

[0245] When the iteratively optimized image segmentation model meets the model convergence condition, the optimized image segmentation model and the optimized image segmentation prompt information are obtained.

[0246] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder, and a segmentation decoder; wherein the segmentation decoder is composed of: a convolutional low-rank fine-tuning model, a transposed convolutional layer module, and a multi-layer perceptron, the convolutional low-rank fine-tuning model refers to a convolution mechanism of introducing an expert mixture model in a reweighted model, and the convolutional low-rank fine-tuning model injects an inductive bias prior into the image segmentation model based on the convolution mechanism; the processing unit 902 is further used to perform the following operations:

[0247] Obtain a first parameter to be optimized from the convolutional low-rank fine-tuning model;

[0248] Obtain a second parameter to be optimized from the transposed convolutional layer module;

[0249] Obtaining a third parameter to be optimized from the multilayer perceptron;

[0250] The first parameter, the second parameter, and the third parameter to be optimized are determined as model parameters to be optimized in the image segmentation model.

[0251] In a possible implementation, the image segmentation prompt information includes a prompt vector; the acquisition unit 901 acquires the image segmentation prompt information to perform the following operations:

[0252] Obtaining initial prompt data input to the image segmentation model; wherein the type of the initial prompt data includes any one of the following: text, box, point, and mask;

[0253] The second encoder in the image segmentation model is called to perform feature extraction processing on the initial prompt data to obtain a prompt vector of the image segmentation model.

[0254] In a possible implementation, the acquisition unit 901 acquires a sample image set for training an image segmentation model, and performs the following operations:

[0255] Obtain multiple images to be trained for training an image segmentation model;

[0256] Performing image preprocessing on each image to be trained to obtain a preprocessed image; wherein the image preprocessing includes: any one or more of normalization processing, denoising processing, and image flipping processing;

[0257] The preprocessed images are used as sample images for training the image segmentation model, and a sample image set is generated based on each sample image.

[0258] In a possible implementation, the processing unit 902 is further configured to perform the following operations:

[0259] The sample image set is divided into a first sample subset and a second sample subset by using a preset data division method; the preset data division method includes any one of the following: randomly dividing each sample image in the sample image set, dividing each sample image in the sample image set according to a specified number;

[0260] The number of first sample images included in the first sample subset and the number of second sample images included in the second sample subset are the same or different.

[0261] In a possible implementation, the processing unit 902 is further configured to perform the following operations:

[0262] Obtaining business images to be processed in a business field, where the business field includes any one of the following: medical field, game field, live broadcast field, and transportation field;

[0263] According to the optimized image segmentation prompt information, the optimized image segmentation model is called to perform image segmentation processing on the business image to obtain the segmentation result of the business image;

[0264] Based on the segmentation result of the business image, business processing is performed on the business image in the business domain; wherein the business processing includes: any one of medical data analysis, game testing and optimization, and traffic situation analysis.

[0265] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder, and a segmentation decoder; the segmentation result includes a segmentation mask matrix, the segmentation mask matrix includes a mask label of each pixel in the business image, and any of the mask labels is used to reflect the category to which the corresponding pixel belongs;

[0266] The processing unit 902 calls the optimized image segmentation model to perform image segmentation processing on the business image according to the optimized image segmentation prompt information, and obtains the segmentation result of the business image, which is used to perform the following operations:

[0267] Calling the first encoder to perform image feature extraction processing on the business image to obtain an image feature vector of the business image; wherein the image feature extraction processing includes: any one or more of image convolution processing, position encoding processing, and attention mechanism processing;

[0268] The segmentation decoder is called to decode the image feature vector and the optimized image segmentation prompt information to obtain the segmentation mask matrix of the business image.

[0269] In an embodiment of the present application, a bilateral optimization method based on image segmentation is provided, which can not only optimize the image segmentation model, but also optimize the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can provide prompts for the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, achieving efficient optimization of the image segmentation model, and thus improving the efficiency of image segmentation processing.

[0270] See also Fig.10 , Fig.10 It is a structural diagram of a computer device provided in an embodiment of the present application. The computer device 1000 is used to execute the steps performed by the computer device in the aforementioned method embodiment. The computer device 1000 may include an independent device (for example, one or more of a server, a node, a terminal, etc.), or may include components inside an independent device (for example, a chip, a software module or a hardware module, etc.). The computer device may include at least one processor 1001 and a communication interface 1002. Further, optionally, the computer device may also include at least one memory 1003 and a bus 1004. In addition, the processor 1001, the communication interface 1002 and the memory 1003 are connected via a bus 1004. Wherein:

[0271] 1) The processor 1001 is a module that performs arithmetic operations and / or logical operations, and may specifically be a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor unit (MPU), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a complex programmable logic device (CPLD), a coprocessor (assisting the central processing unit to complete corresponding processing and applications), a micro controller unit (MCU), and other processing modules, or a combination of multiple of them.

[0272] 2) The communication interface 1002 may be used to provide information input or output for at least one processor 1001. And / or, the communication interface 1002 may be used to receive data sent from the outside and / or send data to the outside, and may be a wired link interface including an Ethernet cable, etc., or a wireless link interface (Wi-Fi, Bluetooth, general wireless transmission, vehicle-mounted short-range communication technology, and other short-range wireless communication technologies, etc.). The communication interface 1002 may be used as a network interface.

[0273] 3) The memory 1003 is used to provide a storage space, in which data such as an operating system and a computer program can be stored. The memory 1003 can be a random access memory (RAM), a read-only memory (ROM), an erasable programmable read only memory (EPROM), or a portable read-only memory (CD-ROM), etc., or a combination of multiple types.

[0274] Specifically, the processor 1001 calls the program instructions stored in the memory 1003 to perform the following operations:

[0275] Acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images;

[0276] Obtaining image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model;

[0277] The image segmentation model and the image segmentation prompt information are bilaterally optimized using a sample image set to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to segment objects in any image according to the prompts of the optimized image segmentation prompt information.

[0278] In a possible implementation, the sample image set is divided into a first sample subset and a second sample subset; the processor 1001 uses the sample image set to perform bilateral optimization processing on the image segmentation model and the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0279] Using the first sample subset to perform inner optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; or,

[0280] The first sample subset is used to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, the second sample subset is used to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information.

[0281] In a possible implementation, the first sample subset includes M first sample images, any first sample image is represented as a first sample image i, and the first sample image i carries a first sample label, M, i are positive integers, 1≤i≤M; let the image segmentation prompt information before optimization be represented as P0, and the image segmentation prompt information after optimization be represented as P1;

[0282] The processor 1001 uses the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, which is used to perform the following operations:

[0283] Based on the image segmentation prompt information P0, the image segmentation model is called to perform image segmentation processing on the first sample image i to obtain a predicted label of the first sample image i;

[0284] Calculate the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label;

[0285] According to the calculated loss data of the M first sample images, the model parameters to be optimized in the image segmentation model are iteratively optimized to obtain an optimized image segmentation model.

[0286] In a possible implementation, the processor 1001 calculates the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label, and performs the following operations:

[0287] Obtaining a target loss function for training an image segmentation model, where the target loss function includes a first loss function and a second loss function;

[0288] Based on the predicted label of the first sample image i and the first sample label, a first loss of the first sample image i is calculated using a first loss function;

[0289] Based on the predicted label of the first sample image i and the first sample label, a second loss of the first sample image i is calculated using a second loss function;

[0290] The first loss and the second loss are weightedly fused to obtain loss data of the first sample image i.

[0291] In a possible implementation, the second sample subset includes N second sample images, any second sample image is represented as a second sample image j, and the second sample image j carries a second sample label, N and j are positive integers, 1≤j≤N;

[0292] The processor 1001 uses the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information for performing the following operations:

[0293] Call the optimized image segmentation model to perform image segmentation processing on the second sample image j to obtain a predicted label of the second sample image j;

[0294] Calculate the loss data of the second sample image j based on the difference between the predicted label of the second sample image j and the second sample label;

[0295] According to the calculated loss data of the N second sample images, the image segmentation prompt information P0 is iteratively optimized to obtain the optimized image segmentation prompt information P1.

[0296] In a possible implementation, the processor 1001 uses the first sample subset to perform inner optimization processing on the image segmentation model, and during the inner optimization processing, uses the second sample subset to perform outer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information, which are used to perform the following operations:

[0297] Based on the image segmentation prompt information P0, the first sample image i is used to optimize and update the model parameter W0 to be optimized in the image segmentation model to obtain the optimized model parameter W1;

[0298] Based on the optimized model parameter W1, the image segmentation prompt information P0 is optimized and updated using the second sample image j to obtain the optimized image segmentation prompt information P1;

[0299] The optimized image segmentation prompt information P1 is used as the new image segmentation prompt information, and the optimized model parameter W1 is used as the new model parameter, and M first sample images and N second sample images are used for iterative optimization;

[0300] When the iteratively optimized image segmentation model meets the model convergence condition, the optimized image segmentation model and the optimized image segmentation prompt information are obtained.

[0301] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder, and a segmentation decoder; wherein the segmentation decoder is composed of: a convolutional low-rank fine-tuning model, a transposed convolutional layer module, and a multi-layer perceptron, the convolutional low-rank fine-tuning model refers to a convolution mechanism of introducing an expert mixture model in a reweighted model, and the convolutional low-rank fine-tuning model injects an inductive bias prior into the image segmentation model based on the convolution mechanism; the processor 1001 is further used to perform the following operations:

[0302] Obtain a first parameter to be optimized from the convolutional low-rank fine-tuning model;

[0303] Obtain a second parameter to be optimized from the transposed convolutional layer module;

[0304] Obtaining a third parameter to be optimized from the multilayer perceptron;

[0305] The first parameter, the second parameter, and the third parameter to be optimized are determined as model parameters to be optimized in the image segmentation model.

[0306] In a possible implementation, the image segmentation prompt information includes a prompt vector; the processor 1001 obtains the image segmentation prompt information to perform the following operations:

[0307] Obtaining initial prompt data input to the image segmentation model; wherein the type of the initial prompt data includes any one of the following: text, box, point, and mask;

[0308] The second encoder in the image segmentation model is called to perform feature extraction processing on the initial prompt data to obtain a prompt vector of the image segmentation model.

[0309] In a possible implementation, the processor 1001 obtains a sample image set for training an image segmentation model, and performs the following operations:

[0310] Obtain multiple images to be trained for training an image segmentation model;

[0311] Performing image preprocessing on each image to be trained to obtain a preprocessed image; wherein the image preprocessing includes: any one or more of normalization processing, denoising processing, and image flipping processing;

[0312] The preprocessed images are used as sample images for training the image segmentation model, and a sample image set is generated based on each sample image.

[0313] In a possible implementation manner, the processor 1001 is further configured to perform the following operations:

[0314] The sample image set is divided into a first sample subset and a second sample subset by using a preset data division method; the preset data division method includes any one of the following: randomly dividing each sample image in the sample image set, dividing each sample image in the sample image set according to a specified number;

[0315] The number of first sample images included in the first sample subset and the number of second sample images included in the second sample subset are the same or different.

[0316] In a possible implementation manner, the processor 1001 is further configured to perform the following operations:

[0317] Obtaining business images to be processed in a business field, where the business field includes any one of the following: medical field, game field, live broadcast field, and transportation field;

[0318] According to the optimized image segmentation prompt information, the optimized image segmentation model is called to perform image segmentation processing on the business image to obtain the segmentation result of the business image;

[0319] Based on the segmentation result of the business image, business processing is performed on the business image in the business domain; wherein the business processing includes: any one of medical data analysis, game testing and optimization, and traffic situation analysis.

[0320] In a possible implementation, the image segmentation model includes: a first encoder, a second encoder, and a segmentation decoder; the segmentation result includes a segmentation mask matrix, the segmentation mask matrix includes a mask label of each pixel in the business image, and any of the mask labels is used to reflect the category to which the corresponding pixel belongs;

[0321] The processor 1001 calls the optimized image segmentation model to perform image segmentation processing on the business image according to the optimized image segmentation prompt information, and obtains the segmentation result of the business image, which is used to perform the following operations:

[0322] Calling the first encoder to perform image feature extraction processing on the business image to obtain an image feature vector of the business image; wherein the image feature extraction processing includes: any one or more of image convolution processing, position encoding processing, and attention mechanism processing;

[0323] The segmentation decoder is called to decode the image feature vector and the optimized image segmentation prompt information to obtain the segmentation mask matrix of the business image.

[0324] In an embodiment of the present application, a bilateral optimization method based on image segmentation is provided, which can not only optimize the image segmentation model, but also optimize the image segmentation prompt information, so that the optimized image segmentation prompt information can guide the segmentation processing of any image, that is, the optimized image segmentation prompt information can provide prompts for the segmentation processing of any image, thereby avoiding artificially designing prompt information for the image, achieving efficient optimization of the image segmentation model, and thus improving the efficiency of image segmentation processing.

[0325] According to one aspect of the present application, an embodiment of the present application further provides a computer storage medium, and a computer program is stored in the computer storage medium, and the computer program includes program instructions. When the processor executes the above program instructions, the method in the corresponding embodiment of the foregoing text can be executed, so it will not be repeated here. For technical details not disclosed in the computer storage medium embodiment involved in the present application, please refer to the description of the method embodiment of the present application. As an example, the program instructions can be deployed on a computer device, or executed on multiple computer devices located in one place, or, executed on multiple computer devices distributed in multiple locations and interconnected by a communication network.

[0326] According to one aspect of the present application, an embodiment of the present application further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device can execute the method in the above corresponding embodiment, and therefore, it will not be described in detail here.

[0327] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server, a data center, etc. that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0328] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A model processing method, characterized in that: include: Acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images; the sample image set is divided into a first sample subset and a second sample subset; Acquire image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model; Using the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, and using the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; or, The image segmentation model is inner-optimized by using the first sample subset, and during the inner-optimization process, the image segmentation prompt information is outer-optimized by using the second sample subset to obtain an optimized image segmentation model and optimized image segmentation prompt information; The optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information.

2. The method according to claim 1, characterized in that The first sample subset includes M first sample images, any one of the first sample images is represented as a first sample image i, and the first sample image i carries a first sample label, M, i are positive integers, 1≤i≤M; the image segmentation prompt information before optimization is represented as P0, and the image segmentation prompt information after optimization is represented as P1; The step of performing inner layer optimization processing on the image segmentation model using the first sample subset to obtain an optimized image segmentation model comprises: Based on the image segmentation prompt information P0, calling the image segmentation model to perform image segmentation processing on the first sample image i to obtain a predicted label of the first sample image i; Calculating loss data of the first sample image i based on a difference between the predicted label of the first sample image i and the first sample label; According to the calculated loss data of the M first sample images, the model parameters to be optimized in the image segmentation model are iteratively optimized to obtain an optimized image segmentation model.

3. The method according to claim 2, characterized in that The calculating the loss data of the first sample image i based on the difference between the predicted label of the first sample image i and the first sample label includes: Acquire a target loss function for training the image segmentation model, wherein the target loss function includes a first loss function and a second loss function; Based on the predicted label of the first sample image i and the first sample label, the first loss of the first sample image i is calculated using the first loss function; Based on the predicted label of the first sample image i and the first sample label, using the second loss function to calculate the second loss of the first sample image i; The first loss and the second loss are weightedly fused to obtain loss data of the first sample image i.

4. The method according to claim 1, characterized in that The second sample subset includes N second sample images, any one of the second sample images is represented as a second sample image j, and the second sample image j carries a second sample label, N and j are positive integers, 1≤j≤N; The step of performing outer layer optimization processing on the image segmentation prompt information by using the second sample subset to obtain optimized image segmentation prompt information includes: Calling the optimized image segmentation model to perform image segmentation processing on the second sample image j to obtain a predicted label of the second sample image j; Calculating loss data of the second sample image j based on a difference between the predicted label of the second sample image j and the second sample label; According to the calculated loss data of the N second sample images, the image segmentation prompt information P0 is iteratively optimized to obtain the optimized image segmentation prompt information P1.

5. The method according to claim 1, characterized in that The method of using the first sample subset to perform inner layer optimization processing on the image segmentation model, and using the second sample subset to perform outer layer optimization processing on the image segmentation prompt information during the inner layer optimization processing, to obtain an optimized image segmentation model and optimized image segmentation prompt information, includes: Based on the image segmentation prompt information P0, the first sample image i is used to optimize and update the model parameter W0 to be optimized in the image segmentation model to obtain the optimized model parameter W1; Based on the optimized model parameter W1, the image segmentation prompt information P0 is optimized and updated using the second sample image j to obtain the optimized image segmentation prompt information P1; The optimized image segmentation prompt information P1 is used as new image segmentation prompt information, and the optimized model parameter W1 is used as a new model parameter, and M first sample images and N second sample images are used for iterative optimization; When the iteratively optimized image segmentation model satisfies the model convergence condition, an optimized image segmentation model and optimized image segmentation prompt information are obtained.

6. The method according to any one of claims 1 to 5, characterized in that: The image segmentation model includes: a first encoder, a second encoder and a segmentation decoder; wherein the segmentation decoder is composed of: a convolutional low-rank fine-tuning model, a transposed convolutional layer module, and a multi-layer perceptron, the convolutional low-rank fine-tuning model refers to a convolution mechanism of introducing an expert mixture model in a reweighted model, and the convolutional low-rank fine-tuning model injects an inductive bias prior into the image segmentation model based on the convolution mechanism; the method also includes: Obtaining a first parameter to be optimized from the convolutional low-rank fine-tuning model; Obtaining a second parameter to be optimized from the transposed convolutional layer module; Obtaining a third parameter to be optimized from the multilayer perceptron; The first parameter, the second parameter, and the third parameter to be optimized are determined as model parameters to be optimized in the image segmentation model.

7. The method according to claim 6, characterized in that The image segmentation prompt information includes a prompt vector; and obtaining the image segmentation prompt information includes: Acquire initial prompt data input to the image segmentation model; wherein the type of the initial prompt data includes any one of the following: text, box, point, and mask; The second encoder in the image segmentation model is called to perform feature extraction processing on the initial prompt data to obtain a prompt vector of the image segmentation model.

8. The method according to claim 1, characterized in that The step of obtaining a sample image set for training an image segmentation model comprises: Obtain multiple images to be trained for training an image segmentation model; Performing image preprocessing on each of the images to be trained to obtain a preprocessed image; wherein the image preprocessing includes: any one or more of normalization processing, denoising processing, and image flipping processing; The preprocessed images are used as sample images for training the image segmentation model, and a sample image set is generated based on each sample image.

9. The method according to claim 8, characterized in that The method further comprises: The sample image set is divided into a first sample subset and a second sample subset by using a preset data division method; the preset data division method includes any one of the following: randomly dividing each sample image in the sample image set, dividing each sample image in the sample image set according to a specified number; The number of first sample images included in the first sample subset and the number of second sample images included in the second sample subset are the same or different.

10. The method according to claim 1, characterized in that The method further comprises: Acquire a business image to be processed in a business field, wherein the business field includes: any one of a medical field, a game field, a live broadcast field, and a transportation field; According to the optimized image segmentation prompt information, calling the optimized image segmentation model to perform image segmentation processing on the business image to obtain a segmentation result of the business image; Based on the segmentation result of the business image, business processing is performed on the business image in the business domain; wherein the business processing includes: any one of medical data analysis, game testing and optimization, and traffic situation analysis.

11. The method according to claim 10, characterized in that The image segmentation model includes: a first encoder, a second encoder and a segmentation decoder; the segmentation result includes a segmentation mask matrix, the segmentation mask matrix includes a mask label of each pixel in the business image, and any mask label is used to reflect the category to which the corresponding pixel belongs; The step of calling the optimized image segmentation model to perform image segmentation processing on the business image according to the optimized image segmentation prompt information to obtain a segmentation result of the business image includes: Calling the first encoder to perform image feature extraction processing on the business image to obtain an image feature vector of the business image; wherein the image feature extraction processing includes: any one or more of image convolution processing, position encoding processing, and attention mechanism processing; The segmentation decoder is called to decode the image feature vector and the optimized image segmentation prompt information to obtain a segmentation mask matrix of the business image.

12. A model processing device, characterized in that: include: An acquisition unit is used to acquire a sample image set for training an image segmentation model; wherein the sample image set includes a plurality of sample images, the sample images contain objects, and the image segmentation model is used to perform segmentation processing on the objects in the sample images; the sample image set is divided into a first sample subset and a second sample subset; The acquisition unit is further used to acquire image segmentation prompt information; the image segmentation prompt information is used to prompt the segmentation processing process performed by the image segmentation model; a processing unit, configured to use the first sample subset to perform inner layer optimization processing on the image segmentation model to obtain an optimized image segmentation model, and use the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain optimized image segmentation prompt information; or The processing unit is further used to use the first sample subset to perform inner layer optimization processing on the image segmentation model, and during the inner layer optimization processing, use the second sample subset to perform outer layer optimization processing on the image segmentation prompt information to obtain an optimized image segmentation model and optimized image segmentation prompt information; wherein the optimized image segmentation model is used to perform segmentation processing on objects in any image according to the prompt of the optimized image segmentation prompt information.

13. A computer device, characterized in that: include: Memory and processor; One or more computer programs are stored in the memory; A processor is used to load the one or more computer programs to implement the model processing method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the model processing method according to any one of claims 1 to 11 is executed.

15. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the model processing method according to any one of claims 1 to 11 is executed.

Citation Information

Cited By

  • End-side optical character recognition system and method

    TWI947403B