HDR switch control model training method, electronic device, and storage medium
By training an HDR switch control model and utilizing image feature sample data and a deep learning network, the camera's HDR function can be automatically controlled, solving the problem of high user operation threshold, improving image quality, and optimizing device resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2026-04-07
AI Technical Summary
Users need to manually control the camera's HDR function switch, which has a high barrier to entry, leading to the camera being turned on or off at inappropriate times, affecting image quality and increasing the device's computing costs.
An HDR switch control model is trained using image feature sample data. By utilizing a densely connected channel rearrangement module and a deep learning network, the HDR function is automatically controlled to turn on or off based on the brightness characteristics of the captured image.
It enables automatic control of HDR switching in different scenarios, reducing the user's operating threshold, improving image quality, and reducing device computing costs and memory resource waste.
Smart Images

Figure CN117274693B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and particularly relates to an HDR switch control model training method, an electronic device and a storage medium. BACKGROUND
[0002] The HDR (High Dynamic Range Imaging) technology is a high dynamic range technology for image processing, which can obtain an image with a wider dynamic range by synthesizing multiple images with different exposure levels, so that the picture is more realistic and the details are more abundant. The current HDR technology has been widely applied to the camera functions of various mobile devices with camera functions, such as mobile phones and cameras. However, in actual application, users need to manually control the HDR function switch to turn on the HDR function at the right time, otherwise the picture will flicker, distort, and the transition will be unnatural. Turning on the HDR function at the right time has a high operation threshold for ordinary users. SUMMARY
[0003] The main purpose of the present application is to provide an HDR switch control model training method, an electronic device and a storage medium, which aims to solve the technical problem that the manual switching of the camera HDR function has a high operation threshold for users.
[0004] To achieve the above purpose, the present application provides an HDR switch control model training method, which comprises the following steps:
[0005] training a first HDR switch control model by using image feature sample data to obtain a second HDR switch control model;
[0006] When the number of training reaches a preset number, whether the second HDR switch control model meets a preset condition is determined according to a prediction result output by the second HDR switch control model and a corresponding true label, wherein the prediction result and the true label both include an HDR function switch state;
[0007] If yes, the second HDR switch control model is set as a third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to a photographed image;
[0008] If no, the model parameters of the second HDR switch control model are updated and set as the first HDR switch control model, and the step of training the first HDR switch control model by using image feature sample data is returned.
[0009] Optionally, before the step of training the first HDR switch control model by the image feature sample data, the method further comprises:
[0010] building a first HDR switch control model based on a preset model framework, wherein the first HDR switch control model comprises at least one densely connected channel rearrangement module, the channel rearrangement module comprises a channel rearrangement layer and a plurality of convolutional pooling layers connected to each other, and the channel rearrangement layer is located between each of the convolutional pooling layers;
[0011] initializing model parameters of the first HDR switch control model.
[0012] Optionally, the image feature sample data comprises a plurality of feature samples, and before the step of training the first HDR switch control model by the image feature sample data, the method further comprises:
[0013] collecting images under a plurality of scenes, wherein the images under each scene comprise at least a first light image and a second light image, and the brightness of the second light image is higher than that of the first light image;
[0014] extracting brightness features of each of the images to obtain feature samples corresponding to each of the images;
[0015] dividing each of the feature samples into training set data and test set data;
[0016] obtaining real labels corresponding to each of the feature samples, respectively.
[0017] Optionally, the step of training the first HDR switch control model by the image feature sample data comprises:
[0018] inputting a first feature sample in the training set data into the first HDR switch control model to obtain a first prediction result corresponding to the first feature sample;
[0019] inputting the first prediction result and a real label corresponding to the first feature sample into a preset loss function to obtain a first loss function value;
[0020] optimizing model parameters of the first HDR switch control model based on a change of the first loss function value to obtain a second HDR switch control model.
[0021] Optionally, the first HDR switch control model comprises a convolutional layer, a pooling layer, a densely connected channel rearrangement module, a global pooling layer, and a fully connected layer, and the step of inputting the first feature sample in the training set data into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample comprises:
[0022] inputting the first feature sample into a convolutional layer, extracting features of the first feature sample through the convolutional layer, and obtaining first feature data;
[0023] inputting the first feature data into a pooling layer, and generating second feature data;
[0024] inputting the second feature data into a densely connected channel rearrangement module, performing feature extraction and channel rearrangement on the second feature data through the channel rearrangement module, and obtaining third feature data;
[0025] inputting the third feature data into a global pooling layer, and generating fourth feature data;
[0026] inputting the fourth feature data into a fully connected layer, performing result prediction through the fully connected layer, and outputting a first prediction result.
[0027] Optionally, the preset condition at least includes convergence and a prediction accuracy threshold, and the step of judging whether the second HDR switch control model meets the preset condition according to the prediction result output by the second HDR switch control model and a corresponding true label includes:
[0028] inputting a second feature sample in the test set data into the second HDR switch control model, and obtaining a second prediction result corresponding to the second feature sample;
[0029] inputting the second prediction result and a true label corresponding to the second feature sample into a preset loss function, and obtaining a second loss function value;
[0030] judging whether the second HDR switch control model converges according to the second loss function value and a previous loss function value;
[0031] if the second HDR switch control model has converged, calculating a prediction accuracy of the second HDR switch control model according to the second prediction result and the true label corresponding to the second feature sample;
[0032] when the prediction accuracy is not less than a prediction accuracy threshold, determining that the second HDR switch control model meets the preset condition;
[0033] if the second HDR switch control model does not converge or the prediction accuracy is less than the prediction accuracy threshold, determining that the second HDR switch control model does not meet the preset condition.
[0034] Optionally, after the step of setting the second HDR switch control model as a third HDR switch control model, the method further includes:
[0035] The third HDR switch control model is cross-compiled to obtain an executable file corresponding to the third HDR switch control model;
[0036] The executable file is deployed offline in the camera device.
[0037] Optionally, after the step of deploying the executable file offline in the camera device, the method further comprises:
[0038] When the camera device is turned on, inputting a brightness feature corresponding to a currently captured scene image into a third HDR switch control model corresponding to the executable file;
[0039] Predicting, by the third HDR switch control model, an HDR function switch state corresponding to the scene image, and outputting a current prediction result;
[0040] If the current prediction result is off, turning off the HDR function of the camera device;
[0041] If the current prediction result is on, turning on the HDR function of the camera device.
[0042] The application also provides an HDR switch control model training device, which is applied to an HDR switch control model training apparatus, and comprises:
[0043] A model training module is configured to train a first HDR switch control model by using image feature sample data to obtain a second HDR switch control model;
[0044] A model evaluation module is configured to, when a training frequency reaches a preset frequency, judge whether the second HDR switch control model meets a preset condition according to a prediction result output by the second HDR switch control model and a corresponding true label, wherein the prediction result and the true label both include an HDR function switch state.
[0045] A model determination module is configured to set the second HDR switch control model as a third HDR switch control model, wherein the third HDR switch control model is used to control an HDR function switch according to a captured image.
[0046] An iterative optimization module is configured to, if not, update model parameters of the second HDR switch control model and set the second HDR switch control model as the first HDR switch control model, and return to the step of training the first HDR switch control model by using image feature sample data.
[0047] The application further provides an electronic device, which is a physical device, comprising a memory, a processor, and a program of the HDR switch control model training method stored in the memory and executable on the processor, which can realize the steps of the HDR switch control model training method as described above when executed by the processor.
[0048] The application further provides a computer readable storage medium having a program of the HDR switch control model training method stored thereon, which can realize the steps of the HDR switch control model training method as described above when executed by the processor.
[0049] The application further provides a computer program product comprising a computer program, which can realize the steps of the HDR switch control model training method as described above when executed by the processor.
[0050] The application provides an HDR switch control model training method, an electronic device, and a storage medium. First, a first HDR switch control model is trained by image feature sample data to obtain a second HDR switch control model. When the number of training reaches a preset number, whether the second HDR switch control model meets a preset condition is determined according to a prediction result output by the second HDR switch control model and a corresponding real label. The prediction result and the real label both include an HDR function switch state. If yes, the second HDR switch control model is set as a third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to a photographed image. If no, a model parameter of the second HDR switch control model is updated and set as the first HDR switch control model, and the step of training the first HDR switch control model by image feature sample data is returned. In the technical solution of the application, the first HDR switch control model is trained by image feature sample data, the obtained second HDR switch control model is evaluated when the number of training reaches the preset number, and the third HDR switch control model meeting the preset condition is obtained. The third HDR switch control model can control the state of the HDR function switch according to the currently photographed image when a user uses a camera device to shoot, can automatically turn on the HDR function of the camera at a suitable time, does not need manual operation of the user, reduces the operation threshold of the user, and enables the camera to shoot higher quality and performance images at a suitable time. BRIEF DESCRIPTION OF DRAWINGS
[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and serve to explain the principles of the application.
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those of ordinary skill in the art, the accompanying drawings can obtain other drawings based on these drawings without any creative effort.
[0053] Figure 1 The flowchart of the first embodiment of the HDR switch control model training method of the present application is shown in the figure.
[0054] Figure 2 The overall framework flowchart of the HDR switch control model training method of the present application is shown in the figure.
[0055] Figure 3 The data flow direction diagram of the densely connected channel rearrangement module in the HDR switch control model training method of the present application is shown in the figure.
[0056] Figure 4 The specific architecture diagram of the HDR switch control model in the HDR switch control model training method of the present application is shown in the figure.
[0057] Figure 5 The flowchart of rearranging the channel order within the group through the channel rearrangement layer in the HDR switch control model training method of the present application is shown in the figure.
[0058] Figure 6 The flowchart of the second embodiment of the HDR switch control model training method of the present application is shown in the figure.
[0059] Figure 7 The composition structure diagram of the HDR switch control model training device in the embodiment of the present application is shown in the figure.
[0060] Figure 8 The device structure diagram of the hardware running environment involved in the HDR switch control model training method in the embodiment of the present application is shown in the figure.
[0061] The purpose realization, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0062] In order to make the above-mentioned purposes, features and advantages of the present application more apparent and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative effort fall within the scope of protection of the present application.
[0063] Embodiment one
[0064] At present, HDR technology has become one of the common functions in digital cameras and smart phones, which can improve the brightness range and color details of images, making the images more realistic, natural and artistic. HDR technology can be applied to landscape photography, indoor shooting, portrait photography and other application scenarios. When shooting landscape photos in strong sunlight, HDR technology can retain the details of the sky and the ground, and avoid the occurrence of overexposure or overexposure. When shooting indoors, HDR technology can retain the details of the dark and bright parts, and avoid the occurrence of overexposure or overexposure. The embodiments of the present application aim to solve the problem of HDR technology in actual application, that is, how to automatically control the HDR switch in different scenes to obtain more realistic, natural and artistic images. Although HDR technology can improve the brightness range and color details of images, in actual application, users need to manually control the HDR switch and select the appropriate HDR mode and parameters, which may cause inconvenience to ordinary users, and if the HDR function is always turned on, it will also increase the computing cost of the device and waste memory resources. The embodiments of the present application train an HDR switch control model for automatically controlling the HDR function according to the currently captured image, thereby realizing the automatic control of the HDR function switch to solve the above technical problems.
[0065] The embodiments of the present application provide an HDR switch control model training method. In the first embodiment of the HDR switch control model training method of the present application, referring to Figure 1 , the HDR switch control model training method comprises:
[0066] Step S10, training the first HDR switch control model through image feature sample data to obtain a second HDR switch control model;
[0067] Step S20, when the training times reach the preset times, judging whether the second HDR switch control model meets the preset condition according to the prediction result output by the second HDR switch control model and the corresponding true label, the prediction result and the true label both include the HDR function switch state;
[0068] Step S30, if yes, setting the second HDR switch control model as a third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to the captured image;
[0069] Step S40, if no, updating the model parameters of the second HDR switch control model and setting it as the first HDR switch control model, and returning to execute the step of training the first HDR switch control model through image feature sample data.
[0070] In the embodiments of the present application, it should be noted that the image feature sample data is feature data extracted from images collected by a camera in various scenes, for example, statistical values (brightness) of the Y channel of the camera YUV (color coding) domain. In addition, the first HDR switch control model is a deep learning network model that has been initialized and completed, and can output a prediction result according to input data processing, wherein the prediction result can be off or on. After the number of training reaches a preset number (for example, 500 times), the prediction result output by the second HDR switch control model and the true label corresponding to the image feature sample data can be used to determine whether the second HDR switch control model meets the preset condition. It should be noted that the prediction result output by the second HDR switch control model is obtained by inputting the image feature sample data (for example, test set data) into the second HDR switch control model. The preset condition can include function loss value, prediction accuracy, or mean square error, etc. In addition, the true label is a label marked by a person according to whether the image corresponding to the image feature sample data needs to open the HDR function.
[0071] In addition, it should be noted that the first HDR switch control model is an initially established deep learning network model, the second HDR switch control model is a deep learning network model that has been trained, and the third HDR switch control model is a final deep learning network model that meets the preset condition and can be applied to a camera device. When the second HDR switch control model does not meet the preset condition, it is set to the first HDR switch control model, which only means that its name is modified, and the model does not change in essence, which is to make the description consistent when step S40 and step S10 form a loop execution step.
[0072] As an example, steps S10 to S40 include: obtaining image feature sample data, wherein the image feature sample data is luminance feature data corresponding to an image captured by a camera, which can be luminance values corresponding to each pixel point in the image; training a first HDR switch control model that is pre-established by using training set data in the image feature sample data and corresponding true labels to update model parameters in the first HDR switch control model, and naming the trained model as a second HDR switch control model; when the number of times of training of the model reaches a preset number of times, stopping the training, inputting test set data in the image feature sample data into the second HDR switch control model, predicting feature samples in the test set data by using the second HDR switch control model, and outputting a prediction result, wherein the prediction result is to be opened or closed; obtaining true labels corresponding to each feature sample in the test set sample; calculating a loss function value according to the prediction result and the true labels, and calculating a prediction accuracy of the second HDR switch control model according to the prediction result and the true labels after the loss function value is stable; if the prediction accuracy meets a prediction accuracy threshold, the training is successful, and the second HDR switch control model is set as a third HDR switch control model, which is used to control an HDR function switch according to a captured image; if the loss function is unstable or the prediction accuracy does not meet the prediction accuracy threshold, the second HDR switch control model is named as the first HDR switch control model, and steps S10 to S20 are continuously executed to continuously train the HDR switch control model and iteratively optimize parameters until a second HDR switch control model that meets a preset condition is obtained.
[0073] In an alternative embodiment, with reference to Figure 2 , the overall flowchart of the HDR switch control model training method inputs image feature sample data into a pre-established HDR switch control model (a first HDR switch control model or a second HDR switch control model), and outputs a prediction result. True labels corresponding to each feature sample in the image feature sample data are used to calculate a loss function value by using a preset binary cross-entropy loss function. The loss function value can be used to measure whether the HDR switch control model is successfully trained.
[0074] Further, before the step of training the first HDR switch control model by using the image feature sample data to obtain the second HDR switch control model, the method further includes:
[0075] Step A10: Based on the preset model framework, build a first HDR switch control model, wherein the first HDR switch control model includes at least one densely connected channel rearrangement module, the channel rearrangement module includes a channel rearrangement layer and multiple interconnected convolutional pooling layers, the channel rearrangement layer is located between each of the convolutional pooling layers;
[0076] Step A20: Initialize the model parameters of the first HDR switch control model.
[0077] In this embodiment, before training the first HDR switch control model, it is necessary to first build the first HDR switch control model. The model framework can be a commonly used framework such as Tensorflow (symbolic mathematics system) or PyTorch (open-source machine learning library). The first HDR switch control model is a deep learning network model, including multiple network layers. It should be noted that the first HDR switch control model includes at least one densely connected channel shuffle module. Its core idea is to combine dense connections and channel shuffle. Each convolutional layer in this module is connected to all previous layers. This dense connection approach allows for more complete information flow, thereby improving the performance of the trained model. The convolutional layers are used to extract features, and cross-layer connections are used to concatenate the outputs of all previous layers as the input to the current convolutional layer. In this way, each convolutional layer can utilize the information from all previous layers, thereby improving the model's expressiveness.
[0078] In one feasible embodiment, the channel rearrangement module includes two convolutional layers, one channel rearrangement layer, and two other convolutional layers arranged sequentially, as shown below. Figure 3 This demonstrates the data flow of the densely connected channel rearrangement module and the connection methods between different convolutional layers. Each convolutional layer can utilize the feature information extracted by all preceding convolutional layers, effectively improving the performance and expressiveness of the trained HDR switch control model. It should be noted that, since convolutional layers are typically used in conjunction with pooling layers in deep learning network model construction, therefore... Figure 3 In this model, convolutional layers and pooling layers are combined into a single convolutional-pooling layer. Furthermore, during model training, the number of convolutional layers in the channel rearrangement module can be adjusted based on the training situation; the total number of convolutional and pooling layers is not limited.
[0079] It should also be noted that, in addition to building the aforementioned densely connected channel rearrangement module, the first HDR switch control model can also add other networks as needed, such as convolutional layers, pooling layers, global pooling layers, and fully connected layers, without any restrictions.
[0080] After the first HDR switch control model is built, the model parameters in the first HDR switch control model can be initialized. The model parameters can be hyperparameters, such as learning rate, number of iterations, number of network layers, number of neurons per layer, etc. The initialization settings of the model parameters can be set by the staff based on experience.
[0081] In addition, the image feature sample data includes multiple feature samples. Before the step of inputting the image feature sample data into the first HDR switch control model to generate the prediction result corresponding to the image feature sample data, the method further includes:
[0082] Step B10: Acquire images from multiple scenes, wherein each scene image includes at least a first light image and a second light image, wherein the brightness of the second light image is higher than the brightness of the first light image;
[0083] Step B20: Extract the brightness features of each image to obtain feature samples corresponding to each image;
[0084] Step B30: Divide each of the feature samples into training set data and test set data;
[0085] Step B40: Obtain the real labels corresponding to each of the aforementioned feature samples.
[0086] In this embodiment, images can be captured by a camera in various scenes to facilitate feature sample extraction. It should be noted that the captured image set needs to be pre-screened and named according to rules to ensure a one-to-one correspondence between the first lighting image (dark lighting image) and the second lighting image (normal lighting image). That is, each scene has two images under different lighting conditions. Specifically, in a certain scene, the true label for the dark lighting image can be "on," while the true label for the normal lighting image can be "off." This ensures that the proportion of true label types in the captured images is similar and not too disparate. After the feature samples are extracted, they need to be divided for model training. In this embodiment, the feature samples are divided into training set data and test set data, used for training and testing the model, respectively.
[0087] In another feasible embodiment, the feature samples can be divided into training set data, test set data, and validation set data in a ratio of 6:3:1. The validation set data can be used to validate the model after successful model training.
[0088] In this embodiment, the statistical value of the Y channel in the YUV domain of the camera is used to characterize brightness. This statistical value can be used as the input value of the HDR switch control model, i.e., image feature sample data. After obtaining a preset number of images and corresponding feature samples, each feature sample needs to be manually labeled. That is, based on the current scene of each image, it is manually determined whether the HDR function needs to be turned on. This allows the trained HDR switch control model to select the appropriate HDR on-time according to the current scene, thereby obtaining images with higher expressiveness and higher quality. The captured images exhibit richer colors and more detailed texture features. There is no need for manual operation of the HDR switch, and the user will not keep the HDR function on, wasting the camera's memory resources and energy consumption.
[0089] In addition, the step of training the first HDR switch control model using image feature sample data may also include:
[0090] Step S11: Input the first feature sample from the training set data into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample;
[0091] Step S12: Input the first prediction result and the real label corresponding to the first feature sample into a preset loss function to obtain the first loss function value;
[0092] Step S13: Based on the change in the value of the first loss function, optimize the model parameters of the first HDR switch control model to obtain the second HDR switch control model.
[0093] In this embodiment, the established first HDR switch control model is trained using first feature samples from the training set data. A first loss function is calculated based on the prediction results and corresponding ground truth labels. Finally, the model parameters of the first HDR switch control model are optimized based on the changes in the first loss function to obtain a second HDR switch control model with better performance and a better fit to the image feature sample data. It should be noted that the number of times the first HDR switch control model is trained is determined by a preset number set by the user. After the training count is reached, the obtained second HDR switch control model can be tested to evaluate its performance. Furthermore, it should be noted that during the training of the first HDR switch control model using the training set data, the goal of optimizing the model parameters should be to minimize the value of the first loss function. Specifically, various existing mature model parameter tuning methods, such as traditional manual parameter tuning, grid search, random search, and Bayesian search, can be used to obtain a second HDR switch control model with a relatively smaller first loss function value.
[0094] As an example, steps S11 to S13 include: inputting the first feature sample from the training set data into the first HDR switch control model, predicting the HDR switch state corresponding to the first feature sample through the first HDR switch control model, and obtaining a first prediction result corresponding to the first feature sample; inputting the first prediction result and the real label corresponding to the first feature sample into a preset loss function to obtain a first loss function value; adjusting and optimizing the model parameters of the first HDR switch control model using parameter tuning methods such as grid search, random search, or Bayesian search based on the historical first loss function value, and obtaining a second HDR switch control model; and repeatedly executing steps S11 to S13 until the number of training iterations reaches the number of prediction iterations.
[0095] In one feasible embodiment, the loss function is calculated using the cross-entropy loss function. For a binary classification problem, assuming the model output is... The real label is The cross-entropy loss function can then be expressed as:
[0096] ;
[0097] in, The value of the loss function. It represents the natural logarithm.
[0098] Furthermore, the first HDR switch control model designed in this embodiment may include convolutional layers, pooling layers, densely connected channel rearrangement modules, global pooling layers, and fully connected layers. Based on the established structure of the first HDR switch control model, the step of inputting the first feature sample from the training set data into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample includes:
[0099] Step S111: Input the first feature sample into the convolutional layer, and extract the features of the first feature sample through the convolutional layer to obtain the first feature data;
[0100] Step S112: Input the first feature data into the pooling layer to generate the second feature data;
[0101] Step S113: Input the second feature data into the densely connected channel rearrangement module, and perform feature extraction and channel rearrangement on the second feature data through the channel rearrangement module to obtain the third feature data;
[0102] Step S114: Input the third feature data into the global pooling layer to generate the fourth feature data;
[0103] Step S115: Input the fourth feature data into the fully connected layer, perform result prediction through the fully connected layer, and output the first prediction result.
[0104] In this application embodiment, a design structure idea for an HDR switch control model is proposed, referring to... Figure 4 First, the feature samples are input into a convolutional pooling layer, and then into a channel rearrangement module. In this embodiment, the number of convolutional pooling layers + channel rearrangement modules can be adjusted according to the training situation. Figure 4 The diagram shows an HDR switch control model structure consisting of four such structures. After the channel rearrangement module of the last group outputs the adjustment data, it is input into the global pooling layer for feature dimensionality reduction. The resulting dimensionality-reduced feature data is input into the fully connected layer (FC). The fully connected layer outputs the corresponding prediction result "0" or "1" based on the input dimensionality-reduced feature data, where "0" represents off and "1" represents on.
[0105] In the first HDR switch control model, convolutional layers and pooling layers are used for feature extraction and feature dimensionality reduction, respectively, to reduce higher-dimensional feature data to lower-dimensional feature data. The dimensions of the first feature data to the fourth feature data decrease sequentially. After the second feature data is input into the channel rearrangement module, feature extraction and dimensionality reduction can be further performed through the convolutional and pooling layers in the channel rearrangement module. The channel rearrangement layer in the channel rearrangement module also performs cross-arrangement of the channel order, thereby outputting new third feature data.
[0106] Channel shuffle is an operation that rearranges the channel order of an input tensor (input feature data) according to certain rules. It is widely used in deep learning models. The implementation of channel shuffle involves the following steps:
[0107] (1) Grouping: The input tensor is divided into several groups according to certain rules. Each group contains a continuous set of channels. Usually, the number of groups is 2 or 4.
[0108] (2) Channel Shuffle: For each group, the channels are rearranged according to certain rules so that the channels between different groups can exchange information. Specifically, assuming that the current group contains c / g channels, where g is the number of groups and c is the total number of channels, the channel shuffle operation within the group can be as shown in (3).
[0109] (3) Reference Figure 5 The channels of the group can be divided into three subsets, A, B, and C, where subsets A, B, and C each contain c / (3g) channels. Figure 5 In the figure, Figure (a) shows the channel sorting of the group, and Figure (b) shows the channels after being divided into 3 subsets;
[0110] A, B, and C are arranged in a cross-arrangement according to certain rules to obtain a new channel sequence. Figure (c) shows the channel after the group is cross-arranged, and Figure (d) shows the new channel sequence.
[0111] Apply the new channel order to all channels of the group to obtain the output with rearranged channels.
[0112] (4) Concatenation: Combine the outputs of all groups together as the third feature data of the current layer output.
[0113] Channel rearrangement can be implemented using convolutional and tensor operations. Specifically, the input tensor can be divided into several groups using a 1x1 convolutional layer, and then tensor operations can be used to perform channel rearrangement and merging operations on each group. In practical applications, channel rearrangement is usually encapsulated into a component called Channel Shuffle (densely connected channel rearrangement), which is convenient for use in the construction and training of deep learning network models.
[0114] As an example, steps S111 to S115 include: inputting the first feature sample into a convolutional layer, extracting features from the first feature sample through the convolutional layer to obtain first feature data; inputting the first feature data into a pooling layer, reducing the dimensionality of the first feature data through the pooling layer to obtain second feature data; inputting the second feature data into a densely connected channel rearrangement module; performing feature extraction and dimensionality reduction on the second feature data through the convolutional pooling layer in the channel rearrangement module, and inputting the processed feature data into the channel rearrangement layer in the channel rearrangement module, sorting the processed feature data by channel through the channel rearrangement layer, and outputting feature data with a new channel order. The feature data of the new channel order is extracted and dimensionality reduced again through the convolutional pooling layer in the channel rearrangement module to output the third feature data. Steps S111 to S113 are executed a certain number of times, where the number of times is the number of the "convolutional layer + pooling layer + channel rearrangement module" structure in the first HDR switch control model, which is also one of the model's hyperparameters. After the loop ends, the obtained third feature data is input into the global pooling layer, and the third feature data is subjected to feature dimensionality reduction through the global pooling layer to obtain the fourth feature data. The fourth feature data is input into the fully connected layer, and the result is predicted through the fully connected layer to output the first prediction result corresponding to the first feature sample.
[0115] Further, in step S30, the preset conditions include at least convergence and prediction accuracy thresholds, and the step of determining whether the second HDR switch control model meets the preset conditions based on the prediction results output by the second HDR switch control model and the corresponding real labels includes:
[0116] Step S31: Input the second feature sample from the test set data into the second HDR switch control model to obtain the second prediction result corresponding to the second feature sample;
[0117] Step S32: Input the second prediction result and the real label corresponding to the second feature sample into a preset loss function to obtain the second loss function value;
[0118] Step S33: Based on the second loss function value and the previous loss function value, determine whether the second HDR switch control model has converged;
[0119] Step S34: If the second HDR switch control model has converged, calculate the prediction accuracy of the second HDR switch control model based on the second prediction result and the real label corresponding to the second feature sample.
[0120] Step S35: When the prediction accuracy is not less than the prediction accuracy threshold, it is determined that the second HDR switch control model meets the preset conditions.
[0121] Step S36: If the second HDR switch control model fails to converge or the prediction accuracy is less than the prediction accuracy threshold, it is determined that the second HDR switch control model does not meet the preset conditions.
[0122] This application proposes a method to determine whether a second HDR switch control model has converged based on its loss function value, and to determine whether the second HDR switch control model meets preset conditions by combining the model's prediction accuracy. The previous loss function value refers to the second loss function value obtained during the model training process when the second HDR switch control model was last tested using test set data. Whether the second HDR switch control model has converged is determined by whether its loss function value decreases to a certain level and then stops decreasing. For example, if the previous loss function value was 0.2 and the current loss function value is 0.15, then it has not converged; if the previous loss function value was 0.08 and the current loss function value is also 0.08, then the second HDR switch control model can be considered converged. In another feasible embodiment, convergence can be determined by combining the loss function values obtained from multiple historical tests of the second HDR switch control model with the current loss function value, resulting in higher accuracy.
[0123] As an example, steps S31 to S36 include: inputting a second feature sample from the test set data into the second HDR switch control model, predicting the switch state of the second feature sample using the second HDR switch control model, and obtaining a second prediction result corresponding to the second feature sample; inputting the second prediction result and the real label corresponding to the second feature sample into a preset loss function to obtain a second loss function value; determining whether the second loss function value is equal to the previously obtained loss function value; if they are not equal, determining that the second HDR switch control model has not converged and that the second HDR switch control model does not meet the preset condition; if they are equal, determining that the second HDR switch control model has converged; when the second HDR switch control model converges, selecting accurately predicted results from the second prediction results based on the real label; calculating the quotient between the number of accurately predicted results and the total number of predicted results in the second prediction results to obtain the prediction accuracy of the second HDR switch control model; determining whether the prediction accuracy is not less than a prediction accuracy threshold; if the prediction accuracy is not less than the prediction accuracy threshold, determining that the second HDR switch control model meets the preset condition; if the prediction accuracy is less than the prediction accuracy threshold, determining that the second HDR switch control model does not meet the preset condition. It should be noted that if the prediction accuracy is significantly lower than the prediction accuracy threshold when the second HDR switch control model has converged, it can be considered that there is a problem with the overall architecture design of the model or the image feature sample data used for model training is not suitable. In this case, it is necessary to redesign the model architecture and collect new image feature sample data.
[0124] In this embodiment, an HDR switch control model training method is provided. First, a first HDR switch control model is trained using image feature sample data to obtain a second HDR switch control model. When the training iterations reach a preset number, the second HDR switch control model is judged to meet preset conditions based on the prediction results and corresponding ground truth labels output by the second HDR switch control model. Both the prediction results and the ground truth labels include the HDR function switch state. If yes, the second HDR switch control model is set to a third HDR switch control model, whereby the third HDR switch control model is used to control the HDR function switch based on the captured image. If no, the model parameters of the second HDR switch control model are updated and set to the first HDR switch control model, returning to the execution step: training the second HDR switch control model using image feature sample data. The first HDR switch control model is trained using image feature sample data. When the training iterations reach a preset number, the resulting second HDR switch control model is evaluated to obtain a third HDR switch control model that meets preset conditions. This third HDR switch control model can control the HDR function switch state based on the currently captured image when the user is using the camera device to take pictures. It can automatically turn on the camera's HDR function at appropriate times without requiring manual operation, thus lowering the user's operating threshold. Furthermore, turning on the camera's HDR function at the right time results in higher quality and more expressive images. Automatic adjustment of the HDR switch according to changes in ambient light avoids unnecessary energy waste caused by prolonged HDR operation, thereby achieving energy conservation and emission reduction.
[0125] Example 2
[0126] Furthermore, based on the first embodiment of this application, in another embodiment of this application, the same or similar content as in Embodiment 1 can be referred to the above description, and will not be repeated hereafter. Based on this, after obtaining the third HDR switch control model that meets the preset conditions, refer to... Figure 6 It may also include:
[0127] Step C10: Cross-compile the third HDR switch control model to obtain the executable file corresponding to the third HDR switch control model;
[0128] Step C20: Deploy the executable file offline on the camera device.
[0129] This application provides a method for compiling and deploying a trained third HDR switch control model on a mobile device with camera functionality (such as a mobile phone or camera). Specifically, a cross-compilation method is used to obtain an executable file that can be executed by the camera device. This executable file is then deployed offline on the camera device, enabling the camera device to automatically predict based on the currently acquired scene image when capturing images, thereby automatically enabling and disabling the HDR function.
[0130] Furthermore, after deploying the executable file offline on the camera device, refer to Figure 6 The method further includes:
[0131] Step C30: When the camera device is turned on, the brightness features corresponding to the currently acquired scene image are input into the third HDR switch control model corresponding to the executable file;
[0132] Step C40: Predict the HDR function switch state corresponding to the scene image using the third HDR switch control model, and output the current prediction result;
[0133] Step C50: If the current prediction result is off, then turn off the HDR function of the camera device;
[0134] Step C60: If the current prediction result is enabled, then enable the HDR function of the camera device.
[0135] In the embodiments of this application, it should be noted that the execution time of step C30 is not consecutive with that of step C20. Steps C10 to C20 only need to be executed one at a time, while steps C30 to C60 can be executed multiple times.
[0136] In one feasible embodiment, step C30 can be in response to a user's automatic HDR command, meaning the user can choose whether to enable the automatic HDR function, which refers to automatically turning the camera device's HDR function on and off based on the current scene image. It should be noted that steps C20 to C60 apply to the camera device.
[0137] As an example, steps C30 to C60 include: in response to an automatic HDR command input by a user, extracting corresponding brightness features from the currently acquired scene image, wherein the HDR command is a virtual button switch on the camera device; inputting the brightness features into a third HDR switch control model corresponding to an executable file deployed on the camera device; predicting the HDR function switch state corresponding to the scene image through the third HDR switch control model, and outputting the current prediction result; if the current prediction result is off, then turning off the HDR function of the camera device, wherein if the HDR function of the camera device is currently off, then keeping it off; if the current prediction result is on, then turning on the HDR function of the camera device, wherein if the HDR function of the camera device is currently on, then keeping it on.
[0138] This application embodiment also effectively reduces flickering when the HDR function is turned on. The flickering occurs because the human eye is less sensitive as optical conditions gradually darken. People only remember to turn on HDR to improve image quality when the light becomes too dim to be observable. However, by then the light is already too low, so the HDR function compensates for this with excessive lighting, resulting in a flickering state that negatively impacts the user experience. The third HDR switch control model in this application embodiment can perform real-time feature acquisition and prediction of the currently captured scene image. When the lighting conditions reach the threshold requiring HDR to be turned on, it activates the HDR function in advance, avoiding flickering and inconsistent image quality caused by turning on HDR too late.
[0139] In this application embodiment, a method is provided to compile and deploy a trained HDR switch control model on a camera device, enabling users to use the automatic HDR function even when the camera device is offline. Furthermore, when the camera device captures an image, it can predict the HDR function switch based on the brightness characteristics in the current scene image and the HDR switch control model corresponding to the deployed executable file, thereby achieving automatic control of the HDR function switch without requiring manual control by the user. This lowers the operational threshold and avoids problems such as image flickering, distortion, or unnatural transitions caused by incorrect timing of HDR function activation, ensuring the continuity and stability of the image.
[0140] Example 3
[0141] This application also provides an HDR switch control model training device, which is applied to an HDR switch control model training equipment, as described above. Figure 7 The HDR switch control model training device includes:
[0142] The model training module 101 is used to train the first HDR switch control model using image feature sample data to obtain the second HDR switch control model.
[0143] The model evaluation module 102 is used to determine whether the second HDR switch control model meets the preset conditions based on the prediction results and corresponding real labels output by the second HDR switch control model when the number of training times reaches a preset number. The prediction results and the real labels both include the HDR function switch status.
[0144] The model determination module 103 is used to set the second HDR switch control model to the third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to the captured image;
[0145] The iterative optimization module 104 is used to update the model parameters of the second HDR switch control model and set them to the first HDR switch control model if no, and then return to the execution step: train the first HDR switch control model using image feature sample data.
[0146] Optionally, the model training module 101 is further configured to:
[0147] Based on a preset model framework, a first HDR switch control model is built. The first HDR switch control model includes at least one densely connected channel rearrangement module. The channel rearrangement module includes a channel rearrangement layer and multiple interconnected convolutional pooling layers. The channel rearrangement layer is located between each of the convolutional pooling layers.
[0148] Initialize the model parameters of the first HDR switch control model.
[0149] Optionally, the HDR switch control model training device further includes a feature acquisition module, wherein the image feature sample data includes multiple feature samples, and the feature acquisition module is used for:
[0150] Images are acquired from multiple scenes, wherein each scene image includes at least a first light image and a second light image, and the brightness of the second light image is higher than that of the first light image;
[0151] Extract the brightness features of each image to obtain the feature samples corresponding to each image;
[0152] Each of the aforementioned feature samples is divided into training set data and test set data;
[0153] Obtain the true label corresponding to each of the aforementioned feature samples.
[0154] Optionally, the model training module 101 is further configured to:
[0155] The first feature sample in the training set data is input into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample;
[0156] The first prediction result and the true label corresponding to the first feature sample are input into a preset loss function to obtain the first loss function value;
[0157] Based on the changes in the value of the first loss function, the model parameters of the first HDR switch control model are optimized to obtain the second HDR switch control model.
[0158] Optionally, the first HDR switch control model includes convolutional layers, pooling layers, a densely connected channel rearrangement module, a global pooling layer, and a fully connected layer. The model training module 101 is further used for:
[0159] The first feature sample is input into the convolutional layer, and the features of the first feature sample are extracted by the convolutional layer to obtain the first feature data;
[0160] The first feature data is input into the pooling layer to generate the second feature data;
[0161] The second feature data is input into the densely connected channel rearrangement module, and the channel rearrangement module performs feature extraction and channel rearrangement on the second feature data to obtain the third feature data;
[0162] The third feature data is input into the global pooling layer to generate the fourth feature data;
[0163] The fourth feature data is input into the fully connected layer, and the result is predicted through the fully connected layer to output the first prediction result.
[0164] Optionally, the preset conditions include at least convergence and prediction accuracy thresholds, and the model evaluation module 102 is further used for:
[0165] The second feature sample in the test set data is input into the second HDR switch control model to obtain the second prediction result corresponding to the second feature sample;
[0166] The second prediction result and the real label corresponding to the second feature sample are input into a preset loss function to obtain the second loss function value;
[0167] Based on the second loss function value and the previous loss function value, determine whether the second HDR switch control model has converged;
[0168] If the second HDR switch control model has converged, then the prediction accuracy of the second HDR switch control model is calculated based on the second prediction result and the true label corresponding to the second feature sample.
[0169] When the prediction accuracy is not less than the prediction accuracy threshold, it is determined that the second HDR switch control model meets the preset conditions;
[0170] If the second HDR switch control model fails to converge or the prediction accuracy is less than the prediction accuracy threshold, the second HDR switch control model is determined to not meet the preset conditions.
[0171] Optionally, the HDR switch control model training device further includes a model deployment module, which is used for:
[0172] The third HDR switch control model is cross-compiled to obtain the executable file corresponding to the third HDR switch control model;
[0173] The executable file is deployed offline on the camera device.
[0174] Optionally, the HDR switch control model training device further includes a model application module, which is used for:
[0175] When the camera device is turned on, the brightness features corresponding to the currently acquired scene image are input into the third HDR switch control model corresponding to the executable file;
[0176] The third HDR switch control model is used to predict the HDR function switch state corresponding to the scene image and output the current prediction result.
[0177] If the current prediction result is off, then the HDR function of the camera device is turned off;
[0178] If the current prediction result indicates that the HDR function of the camera device is enabled, then the HDR function of the camera device is enabled.
[0179] The HDR switch control model training device provided in this application adopts the HDR switch control model training method in the above embodiments, solving the technical problem that the manual switching of the camera's HDR function has too high an operational threshold for users. Compared with the prior art, the beneficial effects of the HDR switch control model training device provided in this application are the same as those of the HDR switch control model training method provided in the above embodiments, and other technical features in this HDR switch control model training device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0180] Example 4
[0181] This application provides an electronic device, which includes: at least one processor; and a memory communicatively linked to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the HDR switch control model training method in the first embodiment described above.
[0182] The following is for reference. Figure 8 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable media players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0183] like Figure 8 As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 (ROM) or a program loaded from a storage device 1003 into a random access memory 1004 (RAM). The RAM 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1004, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also linked to the bus 1005.
[0184] Typically, the following systems can be linked to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although electronic devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems may be implemented alternatively.
[0185] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined above in the methods of embodiments of this disclosure.
[0186] The electronic device provided in this application employs the HDR switch control model training method in the above embodiments, solving the technical problem that manually switching the camera's HDR function is too difficult for users. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the HDR switch control model training method provided in Embodiment 1 above, and other technical features of this electronic device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0187] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.
[0188] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0189] Example 5
[0190] This embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon, which are used to execute the HDR switch control model training method in the first embodiment described above.
[0191] The computer-readable storage medium provided in this application embodiment may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical links having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM, or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0192] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.
[0193] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by an electronic device, the electronic device causes the following: it trains a first HDR switch control model using image feature sample data to obtain a second HDR switch control model; when the training count reaches a preset number, it determines whether the second HDR switch control model meets preset conditions based on the prediction result output by the second HDR switch control model and the corresponding real label, wherein both the prediction result and the real label include the HDR function switch state; if yes, it sets the second HDR switch control model to a third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to the captured image; if no, it updates the model parameters of the second HDR switch control model and sets it to the first HDR switch control model, then returns to the execution step: training the first HDR switch control model using image feature sample data.
[0194] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be linked to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be linked to an external computer (e.g., via the Internet using an Internet service provider).
[0195] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0196] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0197] The computer-readable storage medium provided in this application stores computer-readable program instructions for executing the above-described HDR switch control model training method, thus solving the technical problem that manually switching the camera's HDR function on and off is too difficult for users to operate. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the HDR switch control model training method provided in the above-described embodiments, and will not be repeated here.
[0198] Example 6
[0199] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the HDR switch control model training method described above.
[0200] The computer program product provided in this application solves the technical problem that manually switching the camera's HDR function on and off is too difficult for users to operate. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the HDR switch control model training method provided in the above embodiments, and will not be repeated here.
[0201] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A training method for an HDR switch control model, characterized in that, The training method for the HDR switch control model includes: Based on a preset model framework, a first HDR switch control model is constructed, wherein the first HDR switch control model includes at least one densely connected channel rearrangement module, the channel rearrangement module includes a channel rearrangement layer and multiple interconnected convolutional pooling layers, the channel rearrangement layer is located between each of the convolutional pooling layers; the model parameters of the first HDR switch control model are initialized. Images from multiple scenes are acquired, wherein each scene image includes at least a first light image and a second light image, the second light image having a higher brightness than the first light image; brightness features of each image are extracted to obtain feature samples corresponding to each image, the brightness features being statistical values of the Y channel in the YUV domain of the camera; each feature sample is divided into training set data and test set data; based on the current scene conditions of each image, it is manually determined whether the HDR function needs to be enabled; and the real labels corresponding to each feature sample are obtained. The first feature sample in the training set data is input into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample; the first prediction result and the real label corresponding to the first feature sample are input into a preset cross-entropy loss function to obtain the first loss function value; based on the change of the first loss function value, the model parameters of the first HDR switch control model are optimized by grid search, random search or Bayesian search method to obtain the second HDR switch control model. When the number of training iterations reaches a preset number, the prediction results and corresponding real labels output by the second HDR switch control model are used to determine whether the second HDR switch control model meets the preset conditions. The prediction results and the real labels both include the HDR function switch status. If so, the second HDR switch control model is set to the third HDR switch control model, wherein the third HDR switch control model is used to control the HDR function switch according to the captured image; If not, update the model parameters of the second HDR switch control model and set it to the first HDR switch control model, then return to the execution step: train the first HDR switch control model using image feature sample data, wherein the image feature sample data includes multiple feature samples; The first HDR switch control model includes convolutional layers, pooling layers, a densely connected channel rearrangement module, a global pooling layer, and a fully connected layer. The step of inputting the first feature sample from the training set data into the first HDR switch control model to obtain the first prediction result corresponding to the first feature sample includes: The first feature sample is input into the convolutional layer, and the features of the first feature sample are extracted by the convolutional layer to obtain the first feature data; The first feature data is input into the pooling layer to generate the second feature data; The second feature data is input into the densely connected channel rearrangement module. The channel rearrangement module performs feature extraction and channel rearrangement on the second feature data to obtain the third feature data. The feature samples are input into the convolutional pooling layer and then into the channel rearrangement module. The number of the convolutional pooling layer + channel rearrangement module structure is adjusted according to the training situation. The third feature data is input into the global pooling layer to generate the fourth feature data; The fourth feature data is input into the fully connected layer, and the result is predicted through the fully connected layer to output the first prediction result.
2. The HDR switch control model training method as described in claim 1, characterized in that, The preset conditions include at least convergence and prediction accuracy thresholds. The step of determining whether the second HDR switch control model meets the preset conditions based on the prediction results output by the second HDR switch control model and the corresponding real labels includes: The second feature sample in the test set data is input into the second HDR switch control model to obtain the second prediction result corresponding to the second feature sample; The second prediction result and the real label corresponding to the second feature sample are input into a preset loss function to obtain the second loss function value; Based on the second loss function value and the previous loss function value, determine whether the second HDR switch control model has converged; If the second HDR switch control model has converged, then the prediction accuracy of the second HDR switch control model is calculated based on the second prediction result and the true label corresponding to the second feature sample. When the prediction accuracy is not less than the prediction accuracy threshold, it is determined that the second HDR switch control model meets the preset conditions; If the second HDR switch control model fails to converge or the prediction accuracy is less than the prediction accuracy threshold, the second HDR switch control model is determined to not meet the preset conditions.
3. The HDR switch control model training method as described in claim 1 or 2, characterized in that, After the step of setting the second HDR switch control model to the third HDR switch control model, the method further includes: The third HDR switch control model is cross-compiled to obtain the executable file corresponding to the third HDR switch control model; The executable file is deployed offline on the camera device.
4. The HDR switch control model training method as described in claim 3, characterized in that, After the step of deploying the executable file offline on the camera device, the method further includes: When the camera device is turned on, the brightness features corresponding to the currently acquired scene image are input into the third HDR switch control model corresponding to the executable file; The third HDR switch control model is used to predict the HDR function switch state corresponding to the scene image and output the current prediction result. If the current prediction result is off, then the HDR function of the camera device is turned off; If the current prediction result indicates that the HDR function of the camera device is enabled, then the HDR function of the camera device is enabled.
5. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively linked to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the steps of the HDR switch control model training method according to any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program for implementing an HDR switch control model training method, which is executed by a processor to implement the steps of the HDR switch control model training method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Contextual HDR determination
US9607366B1