Identification method and equipment based on multi-modal large model
By extracting key area and coordinate information of images through small models, combined with multi-modal large model recognition, the problem of poor recognition effect of multi-modal large models in specific areas is solved, and the recognition accuracy and efficiency are improved.
Patent Information
- Application Number
- CN202410702591.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-10-11
Smart Images

Figure CN118762256A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a recognition method and device based on a multimodal large model. Background Art
[0002] The multimodal large model can recognize images based on prompt words, such as generating image description text or answering questions based on images. In actual application, in some business scenarios, only a certain area in the image or only key targets need to be recognized, but the area or target to be recognized in each image is not fixed and changes at different times. The location information of the area or target cannot be set in advance, and the multimodal large model can only recognize it based on the entire image.
[0003] In the related technology, the multimodal large model has a good understanding of the entire image and a relatively accurate description of the entire image. However, when there is a need to identify a certain area or target in the image, the recognition effect of the multimodal large model is poor. Summary of the invention
[0004] The present application provides a recognition method and device based on a multimodal large model, which is used to solve the problem of poor recognition effect when the multimodal large model is used to recognize a certain area or target in an image in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a recognition method based on a multimodal large model, the method comprising:
[0006] Use a small model to identify key areas of the target image to be identified and determine the coordinate information corresponding to the key areas;
[0007] Determining, in the target image, a target sub-image corresponding to the key area according to the coordinate information;
[0008] According to the multimodal large model and the target sub-image, a recognition result corresponding to the target sub-image is determined.
[0009] In a second aspect, an embodiment of the present application further provides an electronic device, comprising a processor, wherein the processor is configured to implement the steps of the above-mentioned multimodal large model-based recognition method when executing a computer program stored in a memory.
[0010] In an embodiment of the present application, a small model is used to identify key areas of a target image to be identified, and coordinate information corresponding to the key areas is determined; based on the coordinate information, a target sub-image corresponding to the key area is determined in the target image; and based on the multimodal large model and the target sub-image, a recognition result corresponding to the target sub-image is determined. In an embodiment of the present application, a method combining large and small models is proposed. First, the key area is detected by a small model to determine the target sub-image corresponding to the key area, and then the recognition is performed based on the multimodal large model to obtain the recognition result corresponding to the target sub-image. The resolution of the input image is reduced, other irrelevant areas are removed, and only the focus part is input to the multimodal large model, thereby improving the recognition effect of the multimodal large model. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments 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 any creative work.
[0012] Figure 1 A schematic diagram of a snow recognition scenario provided for related technologies;
[0013] Figure 2 A schematic diagram of a railway foreign object recognition scenario provided for related technologies;
[0014] Figure 3 A schematic diagram of a sleeping post scene provided for related technologies;
[0015] Figure 4 A schematic diagram of a recognition process based on a multimodal large model provided in an embodiment of the present application;
[0016] Figure 5 A schematic diagram of a masked snow recognition scene provided in an embodiment of the present application;
[0017] Figure 6 A schematic diagram of a railway foreign object identification mask provided in an embodiment of the present application;
[0018] Figure 7 A schematic diagram of the process of constructing a sample data set corresponding to a snowy road scene provided in an embodiment of the present application;
[0019] Figure 8 A schematic diagram of a scene recognition process provided in an embodiment of the present application;
[0020] Fig. 9 A schematic diagram of an application based on multimodal large model recognition provided in an embodiment of the present application;
[0021] Fig.10 A schematic diagram of the structure of a recognition device based on a multimodal large model provided in an embodiment of the present application;
[0022] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0024] In some business scenarios, it is only necessary to judge the scene within the area or the key target, but the area or the target in the image is not fixed and changes at different times. It is impossible to set the location information of the area or scene in advance. The relevant technology can only judge the entire image. However, for such complex scenes, the recognition effect of small models is poor, and relying solely on small models cannot achieve a good effect. The current multimodal large model has a good overall image understanding effect and a relatively accurate description of the entire image, but the accuracy of the description of the area or target is low.
[0025] For example, in the field of transportation, in the snow recognition scenario, it is only necessary to determine whether there is snow on the road, and the snow on the side of the road is not important.
[0026] Figure 1 A schematic diagram of a snow recognition scene provided for related technologies. Figure 1 Input into the multimodal large model, the output is:
[0027] prompt: Please describe the scene in the picture
[0028] response: The picture shows a picture taken by a surveillance camera on a highway. In this picture, you can see a black highway with only a white car driving on it. There are yellow highway shoulders on both sides of the highway, which are covered with snow. The upper left corner of the picture shows the shooting time and the number of the surveillance camera.
[0029] prompt: Is there any snow in the picture?
[0030] response: Yes, as you can see in the picture, there is snow on the road.
[0031] prompt: Is there snow in the middle of the road?
[0032] Response: Yes, there is snow on the road. As you can see from the picture, the road is covered with a layer of snow, especially near the central divider, where the snow is thicker.
[0033] like Figure 1 In the image, there is snow on both sides of the road, but no snow on the road. At this time, it does not affect the traffic situation and the driver can drive normally. The understanding obtained by the multimodal large model is that there is snow in the picture, and the wrong answer is output, which will affect the business application.
[0034] In the railway field, in the railway foreign object scenario, it is only necessary to judge whether there are foreign objects (cat and dog carcasses, large plastic sheets, iron sheets, etc.) on the rails and nearby areas, and no attention is paid to whether there are foreign objects in other areas.
[0035] Figure 2 A schematic diagram of a railway foreign object recognition scenario provided for related technologies, such as Figure 2 ,If the answer is only based on the description of the whole picture, it may lead to wrong conclusions, affecting business applications.
[0036] In the sleeping post scenario, only the staff members need to be judged, and other areas are not concerned. Figure 3 A schematic diagram of a sleeping scene provided for related technologies, such as Figure 3 As shown, if the answer is based only on the description of the whole picture, it may lead to wrong conclusions and affect the evaluation of the staff.
[0037] In addition, there is currently a problem that the image resolution affects the recognition effect of the multimodal large model. When the input image resolution is large, the recognition effect of the multimodal large model is poor.
[0038] Based on this, in order to improve the image recognition effect, the embodiment of the present application provides a recognition method and device based on a multimodal large model.
[0039] In an embodiment of the present application, a small model is used to identify key areas of a target image to be identified, and coordinate information corresponding to the key areas is determined; based on the coordinate information, a target sub-image corresponding to the key area is determined in the target image; based on the multimodal large model and the target sub-image, a recognition result corresponding to the target sub-image is determined.
[0040] Figure 4 A schematic diagram of a recognition process based on a multimodal large model provided in an embodiment of the present application, the process includes:
[0041] S401: Use a small model to identify key areas of the target image to be identified, and determine coordinate information corresponding to the key areas.
[0042] An embodiment of the present application provides a recognition method based on a multimodal large model, which is applied to an electronic device, and the electronic device may be a PC or a server.
[0043] Since the multimodal large model in the related art cannot recognize the area in the image very well, in the embodiment of the present application, the key area in the target image is extracted by the small model, and only the target sub-image corresponding to the key area is input to the multimodal large model, which reduces the resolution of the input image and improves the recognition effect of the multimodal large model. For example, in the sleeping guard scene, only the area containing the staff is input, which greatly reduces the image resolution compared to the original target image, which will further improve the recognition effect of the multimodal large model.
[0044] Specifically, in an embodiment of the present application, the electronic device inputs the target image to be identified into the small model, and the small model identifies the key areas of the target image, determines and outputs the coordinate information corresponding to the key areas in the target image.
[0045] Among them, in the embodiment of the present application, the small model is a smaller-scale machine learning or deep learning model, which has the advantages of being lightweight, efficient, and easy to deploy. The small model of the embodiment of the present application can be a target detection model, an image segmentation model, or other models that can identify key areas in an image.
[0046] S402: Determine, in the target image, a target sub-image corresponding to the key area according to the coordinate information.
[0047] In an embodiment of the present application, after the electronic device obtains the coordinate information corresponding to the key area output by the small model, the electronic device determines the target sub-image corresponding to the key area in the target image based on the coordinate information.
[0048] Specifically, in the embodiment of the present application, the coordinate information output by the small model is {(x i, y i ), i=1,…,N}, the coordinate information includes multiple coordinates, each coordinate corresponds to a vertex of the key area, and the electronic device can determine multiple points in the target image based on the received coordinate information, and determine the area surrounded by the multiple points as the target sub-image corresponding to the key area.
[0049] Among them, if the small model is a target detection model, the key area determined by the small model is a rectangle, and the number of coordinates contained in the coordinate information output by the small model is two. The electronic device determines the two coordinates as the two vertices of any diagonal of the rectangle, and determines the coordinates of the other two vertices of the rectangle based on the two coordinates. The electronic device determines four points in the target image based on the four coordinates, and connects the four points in sequence, and the enclosed area is determined as the target sub-image corresponding to the key area.
[0050] If the small model is an image segmentation model, the key area determined by the small model is a polygon, and the number of coordinates contained in the coordinate information output by the small model is three or more. The electronic device determines three or more points in the target image based on the three or more coordinates, and connects the three or more points in sequence, and determines the enclosed area as the target sub-image corresponding to the key area.
[0051] S403: Determine a recognition result corresponding to the target sub-image according to the multimodal large model and the target sub-image.
[0052] In an embodiment of the present application, after the electronic device determines the target sub-image corresponding to the key area in the target image, the electronic device determines the recognition result corresponding to the target sub-image based on the multimodal large model and the target sub-image.
[0053] Specifically, the target sub-image and the prompt word are input into the multimodal large model by the electronic device, and the multimodal large model recognizes the target sub-image according to the prompt word. In the embodiment of the present application, the prompt word can be a prompt word for the overall description of the output image of the multimodal large model, or a question that needs to be answered by the multimodal large model.
[0054] Example 1: Figure 1 Through the recognition method provided in the embodiment of the present application, the output of the multimodal large model is:
[0055] prompt: Please describe the scene in the picture
[0056] Response: It is a photo taken from above on a winding highway, with green vegetation on both sides of the road and a car driving in the middle. There is a blue sky above the entire picture, a solid white line on the right, and a dotted line on the left.
[0057] prompt: Is there any snow in the picture?
[0058] response: There is no snow in the picture and the road is very clean.
[0059] prompt: Is there snow in the middle of the road?
[0060] response: According to the description, there is no snow in the middle of the road in the picture and the road surface is very clean.
[0061] Example 2: Figure 2 Through the recognition method provided in the embodiment of the present application, the output of the multimodal large model is:
[0062] Prompt: Is there any foreign object on the rails in the picture? Foreign objects include but are not limited to kittens, puppies, plastic sheets, iron sheets, etc.
[0063] response: Yes, there is a kitten on the railroad tracks in the picture.
[0064] Example 3: Figure 3 Through the recognition method provided in the embodiment of the present application, the output of the multimodal large model is:
[0065] prompt: Is the staff in the picture sleeping?
[0066] response: Yes, the staff in the picture is sleeping.
[0067] Among them, in the above examples 1-3, the content after prompt is the prompt word, and the content after response is the output of the multimodal large model.
[0068] In an embodiment of the present application, a method of combining large and small models is proposed. The key area is first detected by a small model to determine the target sub-image corresponding to the key area, and then recognition is performed based on the multimodal large model to obtain the recognition result corresponding to the target sub-image. The resolution of the input image is reduced, and other irrelevant areas are removed. Only the focus part is input into the multimodal large model, thereby improving the recognition effect of the multimodal large model.
[0069] In order to improve the image recognition effect, based on the above embodiment, in the embodiment of the present application, determining the target sub-image corresponding to the key area in the target image according to the coordinate information includes:
[0070] According to the coordinate information, determining a target area corresponding to the coordinate information in the target image;
[0071] The target area is expanded according to a pre-configured expansion rule, and the target image is cut according to the expanded target area to determine the target sub-image.
[0072] In an embodiment of the present application, after the electronic device obtains the coordinate information output by the small model, the electronic device determines the target area corresponding to the coordinate information in the target image based on the coordinate information. The process of the electronic device determining the target area corresponding to the coordinate information in the target image based on the coordinate information is consistent with the process of the above-mentioned embodiment and will not be repeated here.
[0073] In order to better identify the target area, in an embodiment of the present application, the electronic device is also pre-configured with an expansion rule, which can expand the target area to avoid poor recognition effect of a target area that is too small.
[0074] Specifically, in an embodiment of the present application, the electronic device obtains a pre-configured expansion rule, and expands the target area in the target image according to the expansion rule to obtain the expanded target area. The electronic device cuts the target area and determines the cut image as the target sub-image corresponding to the key area.
[0075] In order to improve the image recognition effect, on the basis of the above embodiments, in the embodiment of the present application, after determining the target area corresponding to the coordinate information in the target image according to the coordinate information, and before expanding the target area according to the pre-configured expansion rule, the method further includes:
[0076] Mask processing is performed on other areas of the target image except the target area.
[0077] Since the target area will include some other areas after expansion, in order to reduce the resolution of the input image, remove other irrelevant areas, only input the focus area to the large model, and improve the recognition effect of the large model, in an embodiment of the present application, after the electronic device determines the target area corresponding to the coordinate information in the target image, the electronic device will also perform mask processing on other areas in the target image except the target area.
[0078] Specifically, in the embodiment of the present application, the electronic device sets the pixel values of the pixel points in other areas of the target image except the target area to preset values.
[0079] In the embodiment of the present application, by masking the target image except the target area, the multimodal large model will not be disturbed by the targets in other areas. Only identifying the presence or absence of targets in the key areas will further improve the recognition effect of the multimodal large model.
[0080] exist Figure 1 On a public basis, Figure 5 This is a schematic diagram of a snow recognition scene mask provided in an embodiment of the present application, such as the Figure 5 As shown, the electronic device performs mask processing on areas other than the road in the image.
[0081] exist Figure 2 On a public basis, Figure 6 This is a schematic diagram of a railway foreign object identification mask provided in an embodiment of the present application, such as the Figure 6 As shown, the electronic device performs mask processing on other areas in the image except the railroad tracks.
[0082] In order to improve the image recognition effect, on the basis of the above embodiments, in the embodiment of the present application, if the small model is an image segmentation model, the expansion of the target area according to the pre-configured expansion rule includes:
[0083] In the target image, determining a minimum bounding rectangle corresponding to the target area;
[0084] The area corresponding to the minimum circumscribed rectangle is determined as the expanded target area.
[0085] In the embodiment of the present application, there are many types of small models. If the small model used by the electronic device is an image segmentation model using an image segmentation algorithm, the target area determined by the image segmentation model is a polygon, and the coordinate information output by the image segmentation model is the coordinates of each vertex of the polygon. After the electronic device receives the coordinate information and determines the target area in the target image according to the coordinate information, the electronic device determines the minimum bounding rectangle corresponding to the target area, and determines the area corresponding to the minimum bounding rectangle as the expanded target area.
[0086] Specifically, in the embodiment of the present application, if the small model is an image segmentation model using an image segmentation algorithm, the coordinate information output at this time is {(x i, y i ), i = 1, ..., N}, the electronic device determines the target area corresponding to the coordinate information, and determines the minimum bounding rectangle of the target area, that is, the coordinates of the upper left corner of the minimum bounding rectangle are (min{x i},min{y i}), i=1,…,N, the coordinates of the lower right corner are (max{x i},max{y i}),i=1,…,N.
[0087] It should be noted that sometimes the segmentation target is large, and the area corresponding to the minimum bounding rectangle of the target area is the target image.
[0088] In order to improve the image recognition effect, on the basis of the above embodiments, in the embodiment of the present application, if the small model is a target detection model, the expansion of the target area according to the pre-configured expansion rule includes:
[0089] In the target image, the length and width of the target area are enlarged by a preset multiple;
[0090] The enlarged area is determined as the expanded target area.
[0091] In the embodiment of the present application, there are many types of small models. If the small model used by the electronic device is a target detection model that uses a target detection algorithm, the target area determined by the target detection model is a rectangle, and the coordinate information output by the image segmentation model is the coordinates of the two vertices corresponding to any diagonal line, generally the vertex in the upper left corner and the vertex in the lower right corner. After the electronic device receives the coordinate information and determines the target area in the target image according to the coordinate information, the electronic device expands the length and width of the target area by preset multiples, and determines the expanded area as the expanded target area.
[0092] The preset multiple may be an integer greater than 1.
[0093] Specifically, if the small model is a target detection model using a target detection algorithm, the output coordinate information is the coordinates of the two vertices corresponding to any diagonal line {(x1, y1), (x2, y2)}, and the target area is determined based on the coordinate information. Taking the center point of the target area as the origin, the length and width are expanded by α times (α≥1), and the expanded area is {(x ′ 1,y ′ 1),(x ′ 2,y ′ 2)}. The user can decide whether to expand the target area by configuring the value of the preset multiple α according to the actual scene requirements.
[0094] The electronic device can determine the coordinate information of the expanded area by the following formula:
[0095]
[0096] Among them, {(x1, y1), (x2, y2)} are the coordinates of the upper left corner and lower right corner of the original target area, {(x ′ 1,y ′ 1),(x ′ 2,y ′ 2)} The coordinates of the two vertices in the upper left corner and lower right corner of the enlarged area, α is the preset multiple.
[0097] In order to improve the image recognition effect, on the basis of the above embodiments, in the embodiment of the present application, before determining the recognition result corresponding to the target sub-image according to the multimodal large model and the target sub-image, the method further includes:
[0098] Obtain a preset number of sample images;
[0099] For each sample image, the image language pre-training model BLIP2 and the chat generation pre-training transformer ChatGPT API are used to process the sample image to determine the sample description text corresponding to the sample image;
[0100] The multimodal large model is fine-tuned according to each sample image and the corresponding sample description text.
[0101] Since the small model has a certain amount of misidentification, the key area given by the small model is not necessarily the most ideal area, and some other areas may be included. Based on this, the embodiment of the present application will also fine-tune the multimodal large model to further improve the regional recognition ability of the multimodal large model and reduce the misidentification rate.
[0102] In order to better fine-tune the multimodal large model, in an embodiment of the present application, a sample data set for fine-tuning the multimodal large model is constructed through a multi-level data construction method. The multimodal large model is fine-tuned based on the constructed sample data set to further optimize the multimodal large model's ability to recognize regional scenes. Among them, the sample data construction method includes data diversity and multi-level fusion description.
[0103] Specifically, the electronic device obtains a preset number of sample images; for each sample image, the image language pre-training model (Bootstrapping Language Image Pre-training 2, BLIP2) and the chat generative pre-trained transformer (Chat Generative Pre-trained Transformer Application Programming Interface, ChatGPT API) are used to process the sample image to determine the sample description text corresponding to the sample image. The electronic device fine-tunes the multimodal large model according to each sample image and the corresponding sample description text.
[0104] Among them, in the embodiments of the present application, when the electronic device fine-tunes the multimodal large model, fine-tuning methods such as Adapter-Tuning, Prefix-Tuning, Prompt-Tuning (P-Tuning), P-Tuning v2, LoRA, etc. can be used, and there is no limitation here.
[0105] In order to improve the image recognition effect, based on the above embodiments, in the embodiment of the present application, the multimodal large model is fine-tuned according to each sample image and the corresponding sample description text, including:
[0106] Using each sample image and the corresponding sample description text to train the multimodal large model, and calculating the loss value;
[0107] Adjusting the parameter values of the pre-configured model parameters for fine-tuning according to the loss value to obtain the target model parameters;
[0108] The target model parameters are combined with the original model parameters of the multimodal large model to obtain a fine-tuned multimodal large model.
[0109] In an embodiment of the present application, the electronic device can use the common LoRA fine-tuning method to perform multi-modal large model fine-tuning.
[0110] Specifically, the electronic device uses each sample image and the corresponding sample description text to train the multimodal large model and calculates the loss value; adjusts the parameter values of the pre-configured model parameters for fine-tuning according to the loss value to obtain the target model parameters; merges the target model parameters with the original model parameters of the multimodal large model to obtain the fine-tuned multimodal large model.
[0111] In order to improve the image recognition effect, based on the above embodiments, in the embodiment of the present application, the image language pre-training model BLIP2 and the chat generation pre-training transformer ChatGPT API are used to process the sample image, and the sample description text corresponding to the sample image is determined to include:
[0112] Using the BLIP2 to identify the sample image, and determining the initial global description text corresponding to the sample image;
[0113] Performing target detection on the sample image using a target detection model, and determining a first sample sub-image according to first coordinate information output by the target detection model, and recognizing the first sample sub-image using the BLIP2 to determine a first sub-description text corresponding to the first sample sub-image;
[0114] Performing image segmentation on the sample image using an image segmentation model, and determining a second sample sub-image according to second coordinate information output by the image segmentation model, and recognizing the second sample sub-image using the BLIP2 to determine a second sub-description text corresponding to the second sample sub-image;
[0115] The sample image, the initial global description text, the first sample sub-image, the first sub-description text, the second sample sub-image and the second sub-description text are input into the ChatGPT API to determine the sample description text corresponding to the sample image.
[0116] In an embodiment of the present application, when the electronic device constructs a sample data set, the electronic device first generates an initial global description text for the sample image, then uses a small model to identify key areas, and generates a sub-description text for the sample sub-image corresponding to the key areas, and then determines the sample description text corresponding to the sample image based on the initial global description text and the sub-description text.
[0117] Specifically, in the embodiment of the present application, the electronic device inputs the sample image into BLIP2 for recognition, and obtains the initial global description text corresponding to the sample image output by BLIP2. The electronic device inputs the sample image into the target detection model, obtains the first coordinate information output by the target detection model, and determines the first sample sub-image according to the first coordinate information; the electronic device inputs the sample image into the image segmentation model, obtains the second coordinate information output by the image segmentation model, and determines the second sample sub-image according to the second coordinate information.
[0118] The electronic device inputs the first sample sub-image and the second sample sub-image into the BLIP2 respectively, and determines a first sub-description text corresponding to the first sample sub-image and a second sub-description text corresponding to the second sample sub-image.
[0119] The electronic device inputs the sample image, the initial global description text, the first sample sub-image, the first sub-description text, the second sample sub-image and the second sub-description text into the ChatGPT API, and obtains the sample description text corresponding to the sample image output by the ChatGPT API.
[0120] In addition, in the embodiment of the present application, after the electronic device obtains the sample description text output by the ChatGPT API, it can further revise and supplement the sample description based on the sample image, the initial global description text, the first sample sub-image, the first sub-description text, the second sample sub-image, and the second sub-description text. Among them, the revision and supplement can be made by the technicians, and can also be made by preset rules, such as pre-setting the necessary information, etc., which is not limited here.
[0121] In a possible implementation, a snowy road scene is used as an example for description:
[0122] When constructing the sample dataset corresponding to the snowy road scene, the sample images selected include the following types of images: images with a large amount of snow in the entire image area, images with snow only on both sides of the road, and images with a small amount of snow on the road.
[0123] Figure 7 A schematic diagram of the construction process of a sample data set corresponding to a snowy road scene provided in an embodiment of the present application, such as the Figure 7As shown in the figure, when determining the sample description text corresponding to the sample image, the following steps are used for description: (1) Generate an initial global description text for the entire sample image based on BLIP2, and the initial global description text is "the ground is covered with white snow, and a snow-white car is driving on a black road"; (2) Use the trained target detection model for detecting roads to generate a road key area (the first sub-sample image), and describe the scene in the road area in detail based on BLIP2. The detailed description of the road key area is "a black road with only a white car driving on it"; (3) Use the trained image segmentation model to generate a road segmentation area (the second sub-sample image), and then describe the road segmentation area in detail based on BLIP2. The road segmentation area is described as "a black highway, which is very clean, with a white car running on it". In the final stage, the initial global description text, road key areas and corresponding descriptions, road segmentation areas and corresponding descriptions are input into the ChatGPT API for summary, and an overall description (sample description text) is output. The overall description is "In this picture, you can see a black road. The road is very clean. There is only a white car driving on it. There are large tracts of land on both sides of the road, and the ground is covered with snow."
[0124] In order to improve the image recognition effect, based on the above embodiments, in the embodiment of the present application, the process of determining the small model includes:
[0125] Receiving an image recognition request carrying the identifiers of the target image and the small model;
[0126] The small model is determined according to the identifier of the small model.
[0127] In the embodiment of the present application, there are many types of small models. For the input image, a suitable small model is selected according to the specific business scenario.
[0128] If the key area of interest is an irregular area, the traditional image segmentation model is used to segment the area and output the segmented key area. For example, in a snowy road scene, the image segmentation model is used to segment the road area in the image and output the polygon coordinates corresponding to the road area; in a railway foreign body scene, the image segmentation model is used to segment the rail area in the image and output the polygon coordinates corresponding to the rail area.
[0129] If the key area of interest is a regular area, the target detection model is used to detect the target and output the detected rectangular area. For example, for sleeping guard detection, the target detection model is used to detect the staff first and output the coordinates of the detected staff rectangular area.
[0130] In an embodiment of the present application, a technician may select a small model and send the identifier of the small model to an electronic device through an image recognition request. The electronic device determines the small model to be used for recognition based on the identifier of the small model carried in the received image recognition request.
[0131] Specifically, in an embodiment of the present application, an electronic device receives an image recognition request carrying the identification of a target image and a small model; the electronic device determines the small model to be used for recognition based on the identification of the small model.
[0132] It should be noted that the recognition method of the embodiment of the present application is applicable to all specific area scene recognition, and the overall idea is universal. Users can flexibly select solutions for each part according to specific scene requirements, and ultimately achieve the goal better.
[0133] Figure 8 A schematic diagram of a scene recognition process provided in an embodiment of the present application, such as the Figure 8 As shown in the figure, the process includes: first, input an image, obtain the coordinates of the key area through a small model (select a target detection model or an image segmentation model according to the actual business scenario), process the key area, and send the processed sub-image to the multimodal large model, which recognizes it and outputs the recognition result. In addition, a data set can be constructed and the multimodal large model can be fine-tuned based on the data set.
[0134] Based on the above embodiments, Fig. 9 The schematic diagram of the application based on multimodal large model recognition provided in the embodiment of the present application is as follows: Fig. 9 As shown, a small model is used to recognize a target image of a foreign object scene on a railroad track (Fig. a), and a target area is identified in the target image (Fig. b); other areas in the target image except the target area are masked to obtain a masked target image (Fig. c); the target area is expanded according to a pre-configured expansion rule, and the target image is cut according to the expanded target area to obtain a target sub-image (Fig. d); the target sub-image is input into a multimodal large model, and the recognition result output by the multimodal large model is "In this picture, you can see a rail and a black kitten on the rail."
[0135] Based on the above embodiments, Fig.10 A schematic diagram of a structure of a recognition device based on a multimodal large model provided in an embodiment of the present application, the device comprising:
[0136] The recognition module 1001 is used to use a small model to identify key areas of the target image to be identified, and determine the coordinate information corresponding to the key areas;
[0137] A processing module 1002 is used to determine a target sub-image corresponding to the key area in the target image according to the coordinate information;
[0138] The recognition module 1001 is further used to determine a recognition result corresponding to the target sub-image according to the multimodal large model and the target sub-image.
[0139] In a possible implementation, the processing module 1002 is specifically used to determine, in the target image, a target area corresponding to the coordinate information based on the coordinate information; expand the target area according to a preconfigured expansion rule, and cut the target image according to the expanded target area to determine the target sub-image.
[0140] In a possible implementation, the processing module 1002 is further configured to perform mask processing on other regions in the target image except the target region.
[0141] In a possible implementation, the processing module 1002 is specifically used to determine the minimum bounding rectangle corresponding to the target area in the target image if the small model is an image segmentation model; and determine the area corresponding to the minimum bounding rectangle as the expanded target area.
[0142] In a possible implementation, the processing module 1002 is specifically configured to, if the small model is a target detection model, expand the length and width of the target area in the target image by a preset multiple; and determine the expanded area as the extended target area.
[0143] In a possible implementation, the processing module 1002 is also used to obtain a preset number of sample images; for each sample image, the sample image is processed using the image language pre-trained model BLIP2 and the chat generation pre-trained transformer ChatGPT API to determine the sample description text corresponding to the sample image; and the multimodal large model is fine-tuned according to each sample image and the corresponding sample description text.
[0144] In a possible implementation, the processing module 1002 is specifically used to train the multimodal large model using each sample image and the corresponding sample description text, and calculate a loss value; adjust the parameter values of the pre-configured model parameters for fine-tuning according to the loss value to obtain target model parameters; and merge the target model parameters with the original model parameters of the multimodal large model to obtain a fine-tuned multimodal large model.
[0145] In a possible implementation, the processing module 1002 is specifically used to use the BLIP2 to identify the sample image and determine the initial global description text corresponding to the sample image; use the target detection model to perform target detection on the sample image, and determine the first sample sub-image according to the first coordinate information output by the target detection model, use the BLIP2 to identify the first sample sub-image, and determine the first sub-description text corresponding to the first sample sub-image; use the image segmentation model to perform image segmentation on the sample image, and determine the second sample sub-image according to the second coordinate information output by the image segmentation model, use the BLIP2 to identify the second sample sub-image, and determine the second sub-description text corresponding to the second sample sub-image; input the sample image, the initial global description text, the first sample sub-image, the first sub-description text, the second sample sub-image and the second sub-description text into the ChatGPT API to determine the sample description text corresponding to the sample image.
[0146] In a possible implementation, the processing module 1002 is further configured to receive an image recognition request carrying the identifiers of the target image and the small model; and determine the small model according to the identifier of the small model.
[0147] Based on the above embodiments, the present application also provides an electronic device, Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, it includes: a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102, and the memory 1103 communicate with each other through the communication bus 1104;
[0148] The memory 1103 stores a computer program. When the program is executed by the processor 1101, the processor 1101 executes the steps of the interface generation method provided in the above embodiments.
[0149] Since the principle of solving the problem by the above electronic device is similar to the recognition method based on the multimodal large model, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0150] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 1102 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0151] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0152] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program executable by a processor. When the program runs on the processor, the processor implements the steps of the recognition method based on the multimodal large model provided in the above embodiments.
[0153] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the interface generation method, the implementation of the above-mentioned computer-readable storage medium can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0154] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0155] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0156] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0157] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0158] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A recognition method based on a multimodal large model, characterized in that: The method comprises: Use a small model to identify key areas of the target image to be identified and determine the coordinate information corresponding to the key areas; Determining, in the target image, a target sub-image corresponding to the key area according to the coordinate information; According to the multimodal large model and the target sub-image, a recognition result corresponding to the target sub-image is determined.
2. The method according to claim 1, characterized in that Determining the target sub-image corresponding to the key area in the target image according to the coordinate information includes: According to the coordinate information, determining a target area corresponding to the coordinate information in the target image; The target area is expanded according to a pre-configured expansion rule, and the target image is cut according to the expanded target area to determine the target sub-image.
3. The method according to claim 2, characterized in that After determining, in the target image, a target area corresponding to the coordinate information according to the coordinate information, and before expanding the target area according to a preconfigured expansion rule, the method further includes: Mask processing is performed on other areas of the target image except the target area.
4. The method according to claim 2 or 3, characterized in that: If the small model is an image segmentation model, the step of expanding the target area according to a preconfigured expansion rule includes: In the target image, determining a minimum bounding rectangle corresponding to the target area; The area corresponding to the minimum circumscribed rectangle is determined as the expanded target area.
5. The method according to claim 2 or 3, characterized in that: If the small model is a target detection model, the step of expanding the target area according to a preconfigured expansion rule includes: In the target image, the length and width of the target area are enlarged by a preset multiple; The enlarged area is determined as the expanded target area.
6. The method according to claim 1, characterized in that Before determining the recognition result corresponding to the target sub-image according to the multimodal large model and the target sub-image, the method further includes: Obtain a preset number of sample images; For each sample image, the image language pre-training model BLIP2 and the chat generation pre-training transformer ChatGPTAPI are used to process the sample image to determine the sample description text corresponding to the sample image; The multimodal large model is fine-tuned according to each sample image and the corresponding sample description text.
7. The method according to claim 6, characterized in that The fine-tuning of the multimodal large model according to each sample image and the corresponding sample description text comprises: Using each sample image and the corresponding sample description text to train the multimodal large model, and calculating the loss value; Adjusting the parameter values of the pre-configured model parameters for fine-tuning according to the loss value to obtain the target model parameters; The target model parameters are merged with the original model parameters of the multimodal large model to obtain a fine-tuned multimodal large model.
8. The method according to claim 5, characterized in that The sample image is processed by using the image language pre-training model BLIP2 and the chat generation pre-training transformer ChatGPT API to determine the sample description text corresponding to the sample image, including: Using the BLIP2 to identify the sample image, and determining the initial global description text corresponding to the sample image; Performing target detection on the sample image using a target detection model, and determining a first sample sub-image according to first coordinate information output by the target detection model, and recognizing the first sample sub-image using the BLIP2 to determine a first sub-description text corresponding to the first sample sub-image; Performing image segmentation on the sample image using an image segmentation model, and determining a second sample sub-image according to second coordinate information output by the image segmentation model, and recognizing the second sample sub-image using the BLIP2 to determine a second sub-description text corresponding to the second sample sub-image; The sample image, the initial global description text, the first sample sub-image, the first sub-description text, the second sample sub-image and the second sub-description text are input into the ChatGPT API to determine the sample description text corresponding to the sample image.
9. The method according to claim 1, characterized in that: The process of determining the small model includes: Receiving an image recognition request carrying the identifiers of the target image and the small model; The small model is determined according to the identifier of the small model.
10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the steps of the multimodal large model-based recognition method as claimed in any one of claims 1 to 9 when executing a computer program stored in a memory.
Citation Information
Cited By
Digital human question and answer method and device, electronic equipment and storage medium
CN119474320A
Multi-modal small target detection method and device and electronic equipment
CN120451487A
Container information identification method and device
CN120747937A
Model deployment method, end-side device, and storage medium
WO2025232128A1
