Image processing method, device, equipment, storage medium and computer program product
By performing block processing and model adjustment on the image, the problem of poor flexibility of traditional image scaling methods is solved, and efficient display of images under different screen resolutions is achieved.
Patent Information
- Application Number
- CN202111443171.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-11-30
AI Technical Summary
Traditional image scaling methods have poor flexibility, resulting in poor image display effects at different screen resolutions.
By dividing the initial image into blocks, the trained resolution recognition model and image scoring model are used to adaptively adjust the resolution range of each image block to generate a target image that matches the target screen resolution.
Improved the display effect of images under different screen resolutions to ensure that the image matches the screen while improving the display quality.
Smart Images

Figure CN114219808B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence image recognition technology, and in particular to an image processing method, apparatus, device, storage medium and computer program product. Background Art
[0002] With the development of computer equipment, in order to facilitate users to understand images, it is often necessary to display images on the screen, for example, business data can be displayed on the screen in the form of text descriptions and charts to facilitate users to understand business-related situations.
[0003] In conventional technology, different screens have different resolutions, so when displaying images, the content to be displayed can be reduced or enlarged according to the resolution of the screen. For example, the resolution of the entire image is multiplied by a preset ratio to obtain the scaled resolution, and the image is adjusted to the scaled resolution before being displayed on the screen. However, the scaling method in conventional technology has the following technical problems: this scaling method is relatively inflexible, and some content in the image does not match the screen after scaling, resulting in poor display of the image. Summary of the invention
[0004] Based on this, it is necessary to provide an image processing method, device, equipment, computer-readable storage medium and computer program product to address the above technical problems.
[0005] In a first aspect, the present application provides an image processing method. The method comprises: determining an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of the screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain a resolution range corresponding to each of the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image blocks and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0006] In one embodiment, the processing of the initial image based on the resolution range corresponding to the initial image block and the target screen resolution and using the processed target image as an image adapted to the target screen resolution includes: obtaining a plurality of candidate image processing schemes based on the resolution range corresponding to the initial image block and the target screen resolution; the candidate image processing schemes include adjustment resolutions corresponding to each of the initial image blocks; processing the initial image based on the candidate image processing schemes to obtain candidate processed images corresponding to the candidate processing schemes; inputting the candidate processed images into a trained image scoring model for scoring to obtain image scores corresponding to each of the candidate processed images; and selecting candidate processed images that meet scoring conditions as target images based on the image scores.
[0007] In one embodiment, the training steps of the image scoring model include: acquiring a real image and a generated image; inputting the real image into the image scoring model to be trained for scoring, and obtaining a first image score corresponding to the real image; inputting the generated image into the image scoring model to be trained for scoring, and obtaining a second image score corresponding to the generated image; obtaining a scoring model loss value based on the first image score and the second image score, the scoring model loss value being negatively correlated with the first image score, and the scoring model loss value being positively correlated with the second image score; adjusting the model parameters of the image scoring model to be trained based on the scoring model loss value, and obtaining a trained image scoring model.
[0008] In one embodiment, the scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold.
[0009] In one embodiment, the training steps of the resolution recognition model include: obtaining a training image and a label image corresponding to the training image; dividing the label image into blocks based on the resolution of the label image to obtain a plurality of label image blocks; obtaining a training image block corresponding to the label image block in the training image; inputting the training image block into the resolution recognition model to be trained for processing to obtain a predicted resolution range corresponding to the training image block; determining a resolution model loss value based on the predicted resolution range corresponding to the training image block and the resolution range corresponding to the label image block; and adjusting parameters of the resolution recognition model to be trained based on the resolution model loss value to obtain a trained resolution recognition model.
[0010] In one embodiment, the block processing of the initial image to obtain multiple initial image blocks includes: performing object recognition on the initial image to obtain a display object contained in the initial image; and block processing of the initial image based on the display object to obtain multiple initial image blocks.
[0011] In the second aspect, the present application also provides an image processing device. The device includes: a resolution and image acquisition module, which is used to determine the initial image to be processed and the target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of the screen displaying the initial image; a block processing module, which is used to perform block processing on the initial image to obtain multiple initial image blocks; a resolution range acquisition module, which is used to input the initial image blocks into a trained resolution recognition model for processing to obtain the resolution ranges corresponding to each of the initial image blocks; and a target image acquisition module, which is used to process the initial image based on the resolution range corresponding to the initial image blocks and the target screen resolution, and use the processed target image as an image adapted to the target screen resolution.
[0012] In one embodiment, the target image acquisition module is used to: obtain multiple candidate image processing schemes based on the resolution range of the initial image block pair and the target screen resolution; the candidate image processing schemes include adjusted resolutions corresponding to each of the initial image blocks; process the initial image based on the candidate image processing schemes to obtain candidate processed images corresponding to the candidate processing schemes; input the candidate processed images into a trained image scoring model for scoring to obtain image scores corresponding to each of the candidate processed images; and select candidate processed images that meet the scoring conditions as target images based on the image scores.
[0013] In one embodiment, the training step module of the image scoring model is used to: obtain a real image and a generated image; input the real image into the image scoring model to be trained for scoring, and obtain a first image score corresponding to the real image; input the generated image into the image scoring model to be trained for scoring, and obtain a second image score corresponding to the generated image; obtain a scoring model loss value based on the first image score and the second image score, the scoring model loss value is negatively correlated with the first image score, and the scoring model loss value is positively correlated with the second image score; adjust the model parameters of the image scoring model to be trained based on the scoring model loss value to obtain a trained image scoring model.
[0014] In one embodiment, the scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold.
[0015] In one embodiment, the training module of the resolution recognition model is used to: obtain a training image and a label image corresponding to the training image; divide the label image into blocks based on the resolution of the label image to obtain a plurality of label image blocks; obtain a training image block corresponding to the label image block in the training image; input the training image block into the resolution recognition model to be trained for processing to obtain a predicted resolution range corresponding to the training image block; determine a resolution model loss value based on the predicted resolution range corresponding to the training image block and the resolution range corresponding to the label image block; and adjust parameters of the resolution recognition model to be trained based on the resolution model loss value to obtain a trained resolution recognition model.
[0016] In one embodiment, the block processing module is used to: perform object recognition on the initial image to obtain a display object contained in the initial image; and perform block processing on the initial image based on the display object to obtain a plurality of initial image blocks.
[0017] In a third aspect, the present application also provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program: determining an initial image to be processed and a target screen resolution corresponding to the initial image, the target screen resolution being the resolution of the screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain a resolution range corresponding to each of the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0018] In a fourth aspect, the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented: determining an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of the screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain a resolution range corresponding to each of the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0019] In a fifth aspect, the present application also provides a computer program product. The computer program product includes a computer program, which implements the following steps when executed by a processor: determining an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of the screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain a resolution range corresponding to each initial image block; processing the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0020] The above-mentioned image processing method, apparatus, computer equipment, storage medium and computer program product have the following technical effects: since the initial image can be divided into blocks to obtain multiple image blocks, and the resolution range corresponding to each initial image block is determined based on the model, the different image blocks of the initial image can be adaptively processed according to the resolution range, so that the processed target image is adapted to the screen resolution and can improve the display effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A diagram showing an application environment of an image processing method in an embodiment;
[0022] Figure 2 is a schematic flow chart of an image processing method in one embodiment;
[0023] Figure 3 is an exemplary schematic diagram of dividing an initial image into multiple image blocks in one embodiment;
[0024] Figure 4 A schematic diagram of a process of processing an initial image based on a resolution range corresponding to an initial image block and a target screen resolution, and using the processed target image as an image adapted to the target screen resolution, in one embodiment;
[0025] Figure 5 A schematic diagram of a flow chart of the training steps of an image scoring model in one embodiment;
[0026] Figure 6 is a structural block diagram of an image processing device in one embodiment;
[0027] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] The image processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 can send the initial image to be displayed to the server 104. The server 104 can obtain the screen resolution of these display devices according to which display devices the initial image is to be displayed on, as the target screen resolution, execute the method of the embodiment of the present application, obtain the target image adapted for each target screen resolution, and send the target image to the corresponding display device for display. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0030] In one embodiment, the server 104 may also pre-store a plurality of different target screen resolutions, that is, the server 104 may pre-generate target images corresponding to different target screen resolutions, and store the corresponding relationship between the image and the target screen resolution. In this way, when the image is to be displayed on a certain display device, the server 104 may obtain the screen resolution corresponding to the display device, and select a target image adapted to the screen resolution of the display device based on the pre-stored corresponding relationship.
[0031] In one embodiment, the image processing method provided in the embodiment of the present application may be executed by a display device.
[0032] In one embodiment, Figure 2 As shown, an image processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0033] Step S202: determining an initial image to be processed and a target screen resolution corresponding to the initial image.
[0034] Among them, the initial image can be an image used to display business data, and the initial image can include different types of content such as charts, characters, and text. The target screen resolution is the resolution of the screen that displays the initial image. The target screen resolution can be pre-set or the screen resolution of the device to be displayed. The screen resolution refers to the number of pixels displayed on the screen. For example, if the screen resolution is 800*1600, it means that there are 800 pixels in the horizontal direction and 1600 pixels in the vertical direction. There can be multiple target screen resolutions, and the content provided in the embodiments of the present application can be executed for each target screen resolution.
[0035] In the embodiment of the present application, the server may respond to the image processing instruction, obtain the initial image to be processed indicated by the image processing instruction, and obtain the preset target screen resolution.
[0036] Step S204, dividing the initial image into blocks to obtain a plurality of initial image blocks.
[0037] Blocking is the process of dividing an image. The division method can be based on the blank area of the image, the type of content displayed in the image, or the initial image can be input into an image segmentation model for division. For example, if an image displays business data through different charts and there are blank areas between the charts, the dividing line can be selected on the blank area to divide the image into multiple image blocks, where "multiple" means at least two.
[0038] In the embodiment of the present application, the server obtains the initial image, analyzes the initial image, determines the division method of the initial image, and divides the image based on the division method to obtain multiple initial image blocks. Figure 3 As shown, an image can be divided into 4 image blocks.
[0039] Step S206: input the initial image blocks into the trained resolution recognition model for processing to obtain the resolution ranges corresponding to the initial image blocks.
[0040] The larger the resolution, the more important the content in the image block. The resolution recognition model is used to identify the resolution range of an image block in the image in which it is located. There are multiple resolutions to choose from within a resolution range. The resolution recognition model determines the resolution range corresponding to each initial image block.
[0041] In the embodiment of the present application, the server can input the initial image blocks obtained by dividing an initial image into a resolution recognition model to obtain the resolution range corresponding to each initial image block. The resolution recognition model can be a model corresponding to the target screen resolution.
[0042] In one embodiment, the resolution recognition model is an artificial intelligence model obtained by pre-training. When training the model, the training image and the corresponding image label can be obtained. The image label includes the resolution corresponding to each training image block in the training image. The resolution corresponding to the training image block is determined based on the value corresponding to the training image block. The greater the value, the greater the resolution. For example, the resolution corresponding to the training image block is determined manually based on the value of the training image block in the training image. For another example, an image pair can be obtained, the image pair includes a training image and a label image corresponding to the training image. The label image can be an image with a good display effect on a display device corresponding to the target screen resolution after the training image is manually adjusted. The resolution of the label image is less than or equal to the target screen resolution. The server can obtain the resolution of the label image on each image block as the resolution corresponding to the training image block in the image label. The training image can be input into the resolution recognition model to be trained for resolution recognition, and the resolution range to which the predicted training image block belongs is obtained, and the resolution range corresponding to the training image block in the image label is determined. The smaller the difference between the predicted resolution range and the actual corresponding resolution range in the image label, the smaller the model loss value. For example, the corresponding relationship between the difference and the loss value can be preset. Assuming that the difference is 1 range, the loss value is ab, and the difference is 2 ranges, the loss value is a. Both a and b are positive numbers. The server can adjust the model parameters of the resolution recognition model to be trained in the direction of reducing the model loss value to obtain a trained resolution recognition model.
[0043] Step S208: Process the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and use the processed target image as an image adapted to the target screen resolution.
[0044] The resolution of an image refers to the number of pixels in an image block. The resolution of the target image is less than or equal to the target screen resolution, that is, in both the horizontal and vertical directions, the number of pixels of the target image is less than or equal to the number of pixels corresponding to the target screen resolution.
[0045] In the embodiment of the present application, the server may select one of the resolutions from the resolution range corresponding to the initial image block, and adjust the resolution of the initial image block to a resolution matching the selected resolution. The adjusted image blocks are then combined according to their positions in the initial image to obtain the target image.
[0046] In one embodiment, the resolution range output by the model may include a range of the number of pixels in the horizontal direction and a range of the number of pixels in the vertical direction. When selecting the resolution therefrom, the selection may be made based on the ratio of the number of pixels in the horizontal direction to the number of pixels in the vertical direction in the initial image block, so that the ratio of the number of pixels selected in the horizontal direction to the number of pixels in the vertical direction is close to the difference of the original ratio of the number of pixels in the initial image block, and the condition of being close may be less than a threshold. For example, assuming that there are 400 pixels in the horizontal direction and 800 pixels in the vertical direction on the initial image block, the ratio of the number of pixels in the horizontal direction to the number of pixels in the vertical direction is 1:2. When selecting the resolution from the resolution range output by the model, the closer the ratio of the number of pixels selected in the horizontal direction to the number of pixels in the vertical direction is to 1:2, the better. For example, the difference from 1:2 may be less than 0.01.
[0047] In the above-mentioned image processing method, since the initial image can be divided into blocks to obtain multiple image blocks, and the resolution range corresponding to each initial image block is determined based on the model, the different image blocks of the initial image can be adaptively processed according to the resolution range, so that the processed target image is adapted to the screen resolution and can improve the display effect.
[0048] In one embodiment, Figure 4 As shown, the initial image is processed based on the resolution range corresponding to the initial image block and the target screen resolution, and the processed target image is used as an image adapted to the target screen resolution, including:
[0049] Step S402 , obtaining a plurality of candidate image processing solutions based on the resolution range corresponding to the initial image block and the target screen resolution; the candidate image processing solutions include adjustment resolutions corresponding to the respective initial image blocks.
[0050] Among them, a candidate processing scheme includes the adjusted resolution of each initial image block in the initial image, referred to as adjusted resolution. The resolution of the target image obtained by processing the initial image based on the candidate processing scheme is less than or equal to the screen resolution. That is, the adjusted resolution of each initial image block in a candidate image processing scheme is added, and the sum of the obtained resolutions is less than the screen resolution. It can be understood that when the resolutions are added, the sum of the number of pixels corresponding to different directions is less than the number of pixels in the direction corresponding to the screen resolution. For example, assuming the screen resolution is 800*1600, it means that the number of pixels in the horizontal direction of the screen is 800, and the number of pixels in the vertical direction is 1600. Assuming that Figure 3As shown, the initial image is evenly divided into 4 image blocks: A, B, C and D. Then, in each candidate processing scheme, the sum of the number of pixels of A and B in the horizontal direction, or the sum of the number of pixels of C and D in the horizontal direction, is less than 800. The sum of the number of pixels of A and C in the vertical direction, or the sum of the number of pixels of B and D in the vertical direction, is less than 1600.
[0051] In the embodiment of the present application, when forming a solution, the server can select a resolution from the resolution range corresponding to each initial image block. The server can obtain multiple solutions, for example, 100 solutions, and then discard the solutions whose resolution is greater than the screen resolution, and use the remaining solutions as candidate processing solutions.
[0052] In one embodiment, the resolution range output by the model may include a range of the number of pixels in the horizontal direction and a range of the number of pixels in the vertical direction. When selecting a candidate processing scheme therefrom, the selection may be made based on the ratio of the number of pixels in the horizontal direction to the number of pixels in the vertical direction in the initial image block, so that the ratio of the number of pixels selected in the horizontal direction to the number of pixels in the vertical direction is close to the difference in the original ratio of the number of pixels in the initial image block, and the condition of being close may be less than a threshold. For example, assuming that there are 400 pixels in the horizontal direction and 800 pixels in the vertical direction on the initial image block, the ratio of the number of pixels in the horizontal direction to the number of pixels in the vertical direction is 1:2. When selecting a resolution from the resolution range output by the model, the closer the ratio of the number of pixels selected in the horizontal direction to the number of pixels in the vertical direction is to 1:2, the better. For example, the difference from 1:2 may be less than 0.01.
[0053] Step S404: Process the initial image based on the candidate image processing scheme to obtain a candidate processed image corresponding to the candidate processing scheme.
[0054] For example, the initial image is divided into four image blocks: A, B, C and D. One of the candidate processing schemes is that the resolution corresponding to A is 100*200, the resolution corresponding to B is 300*400, the resolution corresponding to C is 100*300, and the resolution corresponding to D is 200*200. If the original resolution of A is greater than 100*200, A is compressed so that its resolution is 100*200. Similarly, B, C and D can also be processed. The processed A, B, C and D are combined into the candidate processed image corresponding to the candidate processing scheme.
[0055] Step S406: input the candidate processed images into the image scoring model for scoring, and obtain the image score corresponding to each candidate processed image.
[0056] The image scoring model can be an artificial intelligence model for judging the display quality of an image or a strategy for manually determining the display quality. The higher the score, the better the quality. For example, the image scoring model is an artificial intelligence model for judging whether the image is real. The scoring model can be, for example, a discriminant model in a generative adversarial model. The discriminant model can be used to determine whether the image is naturally taken or synthesized by a machine based on an algorithm. If the strategy for judging the display quality is manually determined, the strategy can be to determine the ratio of the number of pixels in the horizontal direction and the vertical direction of each image block in the candidate processed image, and the difference with the pixel ratio of the image block on the initial image. If the difference is smaller, the higher the score.
[0057] In an embodiment of the present application, the candidate processed images are respectively input into an image scoring model for processing, and the image scoring model performs a quality score on the candidate processed images to obtain an image score corresponding to the candidate processed images.
[0058] Step S408: selecting a candidate processed image that meets the scoring conditions based on the image scores as the target image.
[0059] In the embodiment of the present application, the candidate processed image can be selected based on the scoring condition only, or in combination with other conditions, such as in combination with the resolution condition. The server can select the candidate processed image that meets the scoring condition and the resolution condition as the target image. The resolution condition can be, for example, a resolution sort after a preset sort, in which the resolution is sorted from large to small, so that the resolution of the obtained target image is as small as possible.
[0060] In one embodiment, the scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold. For example, the image with the largest image score among all candidate processing images is used as the target image. The ranking threshold and the scoring threshold can be set as needed. For example, the ranking threshold can be 2, and the scoring threshold can be 80. The image scores are sorted in order from large to small. That is, the higher the score, the higher the ranking.
[0061] In one embodiment, each candidate processed image may be sent to a terminal, and the terminal receives the user's selection operation, and uses the candidate processed image selected by the user as the target image adapted to the target screen resolution. That is, multiple candidate processing schemes may be formed, and processed images corresponding to the candidate processing schemes may be obtained, and then manually selected. Since the resolution in the candidate processing scheme is within the resolution range identified by the resolution model, the candidate processing schemes are relatively few and more suitable, so the efficiency of manual selection can be improved, and a suitable image can be selected.
[0062] In the embodiment of the present application, the resolution of the image block is selected according to the resolution range to form a candidate processing scheme, and then the content scoring model is used for scoring. Since the resolution range is obtained by the trained resolution recognition model, the accuracy is relatively high but it does not completely limit the choice of resolution. The image whose quality meets the requirements is selected through the scoring of the image scoring model, so that the target image is adapted to the target screen resolution while also improving the display quality of the image.
[0063] The artificial intelligence model can be obtained through supervised training. In one embodiment, Figure 5 As shown, the training steps of the image scoring model include:
[0064] Step S502, obtaining a real image and generating an image.
[0065] The generated image refers to an image generated by an artificial intelligence model, such as an image generated by an image generation model. The real image is not generated by an artificial intelligence model, such as an image obtained by photography. When displayed on a display device corresponding to the target screen resolution, the quality of the real image is better than the quality of the generated image. The real image and the generated image can be pre-set, for example, they can be selected manually.
[0066] Step S504: input the real image into the image scoring model to be trained for scoring, and obtain a first image score corresponding to the real image.
[0067] The image scoring model is, for example, a discriminant model in a generative adversarial model, and the discriminant value of the image output by the discriminant model as a true image is used as the first image score corresponding to the true image. The higher the discriminant value, the higher the possibility that the image is true.
[0068] Step S506: input the generated image into the image scoring model to be trained for scoring, and obtain a second image score corresponding to the generated image.
[0069] The discriminant value of the image output by the discriminant model as a real image is used as the score of the second image corresponding to the generated image. The higher the discriminant value, the higher the possibility that it is a real image. The lower the discriminant value, the higher the possibility that it is a real image.
[0070] Step S508, obtaining a scoring model loss value based on the first image score and the second image score.
[0071] The model loss value is negatively correlated with the first image score. That is, the higher the first image score, the better the model's ability to identify the real image as the real image, so the smaller the model loss value. The model loss value is positively correlated with the second image score. That is, the higher the second image score, the more likely the model will mistake the generated image for the real image, the worse the recognition ability, so the larger the model loss value.
[0072] The model loss value may be calculated using a cross entropy loss value calculation method. The server may obtain a first loss value based on the first image score, obtain a second loss value based on the second image score, and add the first loss value to the second loss value to obtain a scoring model loss value.
[0073] Step S510, adjusting the model parameters of the image scoring model to be trained based on the scoring model loss value to obtain a trained image scoring model.
[0074] In an embodiment of the present application, the model parameters can be adjusted in the direction of reducing the model loss value so that the scoring ability of the model becomes higher and higher, wherein the model parameters can be adjusted multiple times, for example, when the number of training times reaches a threshold or the model loss value is less than a threshold, the training is stopped to obtain a trained image scoring model with high accuracy.
[0075] In the embodiment of the present application, since the image scoring model is trained based on real images and generated images, the trained image scoring model has a good ability to identify whether an image is a real image or a generated image, so it is able to select a candidate processed image with better quality as the target image, thereby improving the display effect of the target image.
[0076] In some embodiments, the training steps of the resolution recognition model include: obtaining a training image and obtaining a label image corresponding to the training image; dividing the label image into blocks based on the resolution of the label image to obtain multiple label image blocks; obtaining training image blocks corresponding to the label image blocks in the training image; inputting the training image blocks into the resolution recognition model to be trained for processing to obtain a predicted resolution range corresponding to the training image blocks; determining a resolution model loss value based on the predicted resolution range corresponding to the training image blocks and the resolution range corresponding to the label image blocks; and adjusting parameters of the resolution recognition model to be trained based on the resolution model loss value to obtain a trained resolution recognition model.
[0077] The label image and the training image have the same image content but different resolutions. The label image is adapted to the target screen resolution, while the training image is not. The resolutions of different image blocks in the label image may be different. The server can divide the label image into blocks based on the resolution of the label image, so that in the divided label image blocks, at least two image blocks have different resolutions. It can be understood that the image area corresponding to an image block is continuous.
[0078] The training images are divided according to the division method of the label image blocks, so that the label image blocks and the training image blocks have a one-to-one correspondence, and the corresponding positions and image contents between the corresponding image blocks are the same.
[0079] The predicted resolution range is identified based on the current model parameters of the resolution recognition model. The resolution model loss value can be determined based on the difference between the predicted resolution range and the resolution range corresponding to the label image block, wherein the greater the difference, the greater the loss value. For example, a loss value corresponding to each difference can be set, for example, if the difference is one range, the loss value is c, and if the difference is two ranges, the loss value is c+d, where c and d are both positive numbers. The server can adjust the parameters of the resolution recognition model in the direction of reducing the loss value, and use the adjusted model as the trained resolution recognition model. It can be understood that the model can be obtained after multiple trainings.
[0080] In the embodiment of the present application, since the model loss value is determined based on the label image of the training image during training, through multiple trainings, the resolution range output by the trained model can be made smaller than the resolution range of the label image, and the label image is adapted to the target screen resolution. Therefore, the resolution range recognized by the resolution recognition model matches the target screen resolution, thereby improving the recognition ability of the resolution recognition model.
[0081] In one embodiment, dividing the initial image into blocks to obtain a plurality of initial image blocks includes: performing object recognition on the initial image to obtain a display object contained in the initial image; dividing the initial image into blocks based on the display object to obtain a plurality of initial image blocks.
[0082] The display object in the initial image is a complete display unit, such as a table, a person, or a trend chart. When performing block processing, the blocks are divided based on the display object so that each initial image block contains a complete object, for example, one initial image block corresponds to one display object. For example, assuming that there is a table and a portrait in the image, it is divided into two image blocks: an image block including the table and an image block including the portrait. Since the initial image is divided into blocks according to the display object, the resolution of the image can be determined based on the display object as the dimension, and the value contained in a display object is consistent, thereby improving the display effect.
[0083] In one embodiment, the display objects may be divided according to the display purpose into display objects corresponding to the display purpose and display objects corresponding to non-display purposes. For example, if there is only one person in a picture, and the display purpose of the picture is to show the change of expression, the display objects include two: a face display object and a non-face display object.
[0084] With the development of technology, data visualization large screens have become a very popular demand, but a very important problem with data large screens is screen adaptation. The method provided in the embodiment of the present application can adaptively select corresponding images for display based on the resolution of the large screen. For example, the resolution corresponding to each large screen can be obtained in advance, and the image to be displayed on the large screen can be obtained. Generally speaking, the resolution of the image is higher than the resolution of the screen. Therefore, different resolution ranges can be assigned to different contents in the image, so that the final target image can be adapted to the resolution corresponding to the large screen and is an image with a relatively small resolution.
[0085] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0086] Based on the same inventive concept, the embodiment of the present application also provides an image processing device for implementing the above-mentioned image processing method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image processing device embodiments provided below can refer to the limitations on the image processing method above, and will not be repeated here.
[0087] In one embodiment, Figure 6 As shown, an image processing device is provided, comprising:
[0088] A resolution and image acquisition module 602 is used to determine an initial image to be processed and a target screen resolution corresponding to the initial image, where the target screen resolution is the resolution of the screen displaying the initial image;
[0089] A block processing module 604 is used to perform block processing on the initial image to obtain multiple initial image blocks;
[0090] A resolution range obtaining module 606 is used to input the initial image blocks into the trained resolution recognition model for processing to obtain the resolution ranges corresponding to the initial image blocks;
[0091] The target image obtaining module 608 is used to process the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and use the processed target image as an image adapted to the target screen resolution.
[0092] In one embodiment, the target image acquisition module is used to: obtain multiple candidate image processing schemes based on the resolution range of the initial image block pair and the target screen resolution; the candidate image processing schemes include adjusted resolutions corresponding to each initial image block; the initial image is processed based on the candidate image processing schemes to obtain candidate processed images corresponding to the candidate processing schemes; the candidate processed images are input into a trained image scoring model for scoring to obtain image scores corresponding to each candidate processed image; and the candidate processed images that meet the scoring conditions are selected as the target images based on the image scores.
[0093] In one embodiment, the training step module of the image scoring model is used to: obtain a real image and a generated image; input the real image into the image scoring model to be trained for scoring, and obtain a first image score corresponding to the real image; input the generated image into the image scoring model to be trained for scoring, and obtain a second image score corresponding to the generated image; obtain a scoring model loss value based on the first image score and the second image score, the scoring model loss value is negatively correlated with the first image score, and the scoring model loss value is positively correlated with the second image score; adjust the model parameters of the image scoring model to be trained based on the scoring model loss value to obtain a trained image scoring model.
[0094] In one embodiment, the scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold.
[0095] In one embodiment, the training module of the resolution recognition model is used to: obtain a training image and a label image corresponding to the training image; divide the label image into blocks based on the resolution of the label image to obtain multiple label image blocks; obtain training image blocks corresponding to the label image blocks in the training image; input the training image blocks into the resolution recognition model to be trained for processing to obtain a predicted resolution range corresponding to the training image blocks; determine a resolution model loss value based on the predicted resolution range corresponding to the training image blocks and the resolution range corresponding to the label image blocks; adjust the parameters of the resolution recognition model to be trained based on the resolution model loss value to obtain a trained resolution recognition model.
[0096] In one embodiment, the block processing module is used to: perform object recognition on the initial image to obtain the display object contained in the initial image; and perform block processing on the initial image based on the display object to obtain multiple initial image blocks.
[0097] Each module in the above image processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0098] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store resolution data and image data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an image processing method is implemented.
[0099] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0100] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: determining an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of a screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain resolution ranges corresponding to the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image blocks and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0101] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: determining an initial image to be processed and a target screen resolution corresponding to the initial image, the target screen resolution being the resolution of a screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain resolution ranges corresponding to the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image blocks and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0102] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: determining an initial image to be processed and a target screen resolution corresponding to the initial image, the target screen resolution being the resolution of a screen displaying the initial image; processing the initial image in blocks to obtain a plurality of initial image blocks; inputting the initial image blocks into a trained resolution recognition model for processing to obtain resolution ranges corresponding to the initial image blocks; processing the initial image based on the resolution range corresponding to the initial image blocks and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution.
[0103] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0104] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0105] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0106] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An image processing method, characterized in that: The method comprises: Determine an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is a resolution of a screen displaying the initial image; Performing block processing on the initial image to obtain a plurality of initial image blocks; Inputting the initial image blocks into a trained resolution recognition model for processing to obtain resolution ranges corresponding to the initial image blocks; Processing the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution; The processing of the initial image based on the resolution range corresponding to the initial image block and the target screen resolution, and using the processed target image as an image adapted to the target screen resolution includes: Based on the resolution range corresponding to the initial image block and the target screen resolution, a plurality of candidate image processing schemes are obtained; the candidate image processing schemes include adjustment resolutions corresponding to each of the initial image blocks; Processing the initial image based on the candidate image processing scheme to obtain a candidate processed image corresponding to the candidate image processing scheme; Inputting the candidate processed images into a trained image scoring model for scoring, and obtaining image scores corresponding to each of the candidate processed images; Based on the image scores, a candidate processed image that meets the scoring conditions is selected as a target image.
2. The method according to claim 1, characterized in that The training steps of the image scoring model include: Get real images and generate images; Inputting the real image into the image scoring model to be trained for scoring, and obtaining a first image score corresponding to the real image; Inputting the generated image into the image scoring model to be trained for scoring, and obtaining a second image score corresponding to the generated image; Obtaining a scoring model loss value based on the first image score and the second image score, wherein the scoring model loss value is negatively correlated with the first image score, and the scoring model loss value is positively correlated with the second image score; The model parameters of the image scoring model to be trained are adjusted based on the scoring model loss value to obtain a trained image scoring model.
3. The method according to claim 1, characterized in that The scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold.
4. The method according to claim 1, characterized in that The training steps of the resolution recognition model include: Acquire a training image, and acquire a label image corresponding to the training image; Dividing the label image into blocks based on the resolution of the label image to obtain a plurality of label image blocks; Obtaining a training image block corresponding to the label image block in the training image; Inputting the training image block into a resolution recognition model to be trained for processing, and obtaining a predicted resolution range corresponding to the training image block; Determine a resolution model loss value based on a predicted resolution range corresponding to the training image block and a resolution range corresponding to the label image block; The parameters of the resolution recognition model to be trained are adjusted based on the resolution model loss value to obtain a trained resolution recognition model.
5. The method according to claim 1, characterized in that The performing block processing on the initial image to obtain a plurality of initial image blocks comprises: Performing object recognition on the initial image to obtain a display object contained in the initial image; The initial image is divided into blocks based on the display object to obtain a plurality of initial image blocks.
6. An image processing device, characterized in that: The device comprises: A resolution and image acquisition module, used to determine an initial image to be processed and a target screen resolution corresponding to the initial image, wherein the target screen resolution is the resolution of the screen displaying the initial image; A block processing module, used for performing block processing on the initial image to obtain a plurality of initial image blocks; A resolution range obtaining module, used for inputting the initial image blocks into a trained resolution recognition model for processing, to obtain the resolution ranges corresponding to the initial image blocks; a target image obtaining module, configured to process the initial image based on a resolution range corresponding to the initial image block and the target screen resolution, and use the processed target image as an image adapted to the target screen resolution; The target image obtaining module is used for: Based on the resolution range corresponding to the initial image block and the target screen resolution, a plurality of candidate image processing schemes are obtained; the candidate image processing schemes include adjustment resolutions corresponding to each of the initial image blocks; Processing the initial image based on the candidate image processing scheme to obtain a candidate processed image corresponding to the candidate image processing scheme; Inputting the candidate processed images into a trained image scoring model for scoring, and obtaining image scores corresponding to each of the candidate processed images; Based on the image scores, a candidate processed image that meets the scoring conditions is selected as a target image.
7. The device according to claim 6, characterized in that The training step module of the image scoring model is used to: Get real images and generate images; Inputting the real image into the image scoring model to be trained for scoring, and obtaining a first image score corresponding to the real image; Inputting the generated image into the image scoring model to be trained for scoring, and obtaining a second image score corresponding to the generated image; Obtaining a scoring model loss value based on the first image score and the second image score, wherein the scoring model loss value is negatively correlated with the first image score, and the scoring model loss value is positively correlated with the second image score; The model parameters of the image scoring model to be trained are adjusted based on the scoring model loss value to obtain a trained image scoring model.
8. The device according to claim 6, characterized in that The scoring condition includes at least one of the following conditions: the ranking of the image score is before the ranking threshold, or the image score is greater than the scoring threshold.
9. The device according to claim 6, characterized in that The training module of the resolution recognition model is used to: Acquire a training image, and acquire a label image corresponding to the training image; Dividing the label image into blocks based on the resolution of the label image to obtain a plurality of label image blocks; Obtaining a training image block corresponding to the label image block in the training image; Inputting the training image block into a resolution recognition model to be trained for processing, and obtaining a predicted resolution range corresponding to the training image block; Determine a resolution model loss value based on a predicted resolution range corresponding to the training image block and a resolution range corresponding to the label image block; The parameters of the resolution recognition model to be trained are adjusted based on the resolution model loss value to obtain a trained resolution recognition model.
10. The device according to claim 6, characterized in that The block processing module is used for: Performing object recognition on the initial image to obtain a display object contained in the initial image; The initial image is divided into blocks based on the display object to obtain a plurality of initial image blocks.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
