Hyper-parameter determination method and device of image processing model and electronic equipment
By determining the input image size, batch size and iteration number of the image processing model using the pre-established correlation relationship, the problem of low efficiency in hyperparameter determination in the prior art is solved, and efficient hyperparameter optimization is achieved.
Patent Information
- Application Number
- CN202310980323.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, the process of determining the hyperparameters of the image processing model is low efficiency, requires multiple training and consumes a lot of computing resources, and increases exponentially with the increase of the number of candidate parameter values.
通过获取样本图像的图像尺寸作为目标样本尺寸,根据预先建立的样本尺寸集与输入尺寸集之间的关联关系,确定相应的输入图像尺寸,并计算批尺寸和迭代次数,以优化超参数的确定 .
This method can determine better hyperparameters without multiple training, save time and computing resources, and improve the efficiency of hyperparameter determination of image processing models.
Smart Images

Figure CN119443210A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and in particular to a method, device and electronic device for determining hyperparameters of an image processing model. Background Art
[0002] In the field of machine learning technology, hyperparameters refer to the parameter values set before the training of a deep learning model begins, such as the size of the input image, the batch size (i.e. the number of samples selected for each training), the epoch (number of iterations), etc. In order to ensure the performance of the deep learning model, it is necessary to determine a set of optimal hyperparameters.
[0003] At present, for the image processing model in the deep learning model, the method of determining the hyperparameters in the related technology is: pre-set multiple different candidate parameter values for each hyperparameter, and then combine the multiple candidate parameter values of each hyperparameter to obtain a combination of multiple parameter values, wherein each combination contains a candidate parameter value for each hyperparameter, and the candidate parameter values contained in every two combinations are different; then, for each combination, the image processing model is trained based on the candidate parameter values in the combination to obtain the trained model corresponding to the combination; finally, the candidate parameter values in the combination corresponding to the trained model with the best performance are selected as the hyperparameters of the image processing model.
[0004] Since the related technology requires multiple trainings to determine the hyperparameters, and the number of trainings increases exponentially with the number of candidate parameter values, the process of determining the hyperparameters often consumes a lot of time and computing resources, which makes the efficiency of determining the hyperparameters of the image processing model low. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a method, device and electronic device for determining the hyperparameters of an image processing model, so as to improve the efficiency of determining the hyperparameters of an image processing model. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for determining hyperparameters of an image processing model, the method comprising:
[0007] Obtaining the image size of the sample image used for training the image processing model as the target sample size;
[0008] According to a first association relationship between a sample size set and an input size set established in advance, an input size associated with the target sample size is determined as the size of the input image of the image processing model; wherein in the first association relationship, the sample size is positively correlated with the input size;
[0009] Calculating a batch size for training the image processing model based on the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0010] The number of iterations for training the image processing model is calculated based on designated information; wherein the designated information includes: the size of the determined input image, the total number of categories of the sample image and at least one of auxiliary information; the total number of categories of the sample image is the total number of categories of designated objects that need to be detected in the sample image; and the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0011] Optionally, obtaining the image size of the sample image for training the image processing model as the target sample size includes:
[0012] In the case where the image processing model is a first type of model, obtaining an image size of a sample image used to train the image processing model as a target sample size; wherein the first type of model is an image processing model that does not require determining a detection frame of an object contained in an image;
[0013] The method further comprises:
[0014] In the case where the image processing model is a second type of model, in a sample image used to train the image processing model, a ratio of an image area occupied by a specified object to be detected to an area of the sample image is determined as a target area ratio; wherein the second type of model is an image processing model that requires determination of a detection frame for a specified object in an image;
[0015] According to a second association relationship between a pre-established area ratio set and an input size set, an input size associated with the target area ratio is determined as the size of the input image of the image processing model; wherein, in the second association relationship, the area ratio is negatively correlated with the input size.
[0016] Optionally, the method further comprises:
[0017] In the case where the image processing model is an optical character recognition model, obtaining the number of characters in a sample image used for training the image processing model as the target number of characters;
[0018] According to a pre-established third association relationship between a character quantity set and an input size set, an input size associated with the target character quantity is determined as the size of the input image of the image processing model; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
[0019] Optionally, the calculating a batch size for training the image processing model according to the determined size of the input image and the size of a storage space allocated to the image processing model in a device for training the image processing model comprises:
[0020] According to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model, the batch size for training the image processing model is calculated according to a preset formula:
[0021] BatchSize = (R-Base) / add;
[0022] Among them, BatchSize represents the batch size used to train the image processing model; R represents the size of the storage space allocated for the image processing model in the device; Base represents the first calculation parameter calculated based on the determined size of the input image; add represents the second calculation parameter calculated based on the determined size of the input image.
[0023] Optionally, a method of calculating the first calculation parameter and the second calculation parameter includes:
[0024] When the size of the input image of the image processing model is the determined size of the input image and the batch size is a first preset value, determine the size of the storage space occupied when training the image processing model as the first storage size;
[0025] When the size of the input image of the image processing model is the determined size of the input image and the batch size is a second preset value, determining the size of the storage space required for training the image processing model as the second storage size;
[0026] According to the first preset value, the first storage size, the second preset value and the second storage size, the first calculation parameter and the second calculation parameter are obtained by solving the following formula:
[0027] R1 = Base + BatchSize1 * add;
[0028] R2 = Base + BatchSize2 * add;
[0029] Among them, Base represents the first calculation parameter; add represents the second calculation parameter; R1 represents the first storage size; R2 represents the second storage size; BatchSize1 represents the first preset value; BatchSize2 represents the second preset value.
[0030] Optionally, the calculating the number of iterations for training the image processing model based on the specified information includes:
[0031] Determining the number of iterations for training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient;
[0032] Among them, the target calculation coefficient is at least one of the first calculation coefficient, the second calculation coefficient, and the third calculation coefficient, or the product of at least two of them; the first calculation coefficient is: the calculation coefficient associated with the total number of categories of the sample image determined based on the fourth association relationship between the pre-established total number of categories set and the calculation coefficient set; in the fourth association relationship, the total number of categories is positively correlated with the calculation coefficient; the second calculation coefficient is: the calculation coefficient associated with the size of the determined image input determined based on the fifth association relationship between the pre-established image size set and the calculation coefficient set; in the fifth association relationship, the image size is negatively correlated with the calculation coefficient; when the auxiliary information represents that the image processing model is a pre-trained model, the third calculation coefficient is greater than 0 and less than 1; when the auxiliary information represents that the image processing model is a non-pre-trained model, the third calculation coefficient is equal to 1.
[0033] Optionally, determining the number of iterations for training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient includes:
[0034] Calculate the product of the preset initial iteration value and the target calculation coefficient to obtain the number of iterations to be used;
[0035] If the number of iterations to be used is less than the preset number of iterations, the preset number of iterations is used as the number of iterations for training the image processing model;
[0036] If the number of iterations to be used is not less than the preset number of iterations, the number of iterations to be used is used as the number of iterations for training the image processing model.
[0037] In a second aspect, an embodiment of the present application provides a device for determining hyperparameters of an image processing model, the device comprising:
[0038] A first size acquisition module, used to acquire the image size of a sample image used for training the image processing model as a target sample size;
[0039] A first size determination module, configured to determine an input size associated with the target sample size as the size of the input image of the image processing model according to a first association relationship between a sample size set and an input size set established in advance; wherein in the first association relationship, the sample size is positively correlated with the input size;
[0040] a batch size calculation module, configured to calculate a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0041] An iteration number calculation module is used to calculate the iteration number for training the image processing model based on specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0042] Optionally, the first size acquisition module is specifically used to acquire, when the image processing model is a first type of model, an image size of a sample image used to train the image processing model as a target sample size; wherein the first type of model is an image processing model that does not require determination of a detection frame of an object contained in the image;
[0043] The device further comprises: a second size acquisition module, which is used to determine, in a sample image used to train the image processing model, a ratio of an image area occupied by a designated object to be detected to an area of the sample image, as a target area ratio, when the image processing model is a second type of model; wherein the second type of model is an image processing model that needs to determine a detection frame of a designated object in an image;
[0044] The second size determination module is used to determine the input size associated with the target area ratio as the size of the input image of the image processing model according to a second association relationship between a pre-established area ratio set and an input size set; wherein, in the second association relationship, the area ratio is negatively correlated with the input size.
[0045] Optionally, the device further comprises: a third size acquisition module, for acquiring, when the image processing model is an optical character recognition model, the number of characters in a sample image used for training the image processing model as the target number of characters;
[0046] The third size determination module is used to determine the input size associated with the target number of characters as the size of the input image of the image processing model based on a third association relationship between a pre-established character quantity set and an input size set; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
[0047] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0048] Memory, used to store computer programs;
[0049] The processor is used to implement the hyperparameter determination method of the above-mentioned image processing model when executing the program stored in the memory.
[0050] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for determining the hyperparameters of the above-mentioned image processing model is implemented.
[0051] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described methods for determining hyperparameters of an image processing model.
[0052] Beneficial effects of the embodiments of the present application:
[0053] An embodiment of the present application provides a method for determining hyperparameters of an image processing model. When the image processing model to be trained is an image classification model or a semantic segmentation model, the image size of a sample image used to train the image processing model is obtained as a target sample size, and then according to a first association relationship between a pre-established sample size set and an input size set, an input size associated with the target sample size is determined as the size of the input image of the image processing model; wherein, in the first association relationship, the sample size is positively correlated with the input size; thereafter, according to the determined size of the input image and the size of the storage space allocated to the image processing model in a device for training the image processing model, the batch size for training the image processing model is calculated; and based on the determined size of the input image, the total number of categories of the sample image, and at least one of the auxiliary information of the image processing model, the number of iterations of the image processing model is calculated.
[0054] In this scheme, since the sample size is positively correlated with the input size, when the image size of the sample image is large, a larger input size is determined as a hyperparameter of the image processing model, so that the image information contained in the sample image can be fully utilized when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample image. It can be seen that this scheme ensures the optimality of the hyperparameter of the input image size, and then on this basis, the batch size and number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the image processing model, and this scheme can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and number of iterations of the image processing model. It can be seen that this scheme does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources and improve the efficiency of determining the hyperparameters of the image processing model.
[0055] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0057] Figure 1 A first flow chart of a method for determining hyperparameters of an image processing model provided in an embodiment of the present application;
[0058] Figure 2 A second flow chart of the method for determining hyperparameters of an image processing model provided in an embodiment of the present application;
[0059] Figure 3 A third flow chart of the method for determining hyperparameters of an image processing model provided in an embodiment of the present application;
[0060] Figure 4 A fourth flow chart of the method for determining hyperparameters of an image processing model provided in an embodiment of the present application;
[0061] Figure 5 A schematic diagram of the structure of a device for determining hyperparameters of an image processing model provided in an embodiment of the present application;
[0062] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0064] In the related art, multiple trainings are required to determine the hyperparameters of the image processing model, and the number of trainings increases exponentially with the number of candidate parameter values set for each hyperparameter. For example, if there are three hyperparameters to be determined, and 10 candidate parameter values are set for hyperparameter 1, hyperparameter 2, and hyperparameter 3, then a total of 10*10*10=1000 trainings are required to determine the final hyperparameters. It can be seen that the process of determining the hyperparameters of the related art often consumes a lot of time and computing resources, which makes the efficiency of determining the hyperparameters of the image processing model low.
[0065] In order to improve the efficiency of determining the hyperparameters of an image processing model, an embodiment of the present application provides a method for determining the hyperparameters of an image processing model. The method can be applied to various electronic devices, such as personal computers, servers, and other devices with data processing capabilities. Moreover, the method for determining the hyperparameters of an image processing model provided in the embodiment of the present application can be implemented by software, hardware, or a combination of software and hardware.
[0066] The method for determining the hyperparameters of the image processing model may include the following steps:
[0067] Obtaining the image size of the sample image used for training the image processing model as the target sample size;
[0068] According to a first association relationship between a sample size set and an input size set established in advance, an input size associated with a target sample size is determined as the size of an input image of an image processing model; wherein in the first association relationship, the sample size is positively correlated with the input size;
[0069] Calculating a batch size for training the image processing model based on the determined size of the input image and the size of the storage space allocated for the image processing model in the device for training the image processing model;
[0070] The number of iterations of the training image processing model is calculated based on the specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of the auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0071] In this embodiment, since the sample size is positively correlated with the input size, when the image size of the sample image is large, a larger input size is determined as a hyperparameter of the image processing model, so that the image information contained in the sample image can be fully utilized when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample image. It can be seen that this scheme ensures the optimality of the hyperparameter of the input image size, and then on this basis, the batch size and number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the image processing model, and this scheme can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and number of iterations of the image processing model. It can be seen that this scheme does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources, and improve the efficiency of determining the hyperparameters of the image processing model.
[0072] The following is an introduction to the method for determining the hyperparameters of the image processing model provided by an embodiment of the present invention in conjunction with the accompanying drawings.
[0073] like Figure 1 As shown, the method for determining the hyperparameters of the image processing model provided in the embodiment of the present invention may include the following steps:
[0074] S101, obtaining the image size of a sample image used for training an image processing model as a target sample size;
[0075] In one implementation, the image processing model may be a model for performing any image processing task, that is, the method steps S101 to S104 of this embodiment may be used to determine the hyperparameters of the image processing model for any image processing model.
[0076] In another implementation, when the image processing model is a first type of model, the method steps S101-S104 of this embodiment can be used to determine the hyperparameters of the image processing model; wherein the first type of model is an image processing model that does not require determining the detection box of the object contained in the image.
[0077] The detection box is used to represent the position of the specified object in the image. For example, the detection box can be represented by the minimum bounding rectangle of the specified object in the image.
[0078] The first type of model mentioned above can be an image classification model or a semantic segmentation model, wherein the image classification model refers to a model that only determines the category of objects contained in the image, for example, the category of the contained objects can be cats, dogs, etc.; the semantic segmentation model refers to a model that determines the category to which each pixel point in the image belongs, for example, the category to which each pixel point belongs can be cats, dogs, etc.
[0079] In this embodiment, when the image processing model is an image classification model or a semantic segmentation model, the image size of the sample image used to train the image processing model can be obtained as the target sample size, and then the hyperparameters of the image processing model can be determined based on the target sample size.
[0080] The image size refers to the pixel size of the image, such as 256*256. There may be multiple sample images for training the image processing model, and different sample images may be of uniform size or of different sizes. The sample images may be square images or non-square rectangular images. In case that the size of the sample images is not uniform, the area of each sample image may be calculated first, and then the average area of each sample image may be calculated, and the square root of the average area may be taken to obtain the average side length as the target sample size. Alternatively, the perimeter of each sample image may be calculated, and then the average perimeter of each sample image may be calculated as the target sample size.
[0081] S102, according to a first association relationship between a sample size set and an input size set established in advance, determining an input size associated with a target sample size as a size of an input image of an image processing model; wherein in the first association relationship, the sample size is positively correlated with the input size;
[0082] The size of the input image of the image processing model refers to the size of the image that the image processing model can process. It is understandable that when the image processing model is deployed and needs to process the image, the size of the input image has been determined. For example, the image that the image processing model can process is usually an image with equal length and width, that is, a square image. Therefore, in an embodiment of the present application, the size of the input image of the image processing model can be directly expressed in terms of side length. For example, the size of the input image is 64, which indicates that the input image is a square image with a side length of 64. In addition, when the image to be processed is different from the size of the input image of the image processing model, the size of the image to be input needs to be reduced or enlarged to adjust its size to the same size as the input image of the image processing model. For example, it can be adjusted by downsampling or upsampling.
[0083] In one implementation, the sample size set may include at least one sample size, the input size set may include at least one input size, and each input size is associated with a sample size. The first association relationship between the pre-established sample size set and the input size set may be a positively correlated functional relationship, that is, in the first association relationship, the larger the sample size, the larger the input size associated with it. In this implementation, the target sample size may be brought into the functional relationship to determine the input size associated with the target sample size.
[0084] Since the size of the image to be processed is different from the size of the input image of the image processing model, the size of the image to be processed needs to be adjusted. When the size of the image is reduced, information loss will occur, and when the size of the image is enlarged, information redundancy will occur. Therefore, the above-mentioned method of determining the input size associated with the target sample size as the size of the input image of the image processing model can be: determine the sample size with the smallest difference from the target sample size and larger than the target sample size in the sample size set as the size of the input image of the image processing model. In this way, when using the sample image to train the image processing model, there is no need to enlarge the size of the sample image too much, so it will not cause more information redundancy, and also avoid the information loss caused by reducing the size of the sample image.
[0085] Since the sample size and the input size both represent the size of the image, the associated sample size and input size can be equal in value. For example, the sample size set can include six sample sizes of 64, 128, 224, 288, 416, and 1024, and the input sizes associated with the six sample sizes are also 64, 128, 224, 288, 416, and 1024. In this implementation, when the target sample size is 200, the sample size in the sample size set that has the smallest difference with the target sample size and is larger than the target sample size, i.e., 224, can be determined as the size of the input image of the image processing model.
[0086] S103, calculating a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0087] The batch size of the training image processing model refers to the number of sample images selected for one training. Since the storage space occupied by the training image processing model increases with the size of the input image of the image processing model and the batch size of the training image processing model, the batch size of the training image processing model can be determined according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device used to train the image processing model.
[0088] In one implementation, after determining the size of the input image, in order to make full use of the size of the allocated storage space, the batch size can be determined in a step-by-step manner. For example, a smaller batch size M is first set to detect the size of the storage space to be occupied when training the image processing model according to the determined input image size and the batch size of M. If the detected size is smaller than the size of the allocated storage space, the value of the batch size can be increased, for example, the batch size is set to M+1, and so on. Ultimately, the maximum batch size that can be set when the size of the storage space to be occupied is smaller than the size of the storage space allocated for training the image processing model is determined as the batch size for training the image processing model.
[0089] S104, calculating the number of iterations of the training image processing model based on the specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of the auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0090] When training the image processing model, using all sample images to train the image processing model once is considered an iteration. In one implementation, the number of iterations of training the image processing model can be determined based on the product of a preset initial iteration value and a target calculation coefficient; wherein the target calculation coefficient is at least one of the first calculation coefficient, the second calculation coefficient, and the third calculation coefficient, or the product of at least two of them.
[0091] The first calculation coefficient is: a calculation coefficient associated with the total number of categories of the sample image determined based on a pre-established fourth association relationship between the total number of categories set and the calculation coefficient set; in the fourth association relationship, the total number of categories is positively correlated with the calculation coefficient;
[0092] The total number of categories of the above-mentioned sample images refers to the total number of categories of the specified objects that need to be detected in the sample images, and the total number of categories of the specified objects that need to be detected is determined based on the current detection requirements. For example, the current scene needs to detect pedestrians, cars, streets, and buildings in the image, and the total number of categories is 4. Since the total number of categories of the specified objects that need to be detected in the sample image is higher, the greater the difficulty of the task, it is necessary to increase the number of iterations of the training image processing model, so in the fourth association relationship, the total number of categories is positively correlated with the calculation coefficient. Exemplarily, the total number of categories can include three intervals, namely, an interval less than 5, an interval greater than or equal to 5 and less than or equal to 10, and an interval greater than 10, and the calculation coefficient set can include 3 calculation coefficients, which are 0.8, 1, and 1.2, respectively. Among them, in the fourth association relationship, the calculation coefficient associated with the interval less than 5 is 0.8; the calculation coefficient associated with the interval greater than or equal to 5 and less than or equal to 10 is 1; the calculation coefficient associated with the interval greater than 10 is 1.2. Furthermore, when the total number of categories of the sample image is less than 5, the first calculation coefficient can be determined to be 0.8; when the total number of categories of the sample image is greater than or equal to 5 and less than or equal to 10, the first calculation coefficient is 1; when the total number of categories of the sample image is greater than 10, the first calculation coefficient is 1.2.
[0093] The second calculation coefficient is: a calculation coefficient associated with the determined size of the image input determined based on a fifth association relationship between the pre-established image size set and the calculation coefficient set; in the fifth association relationship, the image size is negatively correlated with the calculation coefficient;
[0094] Since the size of the image input of the image processing model refers to the size of the image directly input into the image processing model, when the size of the image input is large, the image information of the sample image can be more fully utilized when training with the sample image, so that it is easier to have better performance after training. Therefore, when the size of the image input is large, a lower number of iterations can be selected, so in the fifth association relationship, the image size is negatively correlated with the calculation coefficient. Exemplarily, when the determined image input size is one of 64, 128, 224, 288, 416, and 1024, the image size set can include six image sizes of 64, 128, 224, 288, 416, and 1024, respectively, and the calculation coefficient set can include 3 calculation coefficients, which are 0.8, 1, and 1.2, respectively. Then in the fifth association relationship, when the image size is 64 or 128, the calculation coefficient associated therewith is 1.2; when the image size is 224 or 288, the calculation coefficient associated therewith is 1; when the image size is 416 or 1024, the calculation coefficient associated therewith is 0.8.
[0095] The third calculation coefficient may be determined in the following manner: when the auxiliary information representation image processing model is a pre-trained model, the third calculation coefficient is greater than 0 and less than 1, for example, it may be 0.8; when the auxiliary information representation image processing model is not a pre-trained model, the third calculation coefficient is equal to 1.
[0096] If the image processing model is a pretrained model, it means that before the image processing model is trained for the current task to be processed, the image processing model has been pre-trained based on other sample images. Therefore, when the image processing model is a pretrained model, the number of iterations of training the image processing model can be reduced. Therefore, when the auxiliary information represents that the image processing model is a pretrained model, the third calculation coefficient can be set to a value greater than 0 and less than 1.
[0097] In one implementation, after determining the product of the initial iteration value and the target calculation coefficient, the obtained product can be directly used as the number of iterations for training the image processing model.
[0098] It can be seen that in the present implementation, the determined input image size, the total number of categories of the sample image and / or the auxiliary information are utilized to determine the calculation coefficient according to a preset positive correlation or negative correlation, and then the number of iterations of the training image processing model is calculated. The number of iterations can be directly calculated using the characteristics of the model itself and / or the characteristics of the sample image, thereby improving the efficiency of determining the number of iterations of the training image processing model while ensuring the optimality of the obtained number of iterations.
[0099] In another implementation, the method for determining the number of iterations of the training image processing model based on the product of the preset initial iteration value and the target calculation coefficient may be:
[0100] Calculate the product of the preset initial iteration value and the target calculation coefficient to obtain the number of iterations to be used, and then determine whether the number of iterations to be used is less than the preset number of iterations. If the number of iterations to be used is less than the preset number of iterations, the preset number of iterations is used as the number of iterations for training the image processing model; if the number of iterations to be used is not less than the preset number of iterations, the number of iterations to be used is used as the number of iterations for training the image processing model. The preset number of iterations can be determined based on experience and needs. In this implementation, by setting the preset number of iterations, when the product of the calculated initial iteration value and the target calculation coefficient is small, the preset number of iterations can be used as the number of iterations for training the image processing model, so that the determined number of iterations is always not less than the preset number of iterations, so as to ensure sufficient training of the image processing model.
[0101] After determining the size of the input image of the image processing model, the batch size and the number of iterations for training the image processing model, the image processing model can be trained according to the determined size of the input image, the batch size and the number of iterations.
[0102] In this embodiment, since the sample size is positively correlated with the input size, when the image size of the sample image is large, a larger input size is determined as a hyperparameter of the image processing model, so that the image information contained in the sample image can be fully utilized when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample image. It can be seen that this scheme ensures the optimality of the hyperparameter of the input image size, and then on this basis, the batch size and number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the image processing model, and this scheme can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and number of iterations of the image processing model. It can be seen that this scheme does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources, and improve the efficiency of determining the hyperparameters of the image processing model.
[0103] Optionally, in another embodiment of the present application, Figure 2 As shown, the embodiment of the present application may include the following steps:
[0104] S201, when the image processing model is a second type of model, in a sample image used for training the image processing model, determining a ratio of an image area occupied by a specified object to be detected to an area of the sample image as a target area ratio; wherein the second type of model is an image processing model that needs to determine a detection frame of a specified object in an image;
[0105] The second type of model mentioned above can be: a target detection model, an instance segmentation model, or a character positioning model, etc. Among them, the target detection model and the instance segmentation model are used to identify the location of the specified object to be detected in the image and mark the category of each specified object. The specified object to be detected can be a human, an animal, etc.; the target detection model selects the specified object in the image in the form of a box, and the instance segmentation model is used to identify the category to which each pixel in the image belongs and distinguish the individuals of different specified objects in the image. The character positioning model is used to identify the location of the characters in the image, that is, the specified object to be detected is a character, and it can also represent the location of the characters in the image in the form of generating a detection box or a mask image. In the case where the location of the specified object is represented by a detection box, the ratio of the image area occupied by the specified object to be detected to the area of the sample image, that is, the ratio of the area of the detection box to the area of the sample image; in the case where the location of the specified object is represented by a mask image, the ratio of the image area occupied by the specified object to be detected to the area of the sample image, that is, the ratio of the number of pixels in the mask image representing the area of the specified object to the total number of pixels in the mask image.
[0106] Since there can be multiple sample images, we can first determine, for each sample image, the ratio of the image area occupied by the specified object to be detected in the sample image to the area of the sample image as the area ratio corresponding to the sample image, and then use the area ratio corresponding to each sample image as the target area ratio.
[0107] In addition, since there may be multiple specified objects in a sample image, for the sample image, the average area or the sum of the areas of the image area occupied by each specified object that needs to be detected in the sample image can be calculated, and the ratio of the average area or the sum of the areas to the area of the sample image can be calculated as the area ratio corresponding to the sample image.
[0108] S202, according to a pre-established second association relationship between the area ratio set and the input size set, determining an input size associated with the target area ratio as the size of the input image of the image processing model; wherein in the second association relationship, the area ratio is negatively correlated with the input size;
[0109] Since the larger the size of the input image of the image processing model, the more image information can be used during training. Therefore, when the ratio of the image area occupied by the specified object to be detected in the sample image to the area of the sample image is small, it is more necessary to make full use of the image information of the sample image. Therefore, in the second association relationship of the present embodiment, the area ratio is negatively correlated with the input size. The area ratio is negatively correlated with the input size, which can enable a larger input size to be determined as a hyperparameter of the image processing model when the ratio of the image area occupied by the specified object to be detected in the sample image to the area of the sample image is small, thereby making full use of the image information of the sample image when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample image.
[0110] In the case of multiple sample images, in one implementation, the area ratio set may include at least one area ratio, the input size set may include at least one input size, and each input image size is associated with an area ratio. Thus, after determining the area ratios corresponding to each sample image, the average of the area ratios corresponding to each sample image may be calculated, and then the input size associated with the average may be determined according to the second association relationship as the size of the input image of the image processing model.
[0111] Alternatively, in another implementation, the area ratio set may include multiple intervals, each interval representing a range of area ratios, and the input size set includes the input size associated with each interval. Therefore, after determining the area ratio corresponding to each sample image, the interval to which the area ratio corresponding to each sample image belongs can be determined, thereby counting the number of sample images corresponding to each interval, and taking the interval with the largest number of corresponding sample images as the target interval, and then determining the input size associated with the target interval. For example, in one implementation, the area ratio set may include four intervals: an interval less than 0.5%, an interval greater than or equal to 0.5% and less than 1%, an interval greater than or equal to 1% and less than 2.5%, and an interval greater than or equal to 2.5%, and the input size set may include four input sizes of 64, 288, 415, and 1024; the second association relationship may be characterized as: the input size associated with the interval less than 0.5% is 64; the input size associated with the interval greater than or equal to 0.5% and less than 1% is 288; the input size associated with the interval greater than or equal to 1% and less than 2.5% is 415; the input size associated with the interval greater than or equal to 2.5% is 1024.
[0112] After determining the area ratios corresponding to the various sample images, the first number of sample images corresponding to area ratios less than 0.5% can be counted; the second number of sample images corresponding to area ratios greater than or equal to 0.5% and less than 1% can be counted; the third number of sample images corresponding to area ratios greater than or equal to 1% and less than 2.5% can be counted; and the fourth number of sample images corresponding to area ratios greater than or equal to 2.5% can be counted; and then the interval corresponding to the maximum value among the first number, the second number, the third number and the fourth number can be determined as the target interval. For example, if the fourth number is the maximum value, then the interval of area ratios greater than or equal to 2.5% can be determined as the target interval, and then the input size associated with the target interval can be determined to be 1024 as the size of the input image of the image processing model.
[0113] S203, calculating a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0114] S204, calculating the number of iterations of the training image processing model based on the specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of the auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0115] The above steps S203-S204 are similar to steps S103-S104 and will not be described again.
[0116] In this embodiment, when the image processing model is a target detection model, an instance segmentation model or a character positioning model, the optimality of the input image size hyperparameter can be guaranteed. On this basis, the batch size and the number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the image processing model batch size and the number of iterations. In addition, this solution can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and the number of iterations of the image processing model. It can be seen that this solution does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources and improve the efficiency of determining the hyperparameters of the image processing model.
[0117] Optionally, in another embodiment of the present application, Figure 3 As shown, the embodiment of the present application may include the following steps:
[0118] S301, when the image processing model is an optical character recognition model, obtaining the number of characters in a sample image used for training the image processing model as the target number of characters;
[0119] The optical character recognition model is a model for recognizing the character content of characters contained in an image. In the case of multiple sample images, the average number of characters in each sample image or the maximum number can be determined as the target number of characters, but it is not limited to this.
[0120] S302, according to a pre-established third association relationship between a character quantity set and an input size set, determine an input size associated with a target character quantity as the size of an input image of an image processing model; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
[0121] The larger the size of the input image of the image processing model, the more image information can be used during training, and the more characters there are in the sample image, the more necessary it is to fully utilize the image information of the sample image. Therefore, in the third association relationship of the present embodiment, the number of characters is positively correlated with the input size. When the number of characters in the sample image is large, a larger input size can be determined as a hyperparameter of the image processing model, thereby making full use of the image information of the sample image when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample images.
[0122] Similarly, in one implementation, the character quantity set may include multiple intervals, each interval represents a range of character quantity, and the input size set may include an input size associated with each interval; for example, the character quantity set may include intervals less than or equal to 20 and intervals greater than 20; the input size set may include two input sizes: 32*320 and 32*640; the second association relationship may be characterized as: the input size associated with the interval less than or equal to 20 is 32*320; the input size associated with the interval greater than 20 is 32*640. In this implementation, when the target character quantity is less than or equal to 20, the size of the input image of the image processing model is determined to be 32*320, and when the target character quantity is greater than 20, the size of the input image of the image processing model is determined to be 32*640.
[0123] S303, calculating a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0124] S304, calculating the number of iterations of the training image processing model based on the specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of the auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
[0125] The above steps S303-S304 are similar to steps S103-S104 and will not be repeated here.
[0126] In this embodiment, when the image processing model is an optical character recognition model, the optimality of the hyperparameter of the size of the input image can be guaranteed. On this basis, the batch size and the number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the batch size and the number of iterations of the image processing model. In addition, this solution can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and the number of iterations of the image processing model. It can be seen that this solution does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources and improve the efficiency of determining the hyperparameters of the image processing model.
[0127] Optionally, in one implementation, the step of calculating the batch size of the training image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model may include:
[0128] According to the determined size of the input image and the size of the storage space allocated for the image processing model in the device used to train the image processing model, the batch size of the training image processing model is calculated according to a preset formula:
[0129] BatchSize = (R-Base) / add;
[0130] Wherein, BatchSize represents the batch size of the image processing model; R represents the size of the storage space allocated for the image processing model in the device; Base represents the first calculation parameter calculated based on the determined size of the input image; add represents the second calculation parameter calculated based on the determined size of the input image;
[0131] The device used to train the image processing model may be a GPU (Graphics Processing Unit, visual processor), and the size of the storage space may be the size of the GPU's video memory. Since there is a linear relationship between the size of the storage space occupied by the training image processing model and the batch size when the size of the input image is determined, that is, R=Base+BatchSize*add, after determining the first calculation parameter Base and the second calculation parameter add, the batch size can be directly calculated according to the size of the storage space allocated for the image processing model in the device.
[0132] In one implementation, the first calculation parameter and the second calculation parameter may be calculated in the following manner:
[0133] Step A1, when the size of the input image of the image processing model is the determined size of the input image and the batch size is a first preset value, determine the size of the storage space occupied when training the image processing model as the first storage size;
[0134] Step A2, when the size of the input image of the image processing model is the determined size of the input image and the batch size is a second preset value, determine the size of the storage space required for training the image processing model as the second storage size;
[0135] Step A3, according to the first preset value, the first storage size, the second preset value and the second storage size, the first calculation parameter and the second calculation parameter are obtained by solving the following formula:
[0136] R1 = Base + BatchSize1 * add;
[0137] R2 = Base + BatchSize2 * add;
[0138] Among them, Base represents the first calculation parameter; add represents the second calculation parameter; R1 represents the first storage size; R2 represents the second storage size; BatchSize1 represents the first preset value; BatchSize2 represents the second preset value.
[0139] Since there is a linear relationship between the storage space occupied by the training image processing model and the batch size, two batch sizes can be preset: a first preset value and a second preset value, and the storage size occupied when the batch size is the first preset value and the second preset value can be detected respectively. The first calculation parameter and the second calculation parameter can be solved by solving equations.
[0140] In this embodiment, the efficiency of determining the hyperparameters of the image processing model is improved. Furthermore, by utilizing the linear relationship between the size of the storage space occupied by the training image processing model and the batch size, the batch size for training the image processing model is calculated according to the size of the determined input image and the size of the storage space allocated to the image processing model in the device for training the image processing model, and a more optimal batch size for training the image processing model can be determined without multiple trainings, which can save time and computing resources and improve the efficiency of determining the hyperparameters of the image processing model.
[0141] For ease of understanding, the embodiments of the present application are exemplarily described below with reference to the accompanying drawings. Figure 4 As shown, the method for determining the hyperparameters of the image processing model provided in the embodiment of the present application may include the following steps:
[0142] The first step is to obtain the data used to train the image processing model and organize it into a data set in a unified format. The data set can include sample images and true value labels annotated for the sample images. For example, the true value labels can be: the image category of the sample image, the location and category of the specified object to be detected in the sample image, the characters contained in the sample image, etc.
[0143] The second step is to perform feature statistics on the data set, that is, to determine the image size of the sample image, the ratio of the image area occupied by the specified object to be detected to the area of the sample image, the total number of categories of the specified object, the number of characters, etc.
[0144] The third step is to select the size of the input image of the image processing model based on the statistical features. For example, when the image processing model to be trained is an image classification model or a semantic segmentation model, the input size associated with the target sample size can be determined according to a first association relationship between a pre-established sample size set and an input size set, as the size of the input image of the image processing model.
[0145] The fourth step is to calculate the batch size according to the size of the input image of the image processing model and the computing power resources, where the computing power resources refer to the size of the storage space allocated to the image processing model in the device for training the image processing model.
[0146] The fifth step is to calculate the number of iterations of the training image processing model based on the specified information, and to impose a minimum iteration limit, that is, when the calculated number of iterations is less than the preset number of iterations, the preset number of iterations is used as the number of iterations of the image processing model; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image, and at least one of the auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information represents: whether the image processing model is a pre-trained model.
[0147] In the sixth step, the determined input image size, batch size, and number of iterations are used as recommended parameters for training the image processing model.
[0148] The embodiment provided by the present application combines the attribute characteristics of the sample image (i.e., image size) and the attribute characteristics of the true value label (i.e., the ratio of the image area occupied by the specified object to be detected to the area of the sample image, the total number of categories of the specified object, the number of characters, etc.) to recommend hyperparameters. Compared with the method of obtaining the preferred hyperparameters through multiple trainings in the related art, the embodiment of the present application does not require additional training costs. It only needs to perform feature analysis on the data set to directly recommend hyperparameters, saving a lot of training time and computing resources. And the performance of the trained model obtained by training the image processing model using the hyperparameters determined by the present application is not much different from the performance of the trained model obtained by using the hyperparameters determined by the related art.
[0149] In this embodiment, since the sample size is positively correlated with the input size, when the image size of the sample image is large, a larger input size is determined as a hyperparameter of the image processing model, so that the image information contained in the sample image can be fully utilized when training the image processing model, thereby ensuring the performance of the image processing model trained using the sample image. It can be seen that this scheme ensures the optimality of the hyperparameter of the input image size, and then on this basis, the batch size and number of iterations of the image processing model are calculated, which can ensure the optimality of the two hyperparameters of the image processing model, and this scheme can directly use the first association relationship to determine the size of the input image of the image processing model, and then calculate the batch size and number of iterations of the image processing model. It can be seen that this scheme does not require multiple trainings to determine the better hyperparameters, which can save time and computing resources, and improve the efficiency of determining the hyperparameters of the image processing model.
[0150] Based on the same inventive concept, the embodiment of the present application also provides a device for determining hyperparameters of an image processing model, such as Figure 5 Said device comprises:
[0151] A first size acquisition module 501 is used to acquire the image size of a sample image used for training the image processing model as a target sample size;
[0152] A first size determination module 502 is used to determine an input size associated with the target sample size as the size of the input image of the image processing model according to a first association relationship between a sample size set and an input size set established in advance; wherein in the first association relationship, the sample size is positively correlated with the input size;
[0153] A batch size calculation module 503, used to calculate a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model;
[0154] The iteration number calculation module 504 is used to calculate the iteration number of training the image processing model based on specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates whether the image processing model is a pre-trained model.
[0155] Optionally, the first size acquisition module 501 is specifically used to acquire the image size of a sample image used to train the image processing model as a target sample size when the image processing model is a first type of model; wherein the first type of model is an image processing model that does not require determining a detection frame of an object contained in the image;
[0156] The device further comprises: a second size acquisition module, which is used to determine, in a sample image used to train the image processing model, a ratio of an image area occupied by a designated object to be detected to an area of the sample image, as a target area ratio, when the image processing model is a second type of model; wherein the second type of model is an image processing model that needs to determine a detection frame of a designated object in an image;
[0157] The second size determination module is used to determine the input size associated with the target area ratio as the size of the input image of the image processing model according to a second association relationship between a pre-established area ratio set and an input size set; wherein, in the second association relationship, the area ratio is negatively correlated with the input size.
[0158] Optionally, the device further comprises: a third size acquisition module, for acquiring, when the image processing model is an optical character recognition model, the number of characters in a sample image used for training the image processing model as the target number of characters;
[0159] The third size determination module is used to determine the input size associated with the target number of characters as the size of the input image of the image processing model based on a third association relationship between a pre-established character quantity set and an input size set; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
[0160] Optionally, the batch size calculation module 503 is specifically used to calculate the batch size for training the image processing model according to a preset formula based on the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model:
[0161] BatchSize = (R-Base) / add;
[0162] Among them, BatchSize represents the batch size used to train the image processing model; R represents the size of the storage space allocated for the image processing model in the device; Base represents the first calculation parameter calculated based on the determined size of the input image; add represents the second calculation parameter calculated based on the determined size of the input image.
[0163] Optionally, a method of calculating the first calculation parameter and the second calculation parameter includes:
[0164] When the size of the input image of the image processing model is the determined size of the input image and the batch size is a first preset value, determine the size of the storage space occupied when training the image processing model as the first storage size;
[0165] When the size of the input image of the image processing model is the determined size of the input image and the batch size is a second preset value, determining the size of the storage space required for training the image processing model as the second storage size;
[0166] According to the first preset value, the first storage size, the second preset value and the second storage size, the first calculation parameter and the second calculation parameter are obtained by solving the following formula:
[0167] R1 = Base + BatchSize1 * add;
[0168] R2 = Base + BatchSize2 * add;
[0169] Among them, Base represents the first calculation parameter; add represents the second calculation parameter; R1 represents the first storage size; R2 represents the second storage size; BatchSize1 represents the first preset value; BatchSize2 represents the second preset value.
[0170] Optionally, the iteration number calculation module 504 is specifically used to determine the iteration number of training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient;
[0171] Among them, the target calculation coefficient is at least one of the first calculation coefficient, the second calculation coefficient, and the third calculation coefficient, or the product of at least two of them; the first calculation coefficient is: the calculation coefficient associated with the total number of categories of the sample image determined based on the fourth association relationship between the pre-established total number of categories set and the calculation coefficient set; in the fourth association relationship, the total number of categories is positively correlated with the calculation coefficient; the second calculation coefficient is: the calculation coefficient associated with the size of the determined image input determined based on the fifth association relationship between the pre-established image size set and the calculation coefficient set; in the fifth association relationship, the image size is negatively correlated with the calculation coefficient; when the auxiliary information represents that the image processing model is a pre-trained model, the third calculation coefficient is greater than 0 and less than 1; when the auxiliary information represents that the image processing model is a non-pre-trained model, the third calculation coefficient is equal to 1.
[0172] Optionally, the iteration number calculation module 504 determines the iteration number for training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient, including:
[0173] Calculate the product of the preset initial iteration value and the target calculation coefficient to obtain the number of iterations to be used;
[0174] If the number of iterations to be used is less than the preset number of iterations, the preset number of iterations is used as the number of iterations for training the image processing model;
[0175] If the number of iterations to be used is not less than the preset number of iterations, the number of iterations to be used is used as the number of iterations for training the image processing model.
[0176] The present application also provides an electronic device, such as Figure 6 As shown, including:
[0177] Memory 601, used for storing computer programs;
[0178] The processor 602 is used to implement the steps of the method for determining the hyperparameters of any of the above-mentioned image processing models when executing the program stored in the memory 601.
[0179] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 602, the communication interface, and the memory 601 communicate with each other via the communication bus.
[0180] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0181] The communication interface is used for communication between the above electronic device and other devices.
[0182] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0183] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0184] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the method for determining the hyperparameters of any of the above-mentioned image processing models are implemented.
[0185] In another embodiment provided in the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute the method for determining the hyperparameters of any image processing model in the above embodiments.
[0186] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), etc.
[0187] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0188] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0189] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A method for determining hyperparameters of an image processing model, characterized in that: The method comprises: Obtaining the image size of the sample image used for training the image processing model as the target sample size; According to a first association relationship between a sample size set and an input size set established in advance, an input size associated with the target sample size is determined as the size of the input image of the image processing model; wherein in the first association relationship, the sample size is positively correlated with the input size; Calculating a batch size for training the image processing model based on the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model; The number of iterations for training the image processing model is calculated based on designated information; wherein the designated information includes: the size of the determined input image, the total number of categories of the sample image and at least one of auxiliary information; the total number of categories of the sample image is the total number of categories of designated objects that need to be detected in the sample image; and the auxiliary information indicates: whether the image processing model is a pre-trained model.
2. The method according to claim 1, characterized in that The step of obtaining the image size of the sample image used for training the image processing model as the target sample size includes: In the case where the image processing model is a first type of model, obtaining an image size of a sample image used to train the image processing model as a target sample size; wherein the first type of model is an image processing model that does not require determining a detection frame of an object contained in an image; The method further comprises: In the case where the image processing model is a second type of model, in a sample image used to train the image processing model, a ratio of an image area occupied by a specified object to be detected to an area of the sample image is determined as a target area ratio; wherein the second type of model is an image processing model that requires determination of a detection frame for a specified object in an image; According to a second association relationship between a pre-established area ratio set and an input size set, an input size associated with the target area ratio is determined as the size of the input image of the image processing model; wherein, in the second association relationship, the area ratio is negatively correlated with the input size.
3. The method according to claim 2, characterized in that The method further comprises: In the case where the image processing model is an optical character recognition model, obtaining the number of characters in a sample image used for training the image processing model as the target number of characters; According to a pre-established third association relationship between a character quantity set and an input size set, an input size associated with the target character quantity is determined as the size of the input image of the image processing model; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
4. The method according to any one of claims 1 to 3, characterized in that: The step of calculating a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model comprises: According to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model, the batch size for training the image processing model is calculated according to a preset formula: BatchSize = (R-Base) / add; Among them, BatchSize represents the batch size used to train the image processing model; R represents the size of the storage space allocated for the image processing model in the device; Base represents the first calculation parameter calculated based on the determined size of the input image; add represents the second calculation parameter calculated based on the determined size of the input image.
5. The method according to claim 4, characterized in that The method of calculating the first calculation parameter and the second calculation parameter includes: When the size of the input image of the image processing model is the determined size of the input image and the batch size is a first preset value, determine the size of the storage space occupied when training the image processing model as the first storage size; When the size of the input image of the image processing model is the determined size of the input image and the batch size is a second preset value, determining the size of the storage space required for training the image processing model as the second storage size; According to the first preset value, the first storage size, the second preset value and the second storage size, the first calculation parameter and the second calculation parameter are obtained by solving the following formula: R1 = Base + BatchSize1 * add; R2 = Base + BatchSize2 * add; Among them, Base represents the first calculation parameter; add represents the second calculation parameter; R1 represents the first storage size; R2 represents the second storage size; BatchSize1 represents the first preset value; BatchSize2 represents the second preset value.
6. The method according to any one of claims 1 to 3, characterized in that: The calculating the number of iterations for training the image processing model based on the specified information comprises: Determining the number of iterations for training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient; Among them, the target calculation coefficient is at least one of the first calculation coefficient, the second calculation coefficient, and the third calculation coefficient, or the product of at least two of them; the first calculation coefficient is: the calculation coefficient associated with the total number of categories of the sample image determined based on the fourth association relationship between the pre-established total number of categories set and the calculation coefficient set; in the fourth association relationship, the total number of categories is positively correlated with the calculation coefficient; the second calculation coefficient is: the calculation coefficient associated with the size of the determined image input determined based on the fifth association relationship between the pre-established image size set and the calculation coefficient set; in the fifth association relationship, the image size is negatively correlated with the calculation coefficient; when the auxiliary information represents that the image processing model is a pre-trained model, the third calculation coefficient is greater than 0 and less than 1; when the auxiliary information represents that the image processing model is a non-pre-trained model, the third calculation coefficient is equal to 1.
7. The method according to claim 6, characterized in that The step of determining the number of iterations for training the image processing model based on the product of a preset initial iteration value and a target calculation coefficient comprises: Calculate the product of the preset initial iteration value and the target calculation coefficient to obtain the number of iterations to be used; If the number of iterations to be used is less than the preset number of iterations, the preset number of iterations is used as the number of iterations for training the image processing model; If the number of iterations to be used is not less than the preset number of iterations, the number of iterations to be used is used as the number of iterations for training the image processing model.
8. A device for determining hyperparameters of an image processing model, characterized in that: The device comprises: A first size acquisition module, used to acquire the image size of a sample image used for training the image processing model as a target sample size; A first size determination module, configured to determine an input size associated with the target sample size as the size of the input image of the image processing model according to a first association relationship between a sample size set and an input size set established in advance; wherein in the first association relationship, the sample size is positively correlated with the input size; a batch size calculation module, configured to calculate a batch size for training the image processing model according to the determined size of the input image and the size of the storage space allocated to the image processing model in the device for training the image processing model; An iteration number calculation module is used to calculate the iteration number for training the image processing model based on specified information; wherein the specified information includes: the size of the determined input image, the total number of categories of the sample image and at least one of auxiliary information; the total number of categories of the sample image is the total number of categories of the specified objects that need to be detected in the sample image; the auxiliary information indicates: whether the image processing model is a pre-trained model.
9. The device according to claim 8, characterized in that The first size acquisition module is specifically used to acquire the image size of the sample image used to train the image processing model as the target sample size when the image processing model is a first type of model; wherein the first type of model is an image processing model that does not require determining a detection frame of an object contained in the image; The device further comprises: a second size acquisition module, which is used to determine, in a sample image used to train the image processing model, a ratio of an image area occupied by a designated object to be detected to an area of the sample image, as a target area ratio, when the image processing model is a second type of model; wherein the second type of model is an image processing model that needs to determine a detection frame of a designated object in an image; The second size determination module is used to determine the input size associated with the target area ratio as the size of the input image of the image processing model according to a second association relationship between a pre-established area ratio set and an input size set; wherein, in the second association relationship, the area ratio is negatively correlated with the input size.
10. The device according to claim 8, characterized in that The device further comprises: a third size acquisition module, for acquiring, when the image processing model is an optical character recognition model, the number of characters in a sample image used for training the image processing model as the target number of characters; The third size determination module is used to determine the input size associated with the target number of characters as the size of the input image of the image processing model based on a third association relationship between a pre-established character quantity set and an input size set; wherein, in the third association relationship, the character quantity is positively correlated with the input size.
11. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.