WO2020006962A1 - Method and device for processing picture - Google Patents
Method and device for processing picture Download PDFInfo
- Publication number
- WO2020006962A1 WO2020006962A1 PCT/CN2018/116336 CN2018116336W WO2020006962A1 WO 2020006962 A1 WO2020006962 A1 WO 2020006962A1 CN 2018116336 W CN2018116336 W CN 2018116336W WO 2020006962 A1 WO2020006962 A1 WO 2020006962A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- picture
- processed
- size
- standard size
- sample
- Prior art date
Links
- 238000012545 processing Methods 0.000 title claims abstract description 157
- 238000000034 method Methods 0.000 title claims abstract description 63
- 238000012549 training Methods 0.000 claims description 73
- 238000004590 computer program Methods 0.000 claims description 9
- 238000010801 machine learning Methods 0.000 claims description 7
- 230000006870 function Effects 0.000 description 20
- 238000013528 artificial neural network Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 238000004891 communication Methods 0.000 description 6
- 238000013136 deep learning model Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 238000013527 convolutional neural network Methods 0.000 description 3
- 230000000306 recurrent effect Effects 0.000 description 3
- 238000003062 neural network model Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000010187 selection method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
Definitions
- Embodiments of the present application relate to the field of computer technology, and in particular, to a method and an apparatus for processing a picture.
- some processes using neural network models to process pictures usually first scale the size of the picture to be processed to a standard size, and then process the picture.
- the size of each picture to be processed is generally scaled to the same standard size.
- the embodiments of the present application provide a method and device for processing pictures.
- an embodiment of the present application provides a method for processing a picture.
- the method includes: obtaining a picture to be processed; selecting a standard size corresponding to the picture to be processed from a preset standard size set as a target size; The size of the picture to be processed is adjusted to the target size to obtain the adjusted picture to be processed; the adjusted picture to be processed is input to a pre-trained picture processing model to obtain a processing result.
- selecting the standard size corresponding to the picture to be processed as the target size from the preset standard size set includes: determining the size of the picture to be processed; and from the preset standard size set based on the size of the picture to be processed Select the standard size corresponding to the picture to be processed as the target size.
- selecting a standard size corresponding to the picture to be processed from the preset standard size set as the target size includes: selecting a standard size with the smallest difference from the size of the picture to be processed As the target size.
- the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standard size in the standard size set, the standard size and the The difference in the size of the processed picture is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of pixels to the number of vertical pixels and the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size is used as the difference between the standard size and the size of the picture to be processed.
- selecting a standard size corresponding to a picture to be processed as a target size from a preset standard size set includes: determining content information of the picture to be processed; and according to a pre-established correspondence between the content information and the standard size, A standard size corresponding to the content information with the highest similarity of the content information of the picture to be processed is determined as the target size.
- the image processing model is obtained by training as follows: obtaining a training sample set, wherein the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, selecting a standard size set and The standard size corresponding to the sample picture in the training sample, and the size of the sample picture in the training sample is adjusted to the selected standard size to obtain the adjusted sample picture; using the method of machine learning, the The adjusted sample picture corresponding to the sample picture in the training sample is used as input, and the processing result corresponding to the input adjusted sample picture is used as the desired output, and a picture processing model is trained.
- an embodiment of the present application provides an apparatus for processing a picture.
- the apparatus includes: an obtaining unit configured to obtain a picture to be processed; and a selecting unit configured to select an image from a preset standard size set.
- the standard size corresponding to the picture to be processed is taken as the target size;
- the adjustment unit is configured to adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed;
- the processing unit is configured to input the adjusted picture to be processed To the pre-trained image processing model, get the processing result.
- the above-mentioned selecting unit is further configured to: determine a size of the picture to be processed; and based on the size of the picture to be processed, select a standard size corresponding to the picture to be processed as a target size from a preset standard size set.
- the above-mentioned selecting unit is further configured to: select a standard size having a smallest difference from a size of a picture to be processed as a target size.
- the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standard size in the standard size set, the standard size and the The difference in the size of the processed picture is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of pixels to the number of vertical pixels and the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size is used as the difference between the standard size and the size of the picture to be processed.
- the above-mentioned selecting unit is further configured to: determine content information of the picture to be processed; and determine content information with the highest similarity to the content information of the picture to be processed according to a pre-established correspondence between the content information and a standard size The corresponding standard size is used as the target size.
- the image processing model is obtained by training as follows: obtaining a training sample set, wherein the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, selecting a standard size set and The standard size corresponding to the sample picture in the training sample, and the size of the sample picture in the training sample is adjusted to the selected standard size to obtain the adjusted sample picture; using the method of machine learning, the The adjusted sample picture corresponding to the sample picture in the training sample is used as input, and the processing result corresponding to the input adjusted sample picture is used as the desired output, and a picture processing model is trained.
- an embodiment of the present application provides an electronic device.
- the electronic device includes: one or more processors; a storage device configured to store one or more programs;
- the processor executes such that one or more processors implement the method as described in any implementation of the first aspect.
- an embodiment of the present application provides a computer-readable medium having stored thereon a computer program that, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
- the method and device for processing pictures obtained by the embodiments of the present application obtain a picture to be processed and select a standard size corresponding to the picture to be processed from a preset standard size set as a target size. Then, the size of the picture to be processed is adjusted to the selected target size, and the adjusted picture is input to a pre-trained picture processing model to obtain a processing result, so that the size of the picture to be processed is adjusted by using preset multiple standard sizes. In this case, the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps improve the flexibility of picture size adjustment.
- FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
- FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
- FIG. 2 is a flowchart of an embodiment of a method for processing a picture according to the present application
- FIG. 3 is a flowchart of still another embodiment of a method for processing pictures according to the present application.
- FIG. 4 is a schematic diagram of an application scenario of a method for processing pictures according to the present application.
- FIG. 5 is a schematic structural diagram of an embodiment of an apparatus for processing pictures according to the present application.
- FIG. 6 is a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
- FIG. 1 illustrates an exemplary architecture 100 of an embodiment of a method for processing pictures or an apparatus for processing pictures to which the present application can be applied.
- the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105.
- the network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105.
- the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
- the terminal devices 101, 102, 103 interact with the server 105 through the network 104 to receive or send messages and the like.
- Various client applications can be installed on the terminal devices 101, 102, and 103, such as a web browser application and an image processing application.
- the terminal devices 101, 102, and 103 may be hardware or software.
- the terminal devices 101, 102, and 103 can be various electronic devices capable of processing pictures, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, and desktop computers.
- the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, multiple software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
- the server 105 may be a server that provides various services, for example, a picture processing server that provides analysis processing for pictures to be processed on the terminal devices 101, 102, and 103.
- the picture processing server may perform processing such as resizing the picture to be processed, and generate a processing result, and may also feedback the processing result (such as the picture to be processed after the resizing) to the terminal device.
- the above-mentioned pictures to be processed may also be directly stored locally on the server 105, and the server 105 may directly extract and process the locally stored pictures to be processed.
- the terminal devices 101, 102, 103 and the network may not exist. 104.
- the method for processing pictures provided by the embodiments of the present application is generally executed by the server 105, and accordingly, the apparatus for processing pictures is generally set in the server 105.
- the terminal device 101, 102, 103 may also have an image processing application installed, and the terminal device 101, 102, 103 may also process the image to be processed based on the image processing application. At this time, it is used to process the image
- the method can also be executed by the terminal devices 101, 102, 103, and accordingly, the apparatus for processing pictures can also be set in the terminal devices 101, 102, 103.
- the exemplary system architecture 100 may be absent from the server 105 and the network 104.
- the server may be hardware or software.
- the server can be implemented as a distributed server cluster consisting of multiple servers or as a single server.
- the server can be implemented as multiple software or software modules (for example, multiple software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
- terminal devices, networks, and servers in FIG. 1 are merely exemplary. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
- a flowchart 200 of an embodiment of a method for processing a picture according to the present application is shown.
- the method for processing pictures includes the following steps:
- Step 201 Obtain a picture to be processed.
- the execution subject of the method for processing pictures may be wired or wirelessly from a local or other storage device (such as the terminal devices 101 and 102 shown in FIG. 1). (103) Obtain a picture to be processed.
- the picture to be processed may be any type of picture.
- step 202 a standard size corresponding to a picture to be processed is selected as a target size from a preset standard size set.
- the size may refer to the physical size of the picture, such as the length and width of the picture. Size can also refer to the resolution of the picture. Size can also refer to the size of the picture, such as the storage space occupied by the picture.
- the standard size can be any preset size. According to different application requirements, different standard size sets can be preset.
- the correspondence between the to-be-processed picture and the standard size may be different according to different correspondence logic. Different correspondences can usually use different selection methods to select the standard size from the preset standard size set as the target size.
- the size of the picture to be processed may be determined first, and then based on the determined size of the picture to be processed, a standard size is selected as a target size from a preset standard size set.
- the size of the picture may be divided into several types in advance.
- the size of a picture can be divided into three types: the aspect ratio is greater than 1, the aspect ratio is equal to 1, and the aspect ratio is less than 1.
- a standard size corresponding to that type of size is determined.
- a standard size corresponding to the size of the picture to be processed can be directly selected as a target size from a preset standard size set.
- a large number of pictures of that type can be obtained in advance, and then, for the obtained large number of pictures, the size of these pictures is adjusted to a standard size in a preset standard size set. After the average loss of accuracy. Similarly, an average value of the accuracy loss corresponding to each of the standard sizes in the preset standard size set after adjusting the sizes of these pictures is determined. Then, the standard size corresponding to the average value of the smallest loss of accuracy is selected as the standard size corresponding to the picture of this type.
- the content information of the picture to be processed may be determined first, and then the similarity between the content information of the picture to be processed and the standard size will be similar to the content information of the picture to be processed.
- the standard size corresponding to the highest content information is the target size.
- the content information may be information related to the content of the picture to be processed.
- the content information may be the type of objects included in the picture to be processed, the number of objects included, and the like.
- various existing picture detection or recognition methods may be used to determine content information of a picture to be processed.
- existing deep learning models such as AlexNet, etc.
- AlexNet AlexNet
- some existing picture classification software can also be used, and the subject of the picture to be processed determined by the classification software can be used as the content information of the picture to be processed.
- various existing picture understanding methods (such as image text description based on Multimodal Recurrent Neural Network) can be used to process the picture to be processed, and the obtained text describing the image can be used as content information of the picture to be processed.
- a correspondence table that stores the correspondence between the content information of the picture and the standard size may be established in advance.
- a standard size with an aspect ratio of 5: 3 for a face picture, it may correspond to a standard size with an aspect ratio of 5: 3, and for a car picture, it may correspond to a standard size with an aspect ratio of 3: 1.
- a standard size of 5: 3 can be selected as the target size
- a standard size of 3: 1 can be selected as the target size.
- the standard size corresponding to the picture to be processed can be selected as the target size from the preset standard size set by the following steps:
- the size of the picture to be processed is adjusted to each standard size in the standard size set, so as to obtain the adjusted picture set to be processed.
- the similarity between each adjusted to-be-processed picture and the obtained to-be-processed picture in the adjusted to-be-processed picture set is calculated respectively, so as to obtain a similarity set.
- the maximum similarity is selected from the obtained similarity set, and the standard size corresponding to the selected maximum similarity is used as the target size.
- Step 203 Adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed.
- various applications for processing pictures can be used to adjust the size of the picture to be processed, thereby adjusting the size of the picture to be processed to the selected target size, and obtaining the resized picture to be processed.
- Step 204 Input the adjusted to-be-processed picture into a pre-trained picture processing model to obtain a processing result.
- the picture processing model may be various models capable of processing pictures.
- the picture processing model may be various deep learning models capable of processing pictures.
- the image processing model can also be various convolutional neural networks capable of processing images.
- the processing of pictures can be various processing methods. For example, picture classification, picture recognition, picture denoising, picture restoration, etc.
- the picture processing model can be obtained by training as follows:
- the first step is to obtain a training sample set, where the training sample includes a sample picture and a processing result of the sample picture.
- a standard size corresponding to the sample picture in the training sample is selected from the standard size set, and the size of the sample picture in the training sample is adjusted to the selected standard size. To get the adjusted sample picture.
- a standard size corresponding to a sample picture in each sample may be selected from a standard size set according to various methods for selecting a standard size described in step 202 in this embodiment.
- the third step is to use machine learning to take the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and use the processing result corresponding to the input adjusted sample picture as the desired output to train.
- the above-mentioned picture processing model capable of processing various standard sizes is obtained.
- the third step can be implemented by the following steps:
- the initial picture processing model may be various types of untrained or untrained artificial neural networks. For example, deep learning models.
- the initial picture processing model may also be a model obtained by combining a plurality of untrained or untrained artificial neural networks.
- the initial picture processing model may be a model obtained by combining an untrained convolutional neural network, an untrained recurrent neural network, and an untrained fully connected layer.
- the initial image processing model can also be some existing, open source image processing models that have been trained and completed.
- the initial picture processing model may also be a neural network constructed by using various existing neural network APIs (Application Programming Interface).
- the adjusted sample picture corresponding to the sample picture in each training sample can be used as the input of the initial picture processing model, and the initial picture processing model is trained based on the output of the initial picture processing model and a preset loss function, and The initial image processing model after training is used as the image processing model.
- the value of the loss function can be used to represent the degree of difference between the processing result output by the initial picture processing model and the processing result corresponding to the input adjusted sample picture during the training process.
- the smaller the loss function the smaller the difference.
- a picture processing model corresponding to the standard size may be pre-trained for each standard size in a preset standard size set.
- a pre-trained picture processing model corresponding to the target size may be selected according to the target size.
- the selected picture processing model is then used to process the adjusted picture to be processed.
- a picture processing model corresponding to the standard size can be obtained by training as follows:
- the first step is to obtain a training sample set, where the training samples may include sample pictures and processing results of the sample pictures.
- the size of the sample picture in the training sample is adjusted to the standard size to obtain the adjusted sample picture.
- the third step is to use machine learning to take the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and use the processing result corresponding to the input adjusted sample picture as the desired output to train.
- a picture processing model corresponding to the standard size is obtained.
- the above third step can be specifically implemented by the following steps:
- the initial picture processing model may be various types of untrained or untrained artificial neural networks. For example, deep learning models.
- the initial picture processing model may also be a model obtained by combining a plurality of untrained or untrained artificial neural networks.
- the initial picture processing model may be a model obtained by combining an untrained convolutional neural network, an untrained recurrent neural network, and an untrained fully connected layer.
- the initial image processing model can also be some existing, open source image processing models that have been trained and completed.
- the initial picture processing model may also be a neural network constructed by using various existing neural network APIs (Application Programming Interface).
- the adjusted sample picture corresponding to the sample picture in each training sample can be used as the input of the initial picture processing model, and the initial picture processing model is trained based on the output of the initial picture processing model and a preset loss function, and The initial image processing model after training is used as the image processing model.
- the value of the loss function can be used to represent the degree of difference between the processing result output by the initial picture processing model and the processing result corresponding to the input adjusted sample picture during the training process.
- the smaller the loss function the smaller the difference.
- the picture processing model can also be used to process pictures of other standard sizes except the target size in the standard size set, that is, the above picture processing model can process various preset standards. Size picture.
- the method provided by the foregoing embodiment of the present application obtains a picture to be processed, and selects a standard size corresponding to the picture to be processed as a target size from a preset standard size set. Then, the size of the picture to be processed is adjusted to the selected target size, and the adjusted picture is input to a pre-trained picture processing model to obtain a processing result, so that the size of the picture to be processed is adjusted by using preset multiple standard sizes. In this case, the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps improve the flexibility of picture size adjustment.
- the process 300 for processing pictures includes the following steps:
- Step 301 Obtain a picture to be processed.
- step 201 For the specific execution process of this step, refer to the related description of step 201 in the embodiment corresponding to FIG. 2, and details are not described herein again.
- Step 302 Select a standard size that has the smallest difference from the size of the picture to be processed from the preset standard size set as the target size.
- the difference between each standard size in the preset standard size set and the size of the picture to be processed can be determined separately, and then the standard size corresponding to the smallest difference among them is selected as the target size.
- the difference between the size of the picture to be processed and the standard size can be determined using various calculation methods according to the actual application scenario.
- the difference between the length of the picture to be processed and the length corresponding to the standard size or the difference between the width of the picture to be processed and the width corresponding to the standard size may be directly used as the difference between the size of the picture to be processed and the standard size.
- the difference between the length of the picture to be processed and the length corresponding to the standard size may be calculated first, and may be recorded as the first difference; then, the difference between the width of the picture to be processed and the width corresponding to the standard size may be calculated, and Record it as the second difference; then, the square sum of the first difference and the second difference can be calculated, and the calculated sum of squares can be used as the difference between the size of the picture to be processed and the standard size.
- the resolution may be expressed using the number of horizontal pixels and the number of vertical pixels.
- the difference between the sizes of the two pictures can be determined by the following steps.
- the size of the picture to be processed can be determined, and the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed can be calculated as the first ratio.
- the ratio of the number of horizontal pixels and the number of vertical pixels corresponding to the standard size to be compared with the size of the picture to be processed can be calculated as the second ratio.
- the absolute value of the difference between the first ratio and the second ratio is used as the difference between the sizes of the two pictures to be compared.
- Step 303 Adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed.
- Step 304 Input the adjusted to-be-processed picture into a pre-trained picture processing model to obtain a processing result.
- steps 303 and 304 For specific implementation processes of the foregoing steps 303 and 304, reference may be made to the related description of steps 203 and 204 in the embodiment corresponding to FIG. 2, and details are not described herein again.
- FIG. 4 is a schematic diagram of an application scenario of a method for processing a picture according to this embodiment.
- the resolution of the to-be-processed picture 401 is 320 * 480, where the number of horizontal pixels is 320 and the number of vertical pixels is 480.
- the preset standard size set 402 includes three standard sizes, which are: 240 * 320, 960 * 640, and 480 * 800. Then, the difference between the size of the picture to be processed and each standard size can be calculated separately.
- a ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed may be calculated first as 320/480. Then, the ratio of the number of horizontal pixels to the number of vertical pixels of the standard size is calculated as 240/320. After that, the absolute value of the difference between the two ratios can be calculated as the difference between the size of the picture to be processed and the standard size 240 * 320 is 1/12, as shown by reference numeral 403 in the figure.
- the difference between the size of the picture to be processed and the standard size 960 * 640 is 5/6, as shown by reference numeral 404 in the figure, and the difference between the size of the picture to be processed and the standard size 480 * 800 is 1 / 15, as shown by reference numeral 405 in the figure.
- the smallest difference value can be selected from the calculated three difference values to be 1/15. Therefore, the standard size 480 * 800 corresponding to the smallest difference is taken as the target size. Then, the size of the to-be-processed picture 401 can be adjusted to the above-mentioned target size 480 * 800 to obtain the adjusted to-be-processed picture 406.
- the adjusted to-be-processed picture 406 can be input to a pre-trained picture processing model 407, and a processing result 408 can be obtained.
- a pre-trained picture processing model 407 e.g., three picture processing models may be trained in advance, corresponding to three sizes in the standard size set 402, respectively.
- the adjusted to-be-processed picture is input to a picture processing model corresponding to the size of the adjusted to-be-processed picture to obtain a processing result.
- the flow 300 of the information pushing method in this embodiment can compare the difference between the size of the picture to be processed and each standard size in the standard size set, and The size of the picture to be processed is adjusted to the smallest difference corresponding to the standard size, and then the adjusted picture to be processed is processed to obtain a processing result. Therefore, compared with the solution described in this embodiment and the prior art in which the sizes of different pictures to be processed are uniformly adjusted to the same standard size, this method helps reduce the The degree of distortion or deformation further helps to reduce the subsequent impact on the processing result due to the distortion or deformation of the adjusted picture to be processed.
- this application provides an embodiment of a device for processing pictures.
- This device embodiment corresponds to the method embodiment shown in FIG. 2, and the device is specific Can be applied to various electronic devices.
- the apparatus 500 for processing pictures includes an acquisition 501, a selection unit 502, an adjustment unit 503, and a processing unit 504.
- the obtaining unit 501 is configured to obtain a picture to be processed.
- the selecting unit 502 is configured to select a standard size corresponding to a picture to be processed as a target size from a preset standard size set.
- the adjustment unit 503 is configured to adjust the size of the picture to be processed to a target size to obtain the adjusted picture to be processed.
- the processing unit 504 is configured to input the adjusted to-be-processed picture to a pre-trained picture processing model to obtain a processing result.
- step 201, step 202, step 203, and step 204 are not repeated here.
- the above-mentioned selecting unit 502 is further configured to: determine the size of the picture to be processed; and based on the size of the picture to be processed, select from the preset standard size set corresponding to the picture to be processed As the target size.
- the above-mentioned selecting unit 502 is further configured to: select a standard size having a smallest difference from a size of a picture to be processed as a target size.
- the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standards in the standard size set Size, the difference between the standard size and the size of the picture to be processed is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed and the ratio of the number of horizontal pixels and vertical pixels corresponding to the standard size is taken as the difference between the standard size and the size of the picture to be processed.
- the above-mentioned selecting unit 502 is further configured to: determine content information of the picture to be processed; and determine the content of the picture to be processed according to the correspondence between the pre-established content information and the standard size The standard size corresponding to the content information with the highest similarity of information is taken as the target size.
- the picture processing model is obtained by training as follows: obtaining a training sample set, where the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, Select the standard size corresponding to the sample picture in the training sample from the standard size set, and adjust the size of the sample picture in the training sample to the selected standard size to obtain the adjusted sample picture; use the method of machine learning , Taking the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and using the processing result corresponding to the input adjusted sample picture as the desired output, training to obtain a picture processing model.
- the apparatus obtains a picture to be processed through an acquisition unit, the selection unit selects a standard size corresponding to the picture to be processed from a preset standard size set as a target size, and the adjustment unit adjusts the size of the picture to be processed To the target size, get the adjusted to-be-processed picture, and then the processing unit inputs the adjusted to-be-processed picture to a pre-trained picture processing model to get the processing result, so that the preset to-be-adjusted standard sizes are used to adjust the to-be-processed
- the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps to improve the flexibility of picture size adjustment.
- FIG. 6 illustrates a schematic structural diagram of a computer system 600 suitable for implementing an electronic device according to an embodiment of the present application.
- the electronic device shown in FIG. 6 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
- the computer system 600 includes a central processing unit (CPU) 601, which can be loaded into a random access memory (RAM) 603 from a program stored in a read-only memory (ROM) 602 or from a storage portion 608 Instead, perform various appropriate actions and processes.
- RAM random access memory
- ROM read-only memory
- various programs and data required for the operation of the system 600 are also stored.
- the CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
- An input / output (I / O) interface 605 is also connected to the bus 604.
- the following components are connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage portion 608 including a hard disk and the like; a communication section 609 including a network interface card such as a LAN card, a modem, and the like.
- the communication section 609 performs communication processing via a network such as the Internet.
- the driver 610 is also connected to the I / O interface 605 as necessary.
- a removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
- the process described above with reference to the flowchart may be implemented as a computer software program.
- embodiments of the present disclosure include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing a method shown in a flowchart.
- the computer program may be downloaded and installed from a network through the communication section 609, and / or installed from a removable medium 611.
- CPU central processing unit
- the computer-readable medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the foregoing.
- the computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
- a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in combination with an instruction execution system, apparatus, or device.
- a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
- the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
- Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
- each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more functions to implement a specified logical function Executable instructions.
- the functions labeled in the blocks may also occur in a different order than those labeled in the drawings. For example, two blocks represented one after the other may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
- each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts can be implemented by a dedicated hardware-based system that performs the specified function or operation , Or it can be implemented with a combination of dedicated hardware and computer instructions.
- the units described in the embodiments of the present application may be implemented by software or hardware.
- the described unit may also be provided in a processor, for example, it may be described as: a processor including an acquisition unit, a selection unit, an adjustment unit, and a processing unit.
- a processor including an acquisition unit, a selection unit, an adjustment unit, and a processing unit.
- the names of these units do not constitute a limitation on the unit itself in some cases.
- the obtaining unit may also be described as a “unit for obtaining a picture to be processed”.
- the present application further provides a computer-readable medium, which may be included in the device described in the foregoing embodiments; or may exist alone without being assembled into the device.
- the computer readable medium carries one or more programs, and when the one or more programs are executed by the device, the device causes the device to: obtain a picture to be processed; and select a picture corresponding to the picture to be processed from a preset standard size set.
- the standard size is used as the target size; the size of the picture to be processed is adjusted to the target size to obtain the adjusted picture to be processed; the adjusted picture to be processed is input to a pre-trained picture processing model to obtain the processing result.
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
Disclosed in embodiments of the present application are a method and device for processing a picture. One specific implementation of the method comprises: obtaining a picture to be processed; selecting, from a preset standard size set, a standard size corresponding to the picture to be processed as a target size; adjusting the size of the picture to the processed to the target size to obtain an adjusted picture to be processed; and inputting the adjusted picture to be processed to a pre-trained picture processing model to obtain a processing result. The implementation facilitates improving the flexibility of picture size adjustment.
Description
本专利申请要求于2018年7月3日提交的、申请号为201810714637.5、申请人为北京字节跳动网络技术有限公司、发明名称为“用于处理图片的方法和装置”的中国专利申请的优先权,该申请的全文以引用的方式并入本申请中。This patent application claims the priority of a Chinese patent application filed on July 3, 2018, with application number 201810714637.5, the applicant being Beijing BYTE Network Technology Co., Ltd., and the invention name "Method and Device for Processing Pictures" , The entire application of which is incorporated herein by reference.
本申请实施例涉及计算机技术领域,具体涉及用于处理图片的方法和装置。Embodiments of the present application relate to the field of computer technology, and in particular, to a method and an apparatus for processing a picture.
随着人工神经网络的发展,其在图片处理领域的应用也越来越广泛。例如,在图片识别、图片分类等领域,可以使用相应的神经网络模型来对图片进行处理。With the development of artificial neural networks, their applications in the field of image processing are becoming more and more widespread. For example, in the fields of picture recognition, picture classification, etc., corresponding neural network models can be used to process pictures.
现有技术中,一些利用神经网络模型处理图片的过程通常是先将待处理的图片的尺寸缩放至一个标准尺寸,然后再对图片进行处理。并且,在待处理图片的数量为多个时,一般是将各个待处理图片的尺寸缩放至同一个标准尺寸。In the prior art, some processes using neural network models to process pictures usually first scale the size of the picture to be processed to a standard size, and then process the picture. In addition, when the number of pictures to be processed is multiple, the size of each picture to be processed is generally scaled to the same standard size.
发明内容Summary of the invention
本申请实施例提出了用于处理图片的方法和装置。The embodiments of the present application provide a method and device for processing pictures.
第一方面,本申请实施例提供了一种用于处理图片的方法,该方法包括:获取待处理图片;从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸;将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片;将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。In a first aspect, an embodiment of the present application provides a method for processing a picture. The method includes: obtaining a picture to be processed; selecting a standard size corresponding to the picture to be processed from a preset standard size set as a target size; The size of the picture to be processed is adjusted to the target size to obtain the adjusted picture to be processed; the adjusted picture to be processed is input to a pre-trained picture processing model to obtain a processing result.
在一些实施例中,从预设的标准尺寸集合中选取与待处理图片对 应的标准尺寸作为目标尺寸,包括:确定待处理图片的尺寸;基于待处理图片的尺寸,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。In some embodiments, selecting the standard size corresponding to the picture to be processed as the target size from the preset standard size set includes: determining the size of the picture to be processed; and from the preset standard size set based on the size of the picture to be processed Select the standard size corresponding to the picture to be processed as the target size.
在一些实施例中,基于待处理图片的尺寸,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸,包括:选取与待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。In some embodiments, based on the size of the picture to be processed, selecting a standard size corresponding to the picture to be processed from the preset standard size set as the target size includes: selecting a standard size with the smallest difference from the size of the picture to be processed As the target size.
在一些实施例中,待处理图片的尺寸为待处理图片的分辨率,待处理图片的分辨率用水平像素数和垂直像素数表示;以及针对标准尺寸集合中的标准尺寸,该标准尺寸与待处理图片的尺寸的差值通过如下步骤确定:确定待处理图片的水平像素数与垂直像素数的比值;确定该标准尺寸对应的水平像素数和垂直像素数的比值;将待处理图片的水平像素数与垂直像素数的比值与该标准尺寸对应的水平像素数和垂直像素数的比值的差的绝对值作为该标准尺寸与待处理图片的尺寸的差值。In some embodiments, the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standard size in the standard size set, the standard size and the The difference in the size of the processed picture is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of pixels to the number of vertical pixels and the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size is used as the difference between the standard size and the size of the picture to be processed.
在一些实施例中,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸,包括:确定待处理图片的内容信息;根据预先建立的内容信息与标准尺寸的对应关系,确定与待处理图片的内容信息的相似度最高的内容信息对应的标准尺寸作为目标尺寸。In some embodiments, selecting a standard size corresponding to a picture to be processed as a target size from a preset standard size set includes: determining content information of the picture to be processed; and according to a pre-established correspondence between the content information and the standard size, A standard size corresponding to the content information with the highest similarity of the content information of the picture to be processed is determined as the target size.
在一些实施例中,图片处理模型通过如下步骤训练得到:获取训练样本集合,其中,训练样本包括样本图片和样本图片的处理结果;针对训练样本集合中的训练样本,从标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,以及将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片;利用机器学习的方法,将训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到图片处理模型。In some embodiments, the image processing model is obtained by training as follows: obtaining a training sample set, wherein the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, selecting a standard size set and The standard size corresponding to the sample picture in the training sample, and the size of the sample picture in the training sample is adjusted to the selected standard size to obtain the adjusted sample picture; using the method of machine learning, the The adjusted sample picture corresponding to the sample picture in the training sample is used as input, and the processing result corresponding to the input adjusted sample picture is used as the desired output, and a picture processing model is trained.
第二方面,本申请实施例提供了一种用于处理图片的装置,该装置包括:获取单元,被配置成获取待处理图片;选取单元,被配置成从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸;调整单元,被配置成将待处理图片的尺寸调整至目标尺寸,得 到调整后的待处理图片;处理单元,被配置成将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。In a second aspect, an embodiment of the present application provides an apparatus for processing a picture. The apparatus includes: an obtaining unit configured to obtain a picture to be processed; and a selecting unit configured to select an image from a preset standard size set. The standard size corresponding to the picture to be processed is taken as the target size; the adjustment unit is configured to adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed; the processing unit is configured to input the adjusted picture to be processed To the pre-trained image processing model, get the processing result.
在一些实施例中,上述选取单元进一步被配置成:确定待处理图片的尺寸;基于待处理图片的尺寸,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。In some embodiments, the above-mentioned selecting unit is further configured to: determine a size of the picture to be processed; and based on the size of the picture to be processed, select a standard size corresponding to the picture to be processed as a target size from a preset standard size set.
在一些实施例中,上述选取单元进一步被配置成:选取与待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。In some embodiments, the above-mentioned selecting unit is further configured to: select a standard size having a smallest difference from a size of a picture to be processed as a target size.
在一些实施例中,待处理图片的尺寸为待处理图片的分辨率,待处理图片的分辨率用水平像素数和垂直像素数表示;以及针对标准尺寸集合中的标准尺寸,该标准尺寸与待处理图片的尺寸的差值通过如下步骤确定:确定待处理图片的水平像素数与垂直像素数的比值;确定该标准尺寸对应的水平像素数和垂直像素数的比值;将待处理图片的水平像素数与垂直像素数的比值与该标准尺寸对应的水平像素数和垂直像素数的比值的差的绝对值作为该标准尺寸与待处理图片的尺寸的差值。In some embodiments, the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standard size in the standard size set, the standard size and the The difference in the size of the processed picture is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of pixels to the number of vertical pixels and the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size is used as the difference between the standard size and the size of the picture to be processed.
在一些实施例中,上述选取单元进一步被配置成:确定待处理图片的内容信息;根据预先建立的内容信息与标准尺寸的对应关系,确定与待处理图片的内容信息的相似度最高的内容信息对应的标准尺寸作为目标尺寸。In some embodiments, the above-mentioned selecting unit is further configured to: determine content information of the picture to be processed; and determine content information with the highest similarity to the content information of the picture to be processed according to a pre-established correspondence between the content information and a standard size The corresponding standard size is used as the target size.
在一些实施例中,图片处理模型通过如下步骤训练得到:获取训练样本集合,其中,训练样本包括样本图片和样本图片的处理结果;针对训练样本集合中的训练样本,从标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,以及将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片;利用机器学习的方法,将训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到图片处理模型。In some embodiments, the image processing model is obtained by training as follows: obtaining a training sample set, wherein the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, selecting a standard size set and The standard size corresponding to the sample picture in the training sample, and the size of the sample picture in the training sample is adjusted to the selected standard size to obtain the adjusted sample picture; using the method of machine learning, the The adjusted sample picture corresponding to the sample picture in the training sample is used as input, and the processing result corresponding to the input adjusted sample picture is used as the desired output, and a picture processing model is trained.
第三方面,本申请实施例提供了一种电子设备,该电子设备包括:一个或多个处理器;存储装置,用于存储一个或多个程序;当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如第 一方面中任一实现方式描述的方法。According to a third aspect, an embodiment of the present application provides an electronic device. The electronic device includes: one or more processors; a storage device configured to store one or more programs; The processor executes such that one or more processors implement the method as described in any implementation of the first aspect.
第四方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如第一方面中任一实现方式描述的方法。In a fourth aspect, an embodiment of the present application provides a computer-readable medium having stored thereon a computer program that, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
本申请实施例提供的用于处理图片的方法和装置,通过获取待处理图片,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。然后,将待处理图片的尺寸调整至选取的目标尺寸,并将调整后的图片输入预先训练的图片处理模型,得到处理结果,从而借助预设的多种标准尺寸,在调整待处理图片的尺寸时,可以根据具体的待处理图片,将待处理图片的尺寸调整至与其对应的标准尺寸,有助于提升了图片尺寸调整时的灵活性。The method and device for processing pictures provided by the embodiments of the present application obtain a picture to be processed and select a standard size corresponding to the picture to be processed from a preset standard size set as a target size. Then, the size of the picture to be processed is adjusted to the selected target size, and the adjusted picture is input to a pre-trained picture processing model to obtain a processing result, so that the size of the picture to be processed is adjusted by using preset multiple standard sizes. In this case, the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps improve the flexibility of picture size adjustment.
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:Other features, objects, and advantages of the present application will become more apparent by reading the detailed description of the non-limiting embodiments with reference to the following drawings:
图1是本申请的一个实施例可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied; FIG.
图2是本申请的用于处理图片的方法的一个实施例的流程图;2 is a flowchart of an embodiment of a method for processing a picture according to the present application;
图3是根据本申请的用于处理图片的方法的又一个实施例的流程图;3 is a flowchart of still another embodiment of a method for processing pictures according to the present application;
图4是根据本申请的用于处理图片的方法的一个应用场景的示意图;4 is a schematic diagram of an application scenario of a method for processing pictures according to the present application;
图5是根据本申请的用于处理图片的装置的一个实施例的结构示意图;5 is a schematic structural diagram of an embodiment of an apparatus for processing pictures according to the present application;
图6是适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。FIG. 6 is a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发 明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The following describes the present application in detail with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. It should also be noted that, for convenience of description, only the parts related to the related invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The application will be described in detail below with reference to the drawings and embodiments.
图1示出了可以应用本申请的用于处理图片的方法或用于处理图片的装置的一个实施例的示例性架构100。FIG. 1 illustrates an exemplary architecture 100 of an embodiment of a method for processing pictures or an apparatus for processing pictures to which the present application can be applied.
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 1, the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种客户端应用,例如网页浏览器应用、图片处理类应用等。The terminal devices 101, 102, 103 interact with the server 105 through the network 104 to receive or send messages and the like. Various client applications can be installed on the terminal devices 101, 102, and 103, such as a web browser application and an image processing application.
终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是能够处理图片的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、膝上型便携计算机和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供分布式服务的多个软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。The terminal devices 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, and 103 are hardware, they can be various electronic devices capable of processing pictures, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, and desktop computers. When the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, multiple software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
服务器105可以是提供各种服务的服务器,例如为终端设备101、102、103上的待处理图片提供分析处理的图片处理服务器。图片处理服务器可以对待处理图片进行尺寸调整等处理,并生成处理结果,还可以将处理结果(如尺寸调整后的待处理图片)反馈给终端设备。The server 105 may be a server that provides various services, for example, a picture processing server that provides analysis processing for pictures to be processed on the terminal devices 101, 102, and 103. The picture processing server may perform processing such as resizing the picture to be processed, and generate a processing result, and may also feedback the processing result (such as the picture to be processed after the resizing) to the terminal device.
需要说明的是,上述待处理图片也可以直接存储在服务器105的本地,服务器105可以直接提取本地所存储的待处理图片并进行处理,此时,可以不存在终端设备101、102、103和网络104。It should be noted that the above-mentioned pictures to be processed may also be directly stored locally on the server 105, and the server 105 may directly extract and process the locally stored pictures to be processed. At this time, the terminal devices 101, 102, 103 and the network may not exist. 104.
需要说明的是,本申请实施例所提供的用于处理图片方法一般由服务器105执行,相应地,用于处理图片的装置一般设置于服务器105 中。It should be noted that the method for processing pictures provided by the embodiments of the present application is generally executed by the server 105, and accordingly, the apparatus for processing pictures is generally set in the server 105.
还需要指出的是,终端设备101、102、103中也可以安装有图片处理类应用,终端设备101、102、103也可以基于图片处理类应用对待处理图片进行处理,此时,用于处理图片的方法也可以由终端设备101、102、103执行,相应地,用于处理图片的装置也可以设置于终端设备101、102、103中。此时,示例性系统架构100可以不存在服务器105和网络104。It should also be noted that the terminal device 101, 102, 103 may also have an image processing application installed, and the terminal device 101, 102, 103 may also process the image to be processed based on the image processing application. At this time, it is used to process the image The method can also be executed by the terminal devices 101, 102, 103, and accordingly, the apparatus for processing pictures can also be set in the terminal devices 101, 102, 103. At this time, the exemplary system architecture 100 may be absent from the server 105 and the network 104.
需要说明的是,服务器可以是硬件,也可以是软件。当服务器为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成多个软件或软件模块(例如用来提供分布式服务的多个软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。It should be noted that the server may be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers or as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, multiple software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks, and servers in FIG. 1 are merely exemplary. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
继续参考图2,示出了根据本申请的用于处理图片的方法的一个实施例的流程200。该用于处理图片的方法包括以下步骤:With continued reference to FIG. 2, a flowchart 200 of an embodiment of a method for processing a picture according to the present application is shown. The method for processing pictures includes the following steps:
步骤201,获取待处理图片。Step 201: Obtain a picture to be processed.
在本实施例中,用于处理图片的方法的执行主体(如图1所示的服务器105)可以通过有线或无线的方式从本地或者其它存储设备(如图1所示的终端设备101、102、103)获取待处理图片。其中,待处理图片可以是任意类型的图片。In this embodiment, the execution subject of the method for processing pictures (such as the server 105 shown in FIG. 1) may be wired or wirelessly from a local or other storage device (such as the terminal devices 101 and 102 shown in FIG. 1). (103) Obtain a picture to be processed. The picture to be processed may be any type of picture.
步骤202,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。In step 202, a standard size corresponding to a picture to be processed is selected as a target size from a preset standard size set.
在本实施例中,尺寸可以指图片的物理尺寸,如图片的长度和宽度。尺寸也可以指图片的分辨率。尺寸也可以指图片的大小,如图片占用的存储空间。标准尺寸可以是预设的任意尺寸。根据不同的应用需求,可以预设不同的标准尺寸集合。In this embodiment, the size may refer to the physical size of the picture, such as the length and width of the picture. Size can also refer to the resolution of the picture. Size can also refer to the size of the picture, such as the storage space occupied by the picture. The standard size can be any preset size. According to different application requirements, different standard size sets can be preset.
其中,待处理图片与标准尺寸根据不同的对应逻辑可以有不同的对应关系。不同的对应关系通常可以利用不同的选取方式,从预设的 标准尺寸集合中选取标准尺寸作为目标尺寸。The correspondence between the to-be-processed picture and the standard size may be different according to different correspondence logic. Different correspondences can usually use different selection methods to select the standard size from the preset standard size set as the target size.
在本实施例的一些可选的实现方式中,可以先确定待处理图片的尺寸,然后基于确定的待处理图片的尺寸,从预设的标准尺寸集合中选取标准尺寸作为目标尺寸。In some optional implementations of this embodiment, the size of the picture to be processed may be determined first, and then based on the determined size of the picture to be processed, a standard size is selected as a target size from a preset standard size set.
可选地,可以预先将图片的尺寸划分为成几种类型。例如,可以将图片的尺寸划分为长宽比大于1,长宽比等于1和长宽比小于1这三种类型。然后,针对每种类型的尺寸,确定该种类型的尺寸对应的标准尺寸。此时,可以根据待处理图片的尺寸,直接从预设的标准尺寸集合中选取待处理图片的尺寸对应的标准尺寸作为目标尺寸。Optionally, the size of the picture may be divided into several types in advance. For example, the size of a picture can be divided into three types: the aspect ratio is greater than 1, the aspect ratio is equal to 1, and the aspect ratio is less than 1. Then, for each type of size, a standard size corresponding to that type of size is determined. At this time, according to the size of the picture to be processed, a standard size corresponding to the size of the picture to be processed can be directly selected as a target size from a preset standard size set.
具体地,对于每种类型的尺寸,可以预先获取大量的该类型的尺寸的图片,然后,针对获取的大量图片,计算将这些图片的尺寸调整至预设的标准尺寸集合中的一种标准尺寸后的精度损失的平均值。同样地,确定将这些图片的尺寸调整至预设的标准尺寸集合中的其它各标准尺寸后分别对应的精度损失的平均值。然后,选取出最小的精度损失的平均值对应的标准尺寸作为该类型的尺寸的图片对应的标准尺寸。Specifically, for each type of size, a large number of pictures of that type can be obtained in advance, and then, for the obtained large number of pictures, the size of these pictures is adjusted to a standard size in a preset standard size set. After the average loss of accuracy. Similarly, an average value of the accuracy loss corresponding to each of the standard sizes in the preset standard size set after adjusting the sizes of these pictures is determined. Then, the standard size corresponding to the average value of the smallest loss of accuracy is selected as the standard size corresponding to the picture of this type.
在本实施例的一些可选的实现方式中,可以先确定待处理图片的内容信息,然后根据预先建立的图片的内容信息与标准尺寸的对应关系,将与待处理图片的内容信息的相似度最高的内容信息所对应的标准尺寸作为目标尺寸。In some optional implementations of this embodiment, the content information of the picture to be processed may be determined first, and then the similarity between the content information of the picture to be processed and the standard size will be similar to the content information of the picture to be processed. The standard size corresponding to the highest content information is the target size.
其中,内容信息可以是与待处理图片的内容相关的信息。例如内容信息可以是待处理图片中包含的对象的类型、包含的对象的个数等。具体地,可以利用现有的各种图片检测或识别方法来确定待处理图片的内容信息。例如,可以利用现有的各种用于图片分类的深度学习模型(如AlexNet等)对待处理图片进行分类,并将分类结果中确定的待处理图片的标签作为待处理图片的内容信息。例如,还可以利用现有的一些图片分类软件,并将分类软件确定的待处理图片的主题作为待处理图片的内容信息。例如,还可以利用现有的各种图片理解方法(如基于Multimodal Recurrent Neural Network的图像文本描述)对待处理图片进行处理,将得到的描述图像的文本作为待处理图片的内容 信息。The content information may be information related to the content of the picture to be processed. For example, the content information may be the type of objects included in the picture to be processed, the number of objects included, and the like. Specifically, various existing picture detection or recognition methods may be used to determine content information of a picture to be processed. For example, existing deep learning models (such as AlexNet, etc.) used for picture classification can be used to classify pictures to be processed, and the tags of the pictures to be processed determined in the classification result are used as content information of the pictures to be processed. For example, some existing picture classification software can also be used, and the subject of the picture to be processed determined by the classification software can be used as the content information of the picture to be processed. For example, various existing picture understanding methods (such as image text description based on Multimodal Recurrent Neural Network) can be used to process the picture to be processed, and the obtained text describing the image can be used as content information of the picture to be processed.
举例来说,对于图片识别类应用,可以预先建立存储有图片的内容信息与标准尺寸的对应关系的对应关系表。例如,对于人脸类图片,可以对应于长宽比为5:3的标准尺寸,对于汽车类图片,可以对应于长宽比为3:1的标准尺寸。此时,在确定待处理图片的内容信息为人脸时,那么可以选取5:3的标准尺寸作为目标尺寸,在待处理图片的内容信息为汽车时,那么可以选取3:1的标准尺寸作为目标尺寸。For example, for a picture recognition application, a correspondence table that stores the correspondence between the content information of the picture and the standard size may be established in advance. For example, for a face picture, it may correspond to a standard size with an aspect ratio of 5: 3, and for a car picture, it may correspond to a standard size with an aspect ratio of 3: 1. At this time, when it is determined that the content information of the picture to be processed is a human face, a standard size of 5: 3 can be selected as the target size, and when the content information of the picture to be processed is a car, then a standard size of 3: 1 can be selected as the target size.
在本实施例的一些可选的实现方式中,还可以通过如下步骤从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸:In some optional implementations of this embodiment, the standard size corresponding to the picture to be processed can be selected as the target size from the preset standard size set by the following steps:
第一步,将待处理图片的尺寸分别调整至标准尺寸集合中的各个标准尺寸,从而得到调整后的待处理图片集合。In the first step, the size of the picture to be processed is adjusted to each standard size in the standard size set, so as to obtain the adjusted picture set to be processed.
第二步,分别计算调整后的待处理图片集合中的每个调整后的待处理图片与获取的待处理图片的相似度,从而得到相似度集合。In the second step, the similarity between each adjusted to-be-processed picture and the obtained to-be-processed picture in the adjusted to-be-processed picture set is calculated respectively, so as to obtain a similarity set.
第三步,从得到的相似度集合中选取最大的相似度,并将选取的最大的相似度对应的标准尺寸作为目标尺寸。In the third step, the maximum similarity is selected from the obtained similarity set, and the standard size corresponding to the selected maximum similarity is used as the target size.
步骤203,将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片。Step 203: Adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed.
在本实施例中,可以利用各种用于处理图片的应用对待处理的图片的尺寸进行调整,从而将待处理图片的尺寸调整至选取的目标尺寸,得到尺寸调整后的待处理图片。In this embodiment, various applications for processing pictures can be used to adjust the size of the picture to be processed, thereby adjusting the size of the picture to be processed to the selected target size, and obtaining the resized picture to be processed.
步骤204,将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。Step 204: Input the adjusted to-be-processed picture into a pre-trained picture processing model to obtain a processing result.
在本实施例中,图片处理模型可以是各种能够处理图片的模型。例如,图片处理模型可以是各种能够处理图片的深度学习模型。图片处理模型也可以是各种能够处理图片的卷积神经网络。对图片的处理可以是各种处理方式。例如图片分类、图片识别、图片去噪、图片还原等。In this embodiment, the picture processing model may be various models capable of processing pictures. For example, the picture processing model may be various deep learning models capable of processing pictures. The image processing model can also be various convolutional neural networks capable of processing images. The processing of pictures can be various processing methods. For example, picture classification, picture recognition, picture denoising, picture restoration, etc.
在本实施例的一些可选的实现方式中,图片处理模型可以通过如下步骤训练得到:In some optional implementations of this embodiment, the picture processing model can be obtained by training as follows:
第一步,获取训练样本集合,其中,训练样本包括样本图片和样本图片的处理结果。The first step is to obtain a training sample set, where the training sample includes a sample picture and a processing result of the sample picture.
第二步,针对训练样本集合中的训练样本,从标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,并将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片。In the second step, for the training samples in the training sample set, a standard size corresponding to the sample picture in the training sample is selected from the standard size set, and the size of the sample picture in the training sample is adjusted to the selected standard size. To get the adjusted sample picture.
具体地,可以根据本实施例中上述步骤202中说明的各种选取标准尺寸的方法从标准尺寸集合中选取每个样本中的样本图片对应的标准尺寸。Specifically, a standard size corresponding to a sample picture in each sample may be selected from a standard size set according to various methods for selecting a standard size described in step 202 in this embodiment.
第三步,利用机器学习的方法,将训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到上述能够处理各种标准尺寸的图片处理模型。The third step is to use machine learning to take the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and use the processing result corresponding to the input adjusted sample picture as the desired output to train. The above-mentioned picture processing model capable of processing various standard sizes is obtained.
具体地,第三步可以通过如下步骤实现:Specifically, the third step can be implemented by the following steps:
首先,获取初始图片处理模型。其中,初始图片处理模型可以是各种类型的未经训练或未训练完成的人工神经网络。例如深度学习模型。初始图片处理模型也可以是对多种未经训练的或未训练完成的人工神经网络进行组合得到的模型。例如,初始图片处理模型可以是对未经训练的卷积神经网络、未经训练的循环神经网络和未经训练的全连接层进行组合得到的模型。初始图片处理模型还可以是现有的一些已经训练完成的、开源的图片处理模型。初始图片处理模型也可以是利用现有的各种神经网络API(Application Programming Interface,应用程序编程接口)构造出的神经网络。First, obtain the initial image processing model. Among them, the initial picture processing model may be various types of untrained or untrained artificial neural networks. For example, deep learning models. The initial picture processing model may also be a model obtained by combining a plurality of untrained or untrained artificial neural networks. For example, the initial picture processing model may be a model obtained by combining an untrained convolutional neural network, an untrained recurrent neural network, and an untrained fully connected layer. The initial image processing model can also be some existing, open source image processing models that have been trained and completed. The initial picture processing model may also be a neural network constructed by using various existing neural network APIs (Application Programming Interface).
然后,可以每个训练样本中的样本图片对应的调整后的样本图片作为上述初始图片处理模型的输入,基于初始图片处理模型的输出和预设的损失函数对初始图片处理模型进行训练,并将训练完成后的初始图片处理模型作为图片处理模型。Then, the adjusted sample picture corresponding to the sample picture in each training sample can be used as the input of the initial picture processing model, and the initial picture processing model is trained based on the output of the initial picture processing model and a preset loss function, and The initial image processing model after training is used as the image processing model.
其中,上述损失函数的值可以用来表征训练过程中初始图片处理模型输出的处理结果与输入的调整后的样本图片对应的处理结果的差异程度。损失函数越小,表示差异越小。并且,可以根据损失函数确定是否训练完成。例如,可以将前后两次或多次的损失函数的值均小 于一定阈值作为结束条件。此时,在确定前后两次或多次的损失函数的值均小于一定阈值时,则训练完成,将训练完成后的初始图片处理模型作为训练完成的图片处理模型。The value of the loss function can be used to represent the degree of difference between the processing result output by the initial picture processing model and the processing result corresponding to the input adjusted sample picture during the training process. The smaller the loss function, the smaller the difference. And, it can be determined whether the training is completed according to the loss function. For example, the value of the loss function two or more times before and after may be less than a certain threshold as the end condition. At this time, when it is determined that the value of the loss function before and after two or more times is less than a certain threshold, the training is completed, and the initial image processing model after the training is completed is used as the trained image processing model.
在本实施例的一些可选的实现方式中,可以针对预设的标准尺寸集合中的每个标准尺寸,预先训练该标准尺寸对应的图片处理模型。此时,在得到调整后的待处理图片后,可以先根据目标尺寸选取目标尺寸所对应的、预先训练的图片处理模型。然后利用选取的图片处理模型对调整后的待处理图片进行处理。具体地,对于预设的标准尺寸集合中的每个标准尺寸,该标准尺寸对应的图片处理模型可以通过如下步骤训练得到:In some optional implementations of this embodiment, a picture processing model corresponding to the standard size may be pre-trained for each standard size in a preset standard size set. At this time, after obtaining the adjusted picture to be processed, a pre-trained picture processing model corresponding to the target size may be selected according to the target size. The selected picture processing model is then used to process the adjusted picture to be processed. Specifically, for each standard size in the preset standard size set, a picture processing model corresponding to the standard size can be obtained by training as follows:
第一步,获取训练样本集合,其中,训练样本可以包括样本图片和样本图片的处理结果。The first step is to obtain a training sample set, where the training samples may include sample pictures and processing results of the sample pictures.
第二步,针对训练样本集合中的每个训练样本,将该训练样本中的样本图片的尺寸调整至该标准尺寸,得到调整后的样本图片。In the second step, for each training sample in the training sample set, the size of the sample picture in the training sample is adjusted to the standard size to obtain the adjusted sample picture.
第三步,利用机器学习的方法,将训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到该标准尺寸对应的图片处理模型。The third step is to use machine learning to take the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and use the processing result corresponding to the input adjusted sample picture as the desired output to train. A picture processing model corresponding to the standard size is obtained.
上述第三步可以具体通过如下步骤实现:The above third step can be specifically implemented by the following steps:
首先,获取初始图片处理模型。其中,初始图片处理模型可以是各种类型的未经训练或未训练完成的人工神经网络。例如深度学习模型。初始图片处理模型也可以是对多种未经训练的或未训练完成的人工神经网络进行组合得到的模型。例如,初始图片处理模型可以是对未经训练的卷积神经网络、未经训练的循环神经网络和未经训练的全连接层进行组合得到的模型。初始图片处理模型还可以是现有的一些已经训练完成的、开源的图片处理模型。初始图片处理模型也可以是利用现有的各种神经网络API(Application Programming Interface,应用程序编程接口)构造出的神经网络。First, obtain the initial image processing model. Among them, the initial picture processing model may be various types of untrained or untrained artificial neural networks. For example, deep learning models. The initial picture processing model may also be a model obtained by combining a plurality of untrained or untrained artificial neural networks. For example, the initial picture processing model may be a model obtained by combining an untrained convolutional neural network, an untrained recurrent neural network, and an untrained fully connected layer. The initial image processing model can also be some existing, open source image processing models that have been trained and completed. The initial picture processing model may also be a neural network constructed by using various existing neural network APIs (Application Programming Interface).
然后,可以每个训练样本中的样本图片对应的调整后的样本图片作为上述初始图片处理模型的输入,基于初始图片处理模型的输出和 预设的损失函数对初始图片处理模型进行训练,并将训练完成后的初始图片处理模型作为图片处理模型。Then, the adjusted sample picture corresponding to the sample picture in each training sample can be used as the input of the initial picture processing model, and the initial picture processing model is trained based on the output of the initial picture processing model and a preset loss function, and The initial image processing model after training is used as the image processing model.
其中,上述损失函数的值可以用来表征训练过程中初始图片处理模型输出的处理结果与输入的调整后的样本图片对应的处理结果的差异程度。损失函数越小,表示差异越小。并且,可以根据损失函数确定是否训练完成。例如,可以将前后两次或多次的损失函数的值均小于一定阈值作为结束条件。此时,在确定前后两次或多次的损失函数的值均小于一定阈值时,则训练完成,将训练完成后的初始图片处理模型作为训练完成的图片处理模型。The value of the loss function can be used to represent the degree of difference between the processing result output by the initial picture processing model and the processing result corresponding to the input adjusted sample picture during the training process. The smaller the loss function, the smaller the difference. And, it can be determined whether the training is completed according to the loss function. For example, the value of the loss function two or more times before and after it may be less than a certain threshold value as the end condition. At this time, when it is determined that the value of the loss function before and after two or more times is less than a certain threshold value, the training is completed, and the initial picture processing model after the training is completed is used as the trained picture processing model.
在本实施例的一些可选的实现方式中,图片处理模型还可以用于处理标准尺寸集合中除目标尺寸之外的其它标准尺寸的图片,即上述图片处理模型可以处理预设的各种标准尺寸的图片。In some optional implementations of this embodiment, the picture processing model can also be used to process pictures of other standard sizes except the target size in the standard size set, that is, the above picture processing model can process various preset standards. Size picture.
本申请的上述实施例提供的方法通过获取待处理图片,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。然后,将待处理图片的尺寸调整至选取的目标尺寸,并将调整后的图片输入预先训练的图片处理模型,得到处理结果,从而借助预设的多种标准尺寸,在调整待处理图片的尺寸时,可以根据具体的待处理图片,将待处理图片的尺寸调整至与其对应的标准尺寸,有助于提升了图片尺寸调整时的灵活性。The method provided by the foregoing embodiment of the present application obtains a picture to be processed, and selects a standard size corresponding to the picture to be processed as a target size from a preset standard size set. Then, the size of the picture to be processed is adjusted to the selected target size, and the adjusted picture is input to a pre-trained picture processing model to obtain a processing result, so that the size of the picture to be processed is adjusted by using preset multiple standard sizes. In this case, the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps improve the flexibility of picture size adjustment.
进一步参考图3,其示出了用于处理图片的方法的又一个实施例的流程300。该用于处理图片的流程300,包括以下步骤:With further reference to FIG. 3, a flowchart 300 of yet another embodiment of a method for processing a picture is shown. The process 300 for processing pictures includes the following steps:
步骤301,获取待处理图片。Step 301: Obtain a picture to be processed.
本步骤的具体的执行过程可参考图2对应实施例中的步骤201的相关说明,在此不再赘述。For the specific execution process of this step, refer to the related description of step 201 in the embodiment corresponding to FIG. 2, and details are not described herein again.
步骤302,从预设的标准尺寸集合中选取与待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。Step 302: Select a standard size that has the smallest difference from the size of the picture to be processed from the preset standard size set as the target size.
在本实施例中,可以分别确定预设的标准尺寸集合中的各标准尺寸与待处理图片的尺寸的差值,然后选取其中最小的差值对应的标准尺寸作为目标尺寸。其中,待处理图片的尺寸与标准尺寸的差值可以 根据实际的应用场景利用各种不同的计算方式来确定。In this embodiment, the difference between each standard size in the preset standard size set and the size of the picture to be processed can be determined separately, and then the standard size corresponding to the smallest difference among them is selected as the target size. The difference between the size of the picture to be processed and the standard size can be determined using various calculation methods according to the actual application scenario.
可选地,可以直接将待处理图片的长度与标准尺寸对应的长度的差值或者待处理图片的宽度与标准尺寸对应的宽度的差值作为待处理图片的尺寸与标准尺寸的差值。Optionally, the difference between the length of the picture to be processed and the length corresponding to the standard size or the difference between the width of the picture to be processed and the width corresponding to the standard size may be directly used as the difference between the size of the picture to be processed and the standard size.
可选地,还可以先计算待处理图片的长度与标准尺寸对应的长度的差值,可以记为第一差值;然后,计算待处理图片的宽度与标准尺寸对应的宽度的差值,可以记为第二差值;然后,可以计算上述第一差值和第二差值的平方和,并将计算出的平方和作为待处理图片的尺寸与标准尺寸的差值。Optionally, the difference between the length of the picture to be processed and the length corresponding to the standard size may be calculated first, and may be recorded as the first difference; then, the difference between the width of the picture to be processed and the width corresponding to the standard size may be calculated, and Record it as the second difference; then, the square sum of the first difference and the second difference can be calculated, and the calculated sum of squares can be used as the difference between the size of the picture to be processed and the standard size.
可选地,在图片的尺寸为图片的分辨率时,分辨率可以使用水平像素数和垂直像素数来表示。此时,可以通过如下步骤来确定两个图片的尺寸的差值。Optionally, when the size of the picture is the resolution of the picture, the resolution may be expressed using the number of horizontal pixels and the number of vertical pixels. At this time, the difference between the sizes of the two pictures can be determined by the following steps.
第一步,可以确定待处理图片的尺寸,并计算待处理图片的水平像素数与垂直像素数的比值,可以记为第一比值。In the first step, the size of the picture to be processed can be determined, and the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed can be calculated as the first ratio.
第二步,计算与待处理图片的尺寸进行比较的标准尺寸所对应的水平像素数和垂直像素数的比值,可以记为第二比值。In the second step, the ratio of the number of horizontal pixels and the number of vertical pixels corresponding to the standard size to be compared with the size of the picture to be processed can be calculated as the second ratio.
第三步,将上述第一比值与上述第二比值的差的绝对值作为比较的两个图片的尺寸的差值。In a third step, the absolute value of the difference between the first ratio and the second ratio is used as the difference between the sizes of the two pictures to be compared.
步骤303,将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片。Step 303: Adjust the size of the picture to be processed to the target size to obtain the adjusted picture to be processed.
步骤304,将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。Step 304: Input the adjusted to-be-processed picture into a pre-trained picture processing model to obtain a processing result.
上述步骤303和304的具体的执行过程可参考图2对应实施例中的步骤203和204的相关说明,在此不再赘述。For specific implementation processes of the foregoing steps 303 and 304, reference may be made to the related description of steps 203 and 204 in the embodiment corresponding to FIG. 2, and details are not described herein again.
进一步参见图4,图4是根据本实施例的用于处理图片的方法的应用场景的一个示意图。在图4的应用场景中,待处理图片401的分辨率为320*480,其中,水平像素数为320,垂直像素数为480。预设的标准尺寸集合402包括三个标准尺寸,分别为:240*320、960*640、480*800。然后,可以分别计算待处理图片的尺寸与各个标准尺寸的差值。Further referring to FIG. 4, FIG. 4 is a schematic diagram of an application scenario of a method for processing a picture according to this embodiment. In the application scenario of FIG. 4, the resolution of the to-be-processed picture 401 is 320 * 480, where the number of horizontal pixels is 320 and the number of vertical pixels is 480. The preset standard size set 402 includes three standard sizes, which are: 240 * 320, 960 * 640, and 480 * 800. Then, the difference between the size of the picture to be processed and each standard size can be calculated separately.
具体地,对于标准尺寸240*320,可以先计算将待处理图片的水平像素数与垂直像素数的比值为320/480。然后,计算该标准尺寸的水平像素数与垂直像素数的比值为240/320。之后,可以计算上述两个比值的差值的绝对值作为待处理图片的尺寸与标准尺寸240*320的差值为1/12,如图中标号403所示。同样地,可以计算出待处理图片的尺寸与标准尺寸960*640的差值为5/6,如图中标号404所示,以及待处理图片的尺寸与标准尺寸480*800的差值为1/15,如图中标号405所示。Specifically, for a standard size of 240 * 320, a ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed may be calculated first as 320/480. Then, the ratio of the number of horizontal pixels to the number of vertical pixels of the standard size is calculated as 240/320. After that, the absolute value of the difference between the two ratios can be calculated as the difference between the size of the picture to be processed and the standard size 240 * 320 is 1/12, as shown by reference numeral 403 in the figure. Similarly, the difference between the size of the picture to be processed and the standard size 960 * 640 is 5/6, as shown by reference numeral 404 in the figure, and the difference between the size of the picture to be processed and the standard size 480 * 800 is 1 / 15, as shown by reference numeral 405 in the figure.
之后,可以从上述计算出的三个差值中选取出最小的差值为1/15。因此,将该最小的差值对应的标准尺寸480*800作为目标尺寸。接着,可以将待处理图片401的尺寸调整至上述目标尺寸480*800,得到调整后的待处理图片406。After that, the smallest difference value can be selected from the calculated three difference values to be 1/15. Therefore, the standard size 480 * 800 corresponding to the smallest difference is taken as the target size. Then, the size of the to-be-processed picture 401 can be adjusted to the above-mentioned target size 480 * 800 to obtain the adjusted to-be-processed picture 406.
然后,可以将调整后的待处理图片406输入预先训练的图片处理模型407,进而得到处理结果408。或者,也可以预先训练三个图片处理模型,分别对应于标准尺寸集合402中的三种尺寸。此时,将调整后的待处理图片输入至调整后的待处理图片的尺寸对应的图片处理模型以得到处理结果。Then, the adjusted to-be-processed picture 406 can be input to a pre-trained picture processing model 407, and a processing result 408 can be obtained. Alternatively, three picture processing models may be trained in advance, corresponding to three sizes in the standard size set 402, respectively. At this time, the adjusted to-be-processed picture is input to a picture processing model corresponding to the size of the adjusted to-be-processed picture to obtain a processing result.
从图3中可以看出,与图2对应的实施例相比,本实施例中的信息推送方法的流程300可以比较待处理图片的尺寸与标准尺寸集合中的各个标准尺寸的差值,并将待处理图片的尺寸调整至最小的差值对应标准尺寸,然后对调整后的待处理图片进行处理得到处理结果。由此,本实施例描述的方案和现有技术中的将不同的待处理图片的尺寸统一调整至同样的一个标准尺寸相比,该方法有助于减轻由于待处理图片尺寸调整而带来的失真或变形的程度,进而也有助于减轻由于调整后的待处理图片的失真或变形而导致的后续对其处理结果的影响。As can be seen from FIG. 3, compared with the embodiment corresponding to FIG. 2, the flow 300 of the information pushing method in this embodiment can compare the difference between the size of the picture to be processed and each standard size in the standard size set, and The size of the picture to be processed is adjusted to the smallest difference corresponding to the standard size, and then the adjusted picture to be processed is processed to obtain a processing result. Therefore, compared with the solution described in this embodiment and the prior art in which the sizes of different pictures to be processed are uniformly adjusted to the same standard size, this method helps reduce the The degree of distortion or deformation further helps to reduce the subsequent impact on the processing result due to the distortion or deformation of the adjusted picture to be processed.
进一步参考图5,作为对上述各图所示方法的实现,本申请提供了用于处理图片的装置的一个实施例,该装置实施例与图2所示的方法实施例相对应,该装置具体可以应用于各种电子设备中。With further reference to FIG. 5, as an implementation of the methods shown in the foregoing figures, this application provides an embodiment of a device for processing pictures. This device embodiment corresponds to the method embodiment shown in FIG. 2, and the device is specific Can be applied to various electronic devices.
如图5所示,本实施例提供的用于处理图片的装置500包括获取 501、选取单元502、调整单元503和处理单元504。其中,获取单元501被配置成获取待处理图片。选取单元502被配置成从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。调整单元503被配置成将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片。处理单元504被配置成将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。As shown in FIG. 5, the apparatus 500 for processing pictures provided in this embodiment includes an acquisition 501, a selection unit 502, an adjustment unit 503, and a processing unit 504. The obtaining unit 501 is configured to obtain a picture to be processed. The selecting unit 502 is configured to select a standard size corresponding to a picture to be processed as a target size from a preset standard size set. The adjustment unit 503 is configured to adjust the size of the picture to be processed to a target size to obtain the adjusted picture to be processed. The processing unit 504 is configured to input the adjusted to-be-processed picture to a pre-trained picture processing model to obtain a processing result.
在本实施例中,用于处理图片的装置500中:获取单元501、选取单元502、调整单元503和处理单元504的具体处理及其所带来的技术效果可分别参考图2对应实施例中的步骤201、步骤202、步骤203和步骤204的相关说明,在此不再赘述。In this embodiment, in the apparatus 500 for processing pictures: the specific processing of the obtaining unit 501, the selection unit 502, the adjustment unit 503, and the processing unit 504 and the technical effects brought by them can be referred to the corresponding embodiment in FIG. 2 respectively. The relevant descriptions of step 201, step 202, step 203, and step 204 are not repeated here.
在本实施例的一些可选的实现方式中,上述选取单元502进一步被配置成:确定待处理图片的尺寸;基于待处理图片的尺寸,从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸。In some optional implementations of this embodiment, the above-mentioned selecting unit 502 is further configured to: determine the size of the picture to be processed; and based on the size of the picture to be processed, select from the preset standard size set corresponding to the picture to be processed As the target size.
在本实施例的一些可选的实现方式中,上述选取单元502进一步被配置成:选取与待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。In some optional implementation manners of this embodiment, the above-mentioned selecting unit 502 is further configured to: select a standard size having a smallest difference from a size of a picture to be processed as a target size.
在本实施例的一些可选的实现方式中,待处理图片的尺寸为待处理图片的分辨率,待处理图片的分辨率用水平像素数和垂直像素数表示;以及针对标准尺寸集合中的标准尺寸,该标准尺寸与待处理图片的尺寸的差值通过如下步骤确定:确定待处理图片的水平像素数与垂直像素数的比值;确定该标准尺寸对应的水平像素数和垂直像素数的比值;将待处理图片的水平像素数与垂直像素数的比值与该标准尺寸对应的水平像素数和垂直像素数的比值的差的绝对值作为该标准尺寸与待处理图片的尺寸的差值。In some optional implementations of this embodiment, the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and for the standards in the standard size set Size, the difference between the standard size and the size of the picture to be processed is determined by the following steps: determining the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed; determining the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size; The absolute value of the difference between the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed and the ratio of the number of horizontal pixels and vertical pixels corresponding to the standard size is taken as the difference between the standard size and the size of the picture to be processed.
在本实施例的一些可选的实现方式中,上述选取单元502进一步被配置成:确定待处理图片的内容信息;根据预先建立的内容信息与标准尺寸的对应关系,确定与待处理图片的内容信息的相似度最高的内容信息对应的标准尺寸作为目标尺寸。In some optional implementations of this embodiment, the above-mentioned selecting unit 502 is further configured to: determine content information of the picture to be processed; and determine the content of the picture to be processed according to the correspondence between the pre-established content information and the standard size The standard size corresponding to the content information with the highest similarity of information is taken as the target size.
在本实施例的一些可选的实现方式中,图片处理模型通过如下步骤训练得到:获取训练样本集合,其中,训练样本包括样本图片和样 本图片的处理结果;针对训练样本集合中的训练样本,从标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,以及将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片;利用机器学习的方法,将训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到图片处理模型。In some optional implementations of this embodiment, the picture processing model is obtained by training as follows: obtaining a training sample set, where the training sample includes a sample picture and a processing result of the sample picture; and for the training samples in the training sample set, Select the standard size corresponding to the sample picture in the training sample from the standard size set, and adjust the size of the sample picture in the training sample to the selected standard size to obtain the adjusted sample picture; use the method of machine learning , Taking the adjusted sample picture corresponding to the sample picture in the training sample in the training sample set as input, and using the processing result corresponding to the input adjusted sample picture as the desired output, training to obtain a picture processing model.
本申请的上述实施例提供的装置,通过获取单元获取待处理图片,选取单元从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸,调整单元将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片,然后由处理单元将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果,从而借助预设的多种标准尺寸,在调整待处理图片的尺寸时,可以根据具体的待处理图片,将待处理图片的尺寸调整至与其对应的标准尺寸,有助于提升了图片尺寸调整时的灵活性。The apparatus provided by the foregoing embodiments of the present application obtains a picture to be processed through an acquisition unit, the selection unit selects a standard size corresponding to the picture to be processed from a preset standard size set as a target size, and the adjustment unit adjusts the size of the picture to be processed To the target size, get the adjusted to-be-processed picture, and then the processing unit inputs the adjusted to-be-processed picture to a pre-trained picture processing model to get the processing result, so that the preset to-be-adjusted standard sizes are used to adjust the to-be-processed When the size of the picture is adjusted, the size of the picture to be processed can be adjusted to the corresponding standard size according to the specific picture to be processed, which helps to improve the flexibility of picture size adjustment.
下面参考图6,其示出了适于用来实现本申请实施例的电子设备的计算机系统600的结构示意图。图6示出的电子设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Reference is now made to FIG. 6, which illustrates a schematic structural diagram of a computer system 600 suitable for implementing an electronic device according to an embodiment of the present application. The electronic device shown in FIG. 6 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6, the computer system 600 includes a central processing unit (CPU) 601, which can be loaded into a random access memory (RAM) 603 from a program stored in a read-only memory (ROM) 602 or from a storage portion 608 Instead, perform various appropriate actions and processes. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等, 根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。The following components are connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage portion 608 including a hard disk and the like And a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the Internet. The driver 610 is also connected to the I / O interface 605 as necessary. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本申请的方法中限定的上述功能。In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing a method shown in a flowchart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and / or installed from a removable medium 611. When the computer program is executed by a central processing unit (CPU) 601, the above-mentioned functions defined in the method of the present application are executed.
需要说明的是,本申请的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the foregoing. The computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing. In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in combination with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device . Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点 上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more functions to implement a specified logical function Executable instructions. It should also be noted that in some alternative implementations, the functions labeled in the blocks may also occur in a different order than those labeled in the drawings. For example, two blocks represented one after the other may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified function or operation , Or it can be implemented with a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器,包括获取单元、选取单元、调整单元和处理单元。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定,例如,获取单元还可以被描述为“获取待处理图片的单元”。The units described in the embodiments of the present application may be implemented by software or hardware. The described unit may also be provided in a processor, for example, it may be described as: a processor including an acquisition unit, a selection unit, an adjustment unit, and a processing unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases. For example, the obtaining unit may also be described as a “unit for obtaining a picture to be processed”.
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的装置中所包含的;也可以是单独存在,而未装配入该装置中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该装置执行时,使得该装置:获取待处理图片;从预设的标准尺寸集合中选取与待处理图片对应的标准尺寸作为目标尺寸;将待处理图片的尺寸调整至目标尺寸,得到调整后的待处理图片;将调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。As another aspect, the present application further provides a computer-readable medium, which may be included in the device described in the foregoing embodiments; or may exist alone without being assembled into the device. The computer readable medium carries one or more programs, and when the one or more programs are executed by the device, the device causes the device to: obtain a picture to be processed; and select a picture corresponding to the picture to be processed from a preset standard size set. The standard size is used as the target size; the size of the picture to be processed is adjusted to the target size to obtain the adjusted picture to be processed; the adjusted picture to be processed is input to a pre-trained picture processing model to obtain the processing result.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solution of the specific combination of the above technical features, but should also cover the above technical features or Other technical solutions formed by arbitrarily combining their equivalent features. For example, a technical solution formed by replacing the above features with technical features disclosed in the present application (but not limited to) having similar functions.
Claims (14)
- 一种用于处理图片的方法,包括:A method for processing pictures, including:获取待处理图片;Get the pending pictures;从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸;Selecting a standard size corresponding to the picture to be processed as a target size from a preset standard size set;将所述待处理图片的尺寸调整至所述目标尺寸,得到调整后的待处理图片;Adjusting the size of the picture to be processed to the target size to obtain an adjusted picture to be processed;将所述调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。The adjusted picture to be processed is input to a pre-trained picture processing model to obtain a processing result.
- 根据权利要求1所述的方法,其中,所述从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸,包括:The method according to claim 1, wherein the selecting a standard size corresponding to the picture to be processed as a target size from a preset standard size set comprises:确定所述待处理图片的尺寸;Determining the size of the picture to be processed;基于所述待处理图片的尺寸,从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸。Based on the size of the picture to be processed, a standard size corresponding to the picture to be processed is selected as a target size from a preset standard size set.
- 根据权利要求2所述的方法,其中,所述基于所述待处理图片的尺寸,从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸,包括:The method according to claim 2, wherein, based on the size of the picture to be processed, selecting a standard size corresponding to the picture to be processed as a target size from a preset standard size set comprises:选取与所述待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。A standard size with the smallest difference from the size of the picture to be processed is selected as the target size.
- 根据权利要求3所述的方法,其中,所述待处理图片的尺寸为所述待处理图片的分辨率,所述待处理图片的分辨率用水平像素数和垂直像素数表示;以及The method according to claim 3, wherein the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is represented by the number of horizontal pixels and the number of vertical pixels; and针对所述标准尺寸集合中的标准尺寸,该标准尺寸与所述待处理图片的尺寸的差值通过如下步骤确定:For a standard size in the standard size set, a difference between the standard size and the size of the picture to be processed is determined through the following steps:确定所述待处理图片的水平像素数与垂直像素数的比值;Determining a ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed;确定该标准尺寸对应的水平像素数和垂直像素数的比值;Determine the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size;将所述待处理图片的水平像素数与垂直像素数的比值与该标准尺寸对应的水平像素数和垂直像素数的比值的差的绝对值作为该标准尺寸与所述待处理图片的尺寸的差值。Taking the absolute value of the difference between the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed and the ratio of the number of horizontal pixels and vertical pixels corresponding to the standard size as the difference between the standard size and the size of the picture to be processed value.
- 根据权利要求1所述的方法,其中,所述从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸,包括:The method according to claim 1, wherein the selecting a standard size corresponding to the picture to be processed as a target size from a preset standard size set comprises:确定所述待处理图片的内容信息;Determining content information of the picture to be processed;根据预先建立的内容信息与标准尺寸的对应关系,确定与所述待处理图片的内容信息的相似度最高的内容信息对应的标准尺寸作为目标尺寸。According to a pre-established correspondence between the content information and the standard size, a standard size corresponding to the content information with the highest similarity of the content information of the picture to be processed is determined as the target size.
- 根据权利要求1-5之一所述的方法,其中,所述图片处理模型通过如下步骤训练得到:The method according to any one of claims 1-5, wherein the picture processing model is obtained by training as follows:获取训练样本集合,其中,训练样本包括样本图片和样本图片的处理结果;Obtaining a training sample set, where the training sample includes a sample picture and a processing result of the sample picture;针对所述训练样本集合中的训练样本,从所述标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,以及将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片;For the training samples in the training sample set, select a standard size corresponding to the sample picture in the training sample from the standard size set, and adjust the size of the sample picture in the training sample to the selected standard size To get the adjusted sample picture;利用机器学习的方法,将所述训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到所述图片处理模型。By using a machine learning method, an adjusted sample picture corresponding to a sample picture in a training sample in the training sample set is taken as an input, and a processing result corresponding to the input adjusted sample picture is used as an expected output. The picture processing model is described.
- 一种用于处理图片的装置,包括:A device for processing pictures includes:获取单元,被配置成获取待处理图片;An obtaining unit configured to obtain a picture to be processed;选取单元,被配置成从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸;A selection unit configured to select a standard size corresponding to the picture to be processed as a target size from a preset standard size set;调整单元,被配置成将所述待处理图片的尺寸调整至所述目标尺寸,得到调整后的待处理图片;An adjustment unit configured to adjust a size of the picture to be processed to the target size to obtain an adjusted picture to be processed;处理单元,被配置成将所述调整后的待处理图片输入至预先训练的图片处理模型,得到处理结果。The processing unit is configured to input the adjusted to-be-processed picture into a pre-trained picture processing model to obtain a processing result.
- 根据权利要求7所述的装置,其中,所述选取单元进一步被配置成:The apparatus according to claim 7, wherein the selecting unit is further configured to:确定所述待处理图片的尺寸;Determining the size of the picture to be processed;基于所述待处理图片的尺寸,从预设的标准尺寸集合中选取与所述待处理图片对应的标准尺寸作为目标尺寸。Based on the size of the picture to be processed, a standard size corresponding to the picture to be processed is selected as a target size from a preset standard size set.
- 根据权利要求8所述的装置,其中,所述选取单元进一步被配置成:选取与所述待处理图片的尺寸的差值最小的标准尺寸作为目标尺寸。The apparatus according to claim 8, wherein the selecting unit is further configured to select a standard size having a smallest difference from a size of the picture to be processed as a target size.
- 根据权利要求9所述的装置,其中,所述待处理图片的尺寸为所述待处理图片的分辨率,所述待处理图片的分辨率用水平像素数和垂直像素数表示;以及The apparatus according to claim 9, wherein the size of the picture to be processed is the resolution of the picture to be processed, and the resolution of the picture to be processed is expressed by the number of horizontal pixels and the number of vertical pixels; and针对所述标准尺寸集合中的标准尺寸,该标准尺寸与所述待处理图片的尺寸的差值通过如下步骤确定:For a standard size in the standard size set, a difference between the standard size and the size of the picture to be processed is determined through the following steps:确定所述待处理图片的水平像素数与垂直像素数的比值;Determining a ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed;确定该标准尺寸对应的水平像素数和垂直像素数的比值;Determine the ratio of the number of horizontal pixels to the number of vertical pixels corresponding to the standard size;将所述待处理图片的水平像素数与垂直像素数的比值与该标准尺寸对应的水平像素数和垂直像素数的比值的差的绝对值作为该标准尺寸与所述待处理图片的尺寸的差值。Taking the absolute value of the difference between the ratio of the number of horizontal pixels to the number of vertical pixels of the picture to be processed and the ratio of the number of horizontal pixels and vertical pixels corresponding to the standard size as the difference between the standard size and the size of the picture to be processed value.
- 根据权利要求7所述的装置,其中,所述选取单元进一步被配置成:The apparatus according to claim 7, wherein the selecting unit is further configured to:确定所述待处理图片的内容信息;Determining content information of the picture to be processed;根据预先建立的内容信息与标准尺寸的对应关系,确定与所述待处理图片的内容信息的相似度最高的内容信息对应的标准尺寸作为目标尺寸。According to a pre-established correspondence between the content information and the standard size, a standard size corresponding to the content information with the highest similarity of the content information of the picture to be processed is determined as the target size.
- 根据权利要求7-11之一所述的装置,其中,所述图片处理模 型通过如下步骤训练得到:The apparatus according to any one of claims 7 to 11, wherein the picture processing model is obtained by training as follows:获取训练样本集合,其中,训练样本包括样本图片和样本图片的处理结果;Obtaining a training sample set, where the training sample includes a sample picture and a processing result of the sample picture;针对所述训练样本集合中的训练样本,从所述标准尺寸集合中选取与该训练样本中的样本图片对应的标准尺寸,以及将该训练样本中的样本图片的尺寸调整至所选取的标准尺寸,得到调整后的样本图片;For the training samples in the training sample set, select a standard size corresponding to the sample picture in the training sample from the standard size set, and adjust the size of the sample picture in the training sample to the selected standard size To get the adjusted sample picture;利用机器学习的方法,将所述训练样本集合中的训练样本中的样本图片对应的调整后的样本图片作为输入,将与输入的调整后的样本图片对应的处理结果作为期望输出,训练得到所述图片处理模型。By using a machine learning method, an adjusted sample picture corresponding to a sample picture in a training sample in the training sample set is taken as an input, and a processing result corresponding to the input adjusted sample picture is used as an expected output. The picture processing model is described.
- 一种电子设备,包括:An electronic device includes:一个或多个处理器;One or more processors;存储装置,其上存储有一个或多个程序;A storage device on which one or more programs are stored;当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-6中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.
- 一种计算机可读介质,其上存储有计算机程序,其中,该程序被处理器执行时实现如权利要求1-6中任一所述的方法。A computer-readable medium having stored thereon a computer program, wherein the program, when executed by a processor, implements the method of any one of claims 1-6.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810714637.5 | 2018-07-03 | ||
CN201810714637.5A CN108921792B (en) | 2018-07-03 | 2018-07-03 | Method and device for processing pictures |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020006962A1 true WO2020006962A1 (en) | 2020-01-09 |
Family
ID=64425242
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/116336 WO2020006962A1 (en) | 2018-07-03 | 2018-11-20 | Method and device for processing picture |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108921792B (en) |
WO (1) | WO2020006962A1 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113409204A (en) * | 2021-06-10 | 2021-09-17 | Oppo广东移动通信有限公司 | Method and device for optimizing image to be processed, storage medium and electronic equipment |
CN113449139A (en) * | 2020-03-24 | 2021-09-28 | 阿里巴巴集团控股有限公司 | Method, device and system for generating matching graph |
CN113821278A (en) * | 2021-09-06 | 2021-12-21 | 挂号网(杭州)科技有限公司 | Method and device for calling image size, electronic equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105095911A (en) * | 2015-07-31 | 2015-11-25 | 小米科技有限责任公司 | Sensitive picture identification method and apparatus, and server |
CN106096605A (en) * | 2016-06-02 | 2016-11-09 | 史方 | A kind of image obscuring area detection method based on degree of depth study and device |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105225212B (en) * | 2014-06-27 | 2018-09-28 | 腾讯科技(深圳)有限公司 | A kind of image processing method and device |
CN105139033B (en) * | 2015-08-24 | 2018-11-06 | 小米科技有限责任公司 | Grader construction method and device and image processing method and device |
CN105516597B (en) * | 2015-12-30 | 2018-11-13 | 完美幻境(北京)科技有限公司 | A kind of pan-shot processing method and processing device |
CN106250921A (en) * | 2016-07-26 | 2016-12-21 | 北京小米移动软件有限公司 | Image processing method and device |
CN107220652B (en) * | 2017-05-31 | 2020-05-01 | 北京京东尚科信息技术有限公司 | Method and device for processing pictures |
CN107578375B (en) * | 2017-08-21 | 2020-10-02 | 北京陌上花科技有限公司 | Image processing method and device |
CN108133201B (en) * | 2018-01-17 | 2019-10-25 | 百度在线网络技术(北京)有限公司 | Face character recognition methods and device |
CN108154547B (en) * | 2018-01-17 | 2019-08-09 | 百度在线网络技术(北京)有限公司 | Image generating method and device |
-
2018
- 2018-07-03 CN CN201810714637.5A patent/CN108921792B/en active Active
- 2018-11-20 WO PCT/CN2018/116336 patent/WO2020006962A1/en active Application Filing
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105095911A (en) * | 2015-07-31 | 2015-11-25 | 小米科技有限责任公司 | Sensitive picture identification method and apparatus, and server |
CN106096605A (en) * | 2016-06-02 | 2016-11-09 | 史方 | A kind of image obscuring area detection method based on degree of depth study and device |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113449139A (en) * | 2020-03-24 | 2021-09-28 | 阿里巴巴集团控股有限公司 | Method, device and system for generating matching graph |
CN113409204A (en) * | 2021-06-10 | 2021-09-17 | Oppo广东移动通信有限公司 | Method and device for optimizing image to be processed, storage medium and electronic equipment |
CN113821278A (en) * | 2021-09-06 | 2021-12-21 | 挂号网(杭州)科技有限公司 | Method and device for calling image size, electronic equipment and storage medium |
CN113821278B (en) * | 2021-09-06 | 2024-05-03 | 挂号网(杭州)科技有限公司 | Calling image size method, device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN108921792A (en) | 2018-11-30 |
CN108921792B (en) | 2023-06-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11978245B2 (en) | Method and apparatus for generating image | |
WO2020006961A1 (en) | Image extraction method and device | |
CN107633218B (en) | Method and apparatus for generating image | |
US10902245B2 (en) | Method and apparatus for facial recognition | |
US10915980B2 (en) | Method and apparatus for adding digital watermark to video | |
CN109816589B (en) | Method and apparatus for generating cartoon style conversion model | |
US10762387B2 (en) | Method and apparatus for processing image | |
WO2020000879A1 (en) | Image recognition method and apparatus | |
US11270099B2 (en) | Method and apparatus for generating facial feature | |
WO2019242222A1 (en) | Method and device for use in generating information | |
CN108197618B (en) | Method and device for generating human face detection model | |
WO2020062493A1 (en) | Image processing method and apparatus | |
CN107507153B (en) | Image denoising method and device | |
CN107609506B (en) | Method and apparatus for generating image | |
WO2020024484A1 (en) | Method and device for outputting data | |
CN109255337B (en) | Face key point detection method and device | |
CN111275784B (en) | Method and device for generating image | |
WO2020056902A1 (en) | Method and apparatus for processing mouth image | |
CN109344762B (en) | Image processing method and device | |
CN109389072B (en) | Data processing method and device | |
WO2019080702A1 (en) | Image processing method and apparatus | |
WO2020006962A1 (en) | Method and device for processing picture | |
WO2020062494A1 (en) | Image processing method and apparatus | |
CN110516598B (en) | Method and apparatus for generating image | |
WO2020056901A1 (en) | Method and device for processing image |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18925513 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 19.04.2021) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18925513 Country of ref document: EP Kind code of ref document: A1 |