Camera exposure control method based on online self-learning

Through the online self-learning method combining deep learning and reinforcement learning, the problem of camera exposure control adaptability and real-time application in new scenes is solved, and personalized and efficient exposure control is achieved, which is suitable for a wide range of camera application scenarios.

CN119012017APending Publication Date: 2024-11-22SHENYANG INST OF AUTOMATION - CHINESE ACAD OF SCI
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310575705.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-22
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The existing camera exposure control methods have shortcomings in the adaptability and real-time applications of new scenes, especially the deep learning algorithms have weak adaptability to new scenes and are difficult to apply in real-time.

Method used

Using a deep learning-based online self-learning method, by building a deep neural network and deep reinforcement learning iterative model, using public data sets and real-time video streams for training, personalized control of camera exposure is achieved, combined with feature distillation and accelerated inference deployment, Improve the adaptability and real-timeness of the algorithm.

Benefits of technology

It realizes efficient adaptation to new scenes and personalized exposure control, improves the adaptability and real-timeness of the camera exposure algorithm, reduces the demand for computing power, and ensures high-performance exposure adjustment in different user scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119012017A_ABST
    Figure CN119012017A_ABST
Patent Text Reader

Abstract

The invention provides a camera automatic exposure control method based on online self-learning. A module comprises a public data set, a deep learning pre-training model, a deep reinforcement learning iteration model, a deep reinforcement learning deployment model and a real-time video stream. The method specifically comprises the steps of pre-training, reward modeling, online self-learning, experience returning, strategy deployment, collection and exposure compensation. According to the method, the problems of low adaptability to wide application scenes, lack of personalized exposure capability for different users and the like in the processing of a traditional camera exposure method are solved to a great extent; the method can provide optimal exposure compensation for a specific use scene for a user in the fields of mobile phones, personal computers, industrial cameras and the like, and plays an important role in improving the use experience of the user, meeting rich exposure requirements of the user and improving the quality of shot images in the industrial scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of camera automatic exposure, and in particular is a camera exposure control method based on online self-learning. Background Art

[0002] Camera automatic exposure technology is a technology that automatically adjusts the camera's exposure time, aperture size, sensitivity and other parameters by real-time monitoring and analysis of the captured pictures to ensure the best exposure image. This technology can handle various complex shooting environments and provide optimized images. It is widely used in digital cameras, mobile phone cameras, personal computer cameras, industrial cameras, surveillance cameras and machine vision systems. Excellent camera automatic exposure technology can greatly improve image quality and user experience. By automatically adjusting the exposure parameters, the problem of overexposure or underexposure of the image caused by light changes can be avoided, and the contrast and details of the image can be enhanced. Therefore, camera automatic exposure technology is of great significance to the development of modern photo and video acquisition technology.

[0003] At present, camera exposure control methods are mainly divided into three categories: numerical exposure control methods, such as classic algorithms such as center metering, spot metering, and matrix metering, which are currently widely used in various camera modules; heuristic exposure control methods, in the early 21st century, exposure compensation adjustment algorithms based on optimization ideas and algorithms appeared; exposure compensation adjustment algorithms based on deep learning. In recent years, with the rapid development of deep learning, the idea of ​​using deep learning for camera exposure adjustment has been tried more and more. Although most of these methods can achieve good exposure effects, they also have some problems.

[0004] For exposure algorithms based on numerical values, their advantages are fast and stable execution speed, but their disadvantages are that they still lack strong adaptability to a wide range of scenarios; for exposure algorithms based on heuristics, their advantages are that they can better utilize scene information, but there are very few mature technical routes for optimizing execution speed; for exposure algorithms based on deep learning, their advantages are that they are more adaptable to general scenarios, but they still lack adaptive capabilities for new scenarios and are difficult to adapt to the usage habits of different users. Moreover, deep learning networks are more complex than other algorithms and are difficult to apply in real time. Summary of the invention

[0005] The present invention combines the advantages of deep learning exposure control methods, focuses on solving the new scene adaptation problem and real-time application problem of deep learning algorithms, and provides a high-performance technical route that can be applied in a wide range of usage scenarios (including mobile phone cameras, computer cameras, industrial cameras, etc.).

[0006] The technical solution adopted by the present invention to achieve the above-mentioned purpose is:

[0007] A camera exposure control method based on online self-learning comprises the following steps:

[0008] Obtain image data through public datasets and preprocess them;

[0009] Build a deep learning pre-trained model and train the model using the trained image data;

[0010] Obtain real-time video stream, use the trained deep learning pre-training model to calculate the exposure prediction value of the state image of two adjacent frames in the video stream, process it, and store the processing results in the experience pool;

[0011] Construct a deep reinforcement learning iterative model, and use the processed exposure prediction value as the reward of the model to train the deep reinforcement learning iterative model;

[0012] According to the deployment conditions, the trained deep reinforcement learning iterative model is deployed to the camera to achieve exposure control of the camera.

[0013] The deep learning pre-training model adopts a deep neural network structure, the input is image data, the output is the exposure prediction value of the image, and the loss function L of the deep learning pre-training model is trained. pretrain for:

[0014]

[0015] Where D is the deviation image, T is the wrong exposure image, w is the image width, h is the image height, y is the network output, t is the optimal exposure compensation value, and L discrepancy is the deviation loss part, L regression is the regression loss part.

[0016] The reward of the deep reinforcement learning iterative model is:

[0017]

[0018]

[0019] Among them, r t is the reward at time t, score t 、score t-1 are the scores at time t and time t-1 respectively, Neural network mapping for deep learning pre-trained models, s t 、s t-1 are the states at time t and time t-1 respectively.

[0020] The deep reinforcement learning iterative model adopts a competitive deep Q-value network structure, the input is a frame of image collected by the video stream, and the output is the Q-value vector of the current state. The training process of the deep reinforcement learning iterative model is specifically as follows:

[0021] The estimated Q network asynchronously obtains a set of s from the experience pool k and k+1 , the output of the Q network is estimated by forward propagation calculation At the same time, estimate the last layer output feature map of the Q network backbone network

[0022] Calculate action a p :

[0023]

[0024] Where a is the action to estimate the output of the Q network, To estimate the Q network parameter vector;

[0025] Target Q network acquisitions k+1 , and calculate Q(s) by forward propagation k+1 ,a p ; ω), ω is the target Q network parameter vector;

[0026] Q(s k+1 ,a p ;ω) and These calculation results are substituted into the loss function for gradient descent to update the parameters of the estimated Q network;

[0027] When the number of iterations or the average reward value of each generation in the iteration process or the user's action reaches the deployment condition, all parameters of the estimated Q network are applied to the target Q network to complete the update of the target Q network.

[0028] The loss function L online for:

[0029]

[0030] Among them, L DQN is the DQN loss, L KD is the distillation loss, r k is the k-time reward, γ is the reinforcement learning parameter, To estimate the network feature map output, E f (s k ;ω e ) is the network feature map output of the deep learning pre-training model, is the estimated Q network parameter vector, ω is the target Q network parameter vector, ω eParameter vector of a pre-trained model for deep learning.

[0031] The deployment conditions are:

[0032] Deployment condition 1: Record the maximum reward value generated after each iteration, and calculate its average value every 10 iterations. If the ratio of the average value calculated this time to the average value calculated last time exceeds the set threshold, this condition is met;

[0033] Deployment condition 2: This condition is met when the set number of iterations have been completed since the last deployment action;

[0034] Deployment condition 3: If the user stops collecting video streams at a certain moment, this condition is met;

[0035] When any one of deployment conditions 1 and 2 is met, and deployment condition 3 is met, the deployment action is performed.

[0036] The deployment is specifically as follows:

[0037] 1) Export the target Q network to ONNX format;

[0038] 2) Convert the model file in ONNX format to the inference backend model file used;

[0039] 3) Transfer the backend model file to a remote machine via HTTP or store it on the local disk.

[0040] The present invention has the following beneficial effects and advantages:

[0041] 1. In order to adapt to new scenes, the present invention uses the modeling ability of deep reinforcement learning on the Markov decision process to learn the intrinsic connection between video stream frames. At the same time, in conjunction with the online reinforcement learning algorithm of the present invention, the algorithm can effectively enhance the perception and learning of the intrinsic connection between frames during the use of each user. The algorithm can continuously learn the user's scenes and usage habits during the actual use of the user, and ultimately provide a personalized exposure effect for each user.

[0042] 2. In order to solve the problem of real-time application of deep learning algorithms, the present invention uses a lighter deep reinforcement learning model to compress complex deep learning models, and ensures the performance of the former through feature distillation between the two models.

[0043] 3. The present invention proposes a specific application method for deploying deep learning accelerated reasoning on actual devices. By using mature accelerated reasoning deployment components to accelerate the real-time application process of deep learning, high real-time performance can be achieved without relying on a large amount of computing power. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1Schematic diagram of the relationship between modules and steps of the camera exposure control method based on online self-learning;

[0045] Figure 2 Deep learning pre-training model network structure diagram;

[0046] Figure 3 Network structure diagram of deep reinforcement learning iterative model;

[0047] Figure 4 Diagram of the steps of the camera module processing the video stream after applying this algorithm;

[0048] Figure 5 Double-DQN online reinforcement learning architecture diagram. DETAILED DESCRIPTION

[0049] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0050] The present invention provides a complete online self-learning camera exposure control method. The method includes: Figure 1 Modules and steps shown.

[0051] like Figure 1 The method is divided into five modules: [Public Dataset], [Deep Learning Pre-training Model], [Deep Reinforcement Learning Iterative Model], [Deep Reinforcement Learning Deployment Model], [Real-time Video Stream], and seven steps: pre-training, reward modeling, online self-learning, feedback experience, deployment strategy, acquisition, and exposure compensation. The following will explain the technical details of these five modules and seven steps.

[0052] 1.1 Module Introduction

[0053] 1.1.1 Public Datasets

[0054] Part of the data from Flickr30k, a public dataset in the field of professional photography, is processed and used as training data for [pre-training deep learning]. The processing method is as follows:

[0055] ① We randomly crawled 5,000 images with optimal exposure compensation adjusted by professional photographers from the open source dataset Flickr30k.

[0056] ② Use image processing software to adjust the exposure value of each image 20 times (-2.0EV to 2.0EV) with a step size of 0.2. A total of 105,000 images were generated.

[0057] ③ Randomly select 100,000 images as training sets, 1,000 images as validation sets, and 4,000 images as test sets, none of which share any common scenes.

[0058] ④Record the corresponding exposure adjustment value of each picture in step ③ as the optimal exposure compensation value, i.e., the label.

[0059] After being processed as above, the [public dataset] is directly used in the present invention.

[0060] 1.1.2 Deep Learning Pre-training Model

[0061] The deep learning pre-training model uses Figure 2 The deep neural network structure shown.

[0062] Figure 2 In the dataset, the error exposure map is the images in the public dataset; the deviation map is the absolute value of the difference between the image after each exposure adjustment and the original optimal exposure image; the network output is the exposure prediction value, which is the difference between the input image and the optimal exposure image. For example, if an image is obtained by adjusting the exposure of the optimal exposure image by +0.2EV, its exposure prediction value is +0.2. The exposure prediction value range is [-2, +2].

[0063] Among them, the loss function expression used to train the network is as follows:

[0064]

[0065] Where D is the deviation image, T is the wrong exposure image, w is the image width, h is the image height, y is the network output, and t is the optimal exposure compensation value (label). discrepancy is the deviation loss part, L regression is the regression loss part. The sum of the two constitutes the loss function L of the pre-training model pretrain .

[0066] 1.1.3 Deep reinforcement learning iterative model

[0067] The deep reinforcement learning iterative model adopts the DuelingDQN (competitive deep Q value network) structure, such as Figure 3 ,For the pre-trained model, the learning iterative model is more lightweight and can ,achieve the task of adjusting the camera exposure online in real time.

[0068] The input is a frame of image captured by the video stream, and the output is the Q value vector of the current state, specifically a vector of size 1*7. The action space in this example is the exposure value that should be adjusted in this state calculated by the algorithm, that is, action a, and the specific value set is: {a|-0.6,-0.4,-0.2,0,+0.2,+0.4,+0.6}.

[0069] 1.1.4 Deep reinforcement learning deployment model

[0070] The deep reinforcement learning deployment model can be deployed with different inference backends according to different platforms. For example, TensorRT should be used for Nvidia graphics card deployment platform, ONNXRuntime should be used for PC deployment without graphics card, and NCNN should be used for mobile chip deployment.

[0071] The deployment model is essentially a network structure storage file that has been optimized by the inference backend. Applying the corresponding deployment model on the inference backend can greatly improve the inference speed and ensure the real-time performance of the exposure adjustment algorithm applied to the camera video stream.

[0072] 1.1.5 Live Video Streaming

[0073] The real-time video stream is the scene in which the user is actually located. After being collected and processed by the camera sensor module, the video stream is formed. The exposure compensation value output by this algorithm will directly act on the real-time video stream. It should be noted that after the application of this algorithm, the camera module processes the video stream signal in the following steps: Figure 4 shown.

[0074] Figure 4 In the figure, the green part is the algorithm step. The "read inference model" step should be completed before the camera module is started and the serialized backend inference model is loaded into the memory. This step is only executed once during the entire video stream acquisition process. For computing power considerations, the maximum frame rate of the "exposure compensation calculation" and "exposure compensation application" steps is 25 frames per second. For the frames between two algorithm calculations, the exposure compensation value calculated by the previous algorithm is used to adjust the video.

[0075] 1.2 Steps

[0076] 1.2.1 Pre-training

[0077] Train the network in the deep learning pre-trained model based on the public dataset, and iterate all the data for a sufficient number of rounds.

[0078] 1.2.2 Reward Modeling

[0079] During the training process, the current state image and the previous state image are input into the [deep learning pre-training model] obtained in {1. Pre-training} to obtain two exposure prediction values. In order to ensure the smoothness of the reward function, the two exposure prediction values ​​are processed by formula 2 and used as the reward of the [deep reinforcement learning iterative model].

[0080]

[0081] In formula 2, score t 、score t-1 is the score at time t and time t-1, and the calculation method is shown in formula 3; rt is the reward at time t.

[0082]

[0083] In formula 3, Represents the neural network mapping of the deep learning pre-training model, s t 、s t-1 They are the states (images) at time t and time t-1 respectively. At the same time, in the process of forward propagation of the [deep learning pre-training model], the feature map E output by its backbone network is obtained f (s k ;ω e ).

[0084] 1.2.3 Online Self-Learning

[0085] The experience composed of the real-time images of customers transmitted back in step {4. Transmitting experience} is combined with step {2. Reward modeling} to perform online self-learning on the [deep reinforcement learning iterative model]. Here are the technical details:

[0086] ① Online reinforcement learning algorithm based on Double-DQN:

[0087] Double-DQN uses two homogeneous Q networks for iterative learning. The specific learning process is as follows: Figure 5 As shown;

[0088] Figure 5 In the architecture, the camera module is used to collect images from the real scene, and the required data is transmitted back to the reward modeling through the {4. Feedback experience} step (the frequency of transmission is 5 times per second). After the reward of the transmitted data is calculated through the {2. Reward modeling} step, it is put into the experience pool. At the same time, the estimated Q network asynchronously obtains a batch size s from the experience pool k and k+1 , calculated by forward propagation At the same time, the characteristic map of the estimated Q network backbone network output is obtained Then calculate a as follows p :

[0089]

[0090] The target Q network obtains the corresponding s k+1 Calculate Q(s) by forward propagation k+1 ,a p ; ω); Finally, these calculation results are substituted into the loss function for gradient descent to update the parameters of the estimated Q network. When the deployment conditions are met, all the parameters of the estimated Q network are copied and applied to the target Q network to complete the update of the target Q network.

[0091] In addition, in order to ensure that the estimated Q network can quickly learn the feature map output in the [deep learning pre-training model] in fewer rounds of learning iterations, the estimated Q network uses feature distillation to learn the feature map output by the reward modeling network. k Substitute it into the [Deep Learning Pre-training Model] and substitute the obtained feature map into the loss function calculation. Figure 5 The loss function in is as follows:

[0092]

[0093] In formula 4, L is Figure 5 The loss function, L DQN is the DQN loss, L KD is the distillation loss, and the sum of the two is the loss function L of the online self-learning model online ; r k is the reward at time k; γ is the reinforcement learning parameter, and its value range is generally [0,1]; To estimate the network feature map output, E f (s k ;ω e ) is the network feature map output of the [deep learning pre-training model]; is the estimated Q network parameter vector; ω is the target Q network parameter vector; ω e is the parameter vector of the deep learning pre-training model.

[0094] ②Asynchronous experience playback

[0095] It should be noted that Double-DQN is generally used for offline reinforcement learning. Since the speed of the agent's interaction with the environment can be very fast in offline reinforcement learning, the process of the agent obtaining data from the experience pool and the process of depositing data into the experience pool by reward modeling can be performed in a synchronous manner; then for online reinforcement learning, since it is inevitable to involve some low-speed hardware in the interaction with the real environment, if the agent still obtains data from the experience pool in a synchronous manner, the learning algorithm will not have a high utilization rate of time (less training generations completed in equal time). For example, in the present invention, considering factors such as network bandwidth limitations, real-time operation of the camera module, and optimization of training data, the frequency of the data transmission is set to 200 milliseconds once, and the time for a round of training can reach less than 100 milliseconds. At this time, if the experience pool design for offline learning is followed, the algorithm will wait for a certain period of time after training a generation before obtaining the next batch of data from the experience pool, resulting in low time utilization of training.

[0096] Based on the above observations, the present invention proposes to take data from the experience pool to the agent in an asynchronous manner. Since the agent obtains a batch of data from the experience pool at a time, the probability of completely duplicate data is extremely low ( n is the size of the experience pool, b is the amount of data in a batch), so to a certain extent, it can be guaranteed that the quality of the training data will not be seriously reduced due to the asynchronous experience collection of the agent. In this way, the full computing power of the machine can be used more efficiently and the time utilization of training can be improved.

[0097] 1.2.4 Experience Feedback

[0098] While providing the user with exposure control functions, the [Deep Reinforcement Learning Deployment Model] collects the data taken by the user and integrates the current output of the [Deep Reinforcement Learning Deployment Model] to form a data packet, which is sent back to the [Deep Reinforcement Learning Iteration Model] at a frequency of 5 times per second for online self-learning. The specifications of the data packet are as follows:

[0099] ①Contains data: current moment image s t , the next moment image s t+1 , current moment action ({7.Exposure compensation} step output) a t .

[0100] ②Format: Use JSON format, which contains 3 fields: t Corresponding field names "cur_frame", s t+1 Corresponding field names "nxt_frame", a t The corresponding field name is "cur_action"; where s t and t+1 For image data, it needs to be converted into binary serialized data and put into the field. t The data type is 4-byte floating point.

[0101] The way the data packet is transmitted back should be determined by the specific usage scenario. For stand-alone deployment, the data packet is transmitted by local socket communication; for remote deployment, the data packet is transmitted through the HTTP protocol.

[0102] 1.2.5 Deployment Strategy

[0103] During the self-learning process of the [deep reinforcement learning iterative model], the following deployment conditions apply:

[0104] Deployment condition 1: Record the maximum reward value generated after each iteration of the model, and calculate its average value every 10 iterations. If the ratio of the average value calculated this time to the average value calculated last time exceeds 1.2, this condition is met.

[0105] Deployment condition 2: This condition is met if 100,000 iterations have been completed since the last deployment action.

[0106] Deployment condition 3: In step {6. Capture}, if the user stops capturing the video stream at this time, this condition is met.

[0107] When any one of conditions 1 and 2 is met, and condition 3 is met, the deployment action is performed.

[0108] The deployment action has the following steps:

[0109] ① Export the target Q network in step {3. Online self-learning} to ONNX format.

[0110] ②Convert the model file in ONNX format to the inference backend model file used.

[0111] ③Transfer the backend model file to the remote machine via HTTP or store it on the local disk.

[0112] This completes the model deployment and uses the inference backend to accelerate the inference process.

[0113] 1.2.6 Collection

[0114] The user can use the algorithm to collect the video stream of the scene in real time. The user can start or end this step at any time according to his needs. The specific steps in the collection process are as follows: Figure 4 The green modules in the figure are the steps added to this algorithm.

[0115] 1.2.7 Exposure Compensation

[0116] When the user starts the {6. Collection} step, the [Deep Reinforcement Learning Deployment Model] will collect the current moment image s of the video t Calculate the Q value vector Q(s t ,a), and then use the maximum greedy strategy to select the action a with the largest long-term reward in the current Q value vector t , and give it to the camera module to render the image at the next moment (note that the calculation frame rate of the algorithm is 25 frames per second), and the rendered image s at the next moment t+1 Display to the user and record a t 、s t 、s t+1 Data is used in step {4. Return experience}.

[0117] 2.1 Implementation methods of each module

[0118] 2.1.1 Public Datasets

[0119] The specific steps are performed according to Section 1.1.1, where: the crawling script in step ① is written in Python, mainly using the Python requests package, etc.; the image processing software in step ② uses LightRoom, and its batch processing and saving functions are used to quickly adjust the exposure values ​​of all images. When saving each image, the exposure adjustment value information is used, that is, the label in step ④ is placed in the image name; the random sampling script in step ③ is written in Python, mainly using the Python random package, etc.

[0120] 2.1.2 Deep Learning Pre-training Model

[0121] Deep learning pre-trained models Figure 2 The structure is built using Python language and PyTorch framework. The following are the implementation details of each network module that need additional explanation in addition to the information explained in the figure:

[0122] All convolutional layers: The convolution kernel size is Figure 2 As shown, the filling size is as shown in formula 4:

[0123] Where k is the side length of the convolution kernel and p is the padding size.

[0124] All residual layers: use Bottleneck modules.

[0125] Downsampling layers except Unet: use maximum pooling with a pooling kernel size of 2*2.

[0126] Unet module: 64 input channels, 64 output channels, 4 downsampling layers and 4 upsampling layers, channel variation factor of 2, sampling factor of 2, max pooling for downsampling, and transposed convolution for upsampling.

[0127] All linear layers: No random dropout strategy is used.

[0128] In addition, no batch normalization operation is performed on the output of any layer.

[0129] 2.1.3 Deep reinforcement learning iterative model

[0130] Deep reinforcement learning iterative model Figure 3 Build, refer to Section 2.1.2 for details.

[0131] 2.1.4 Deep reinforcement learning deployment model

[0132] For an overview of the deployment model, see Section 1.2.4. This paper takes the TensorRT inference backend as an example to introduce in detail how to accelerate the deployment of the deep reinforcement learning iterative model. The specific steps are shown in Section 2.2.5.

[0133] 2.1.5 Live Video Streaming

[0134] The real-time video stream acquisition process is as follows: Figure 4 As shown, in terms of hardware, the camera module built into the device (personal computer, mobile phone, industrial computer, embedded development board, etc.) can be used, or an external camera module can be used. The hardware part is not the focus of this invention; in terms of software, the camera module is called using the OpenCV function library and is written in C / C++ language. Figure 4 The "exposure compensation application" step in is also implemented using the corresponding OpenCV API.

[0135] It should be noted that when using the above API to change the exposure compensation of the video stream, the exposure compensation calculated by this algorithm based on the current frame image is generally applied with a delay of 3-10 frames.

[0136] 2.2 Implementation methods of each step

[0137] The specific implementation method of the steps involves: a machine used for training, hereinafter referred to as a training machine; and a deployment machine for running a real-time algorithm, hereinafter referred to as a deployment machine.

[0138] Among them, steps {1. Pre-training}, {2. Reward modeling}, {3. Online self-learning}, and {5. Deployment strategy} are coded in Python on the training machine; steps {4. Feedback experience}, {6. Collection}, and {7. Exposure compensation} are coded in C++ on the deployment machine.

[0139] It should be noted that the present invention does not only include the above environment and configuration. Users can build this algorithm on their own training machines and deployment machines according to their needs. Even in some usage scenarios (such as industrial computer usage scenarios), the training machine and the deployment machine can be the same machine. Of course, in most scenarios, due to the computing power limitations of the deployment end (such as laptops, mobile phones, etc.), the training machine and the deployment machine need to be separated.

[0140] 2.2.1 Pre-training

[0141] The network in the deep learning pre-training model is trained based on the public dataset, and all data are iterated for 100 epochs using Python and PyTorch.

[0142] Training related parameters: learning rate is 5e-4, Adam is used as the optimizer, warmup strategy (Warmup) and multi-step strategy (Multi-Step) are used for learning rate, the number of warmup iterations is 800 times (iteration), the initial learning rate is 1e-5, and the learning rate is reduced when the iteration round reaches 30, 60 and 80 times (epoch), and the reduction ratio is 0.4.

[0143] Data processing method: All training images are standardized and input into the network, all labels are normalized, and the data batch size is 24.

[0144] 2.2.2 Reward Modeling

[0145] Return the s returned in step {4. Return experience} t and t+1 After state transfer (see Section 1.2.3 for details), we get s t-1 and t , substitute into formula 3 to get the score score t-1 and score t , and then substitute it into formula 2 to get the reward r at time t t Just follow the steps {3. Online self-study}.

[0146] 2.2.3 Online Self-Learning

[0147] The implementation of online self-learning should include the following parts:

[0148] ① Parsing of returned experience data: Use Python’s json, cv2 and other packages to parse the current state image, next state image and current action value.

[0149] ② Online reinforcement learning algorithm based on Double-DQN: In this example, a Double-DQN training framework is implemented from scratch using Python and PyTorch; it mainly includes the following basic components: Agent, Trainer, Expriences, and Env. On this basis, components such as DoubleDQNAgent (DoubleDQN agent), Video (real-time video streaming environment), and AsioExps (asynchronous experience pool) are implemented. It can support the online learning process of DoubleDQN. Among them, the asynchronous experience pool uses Python's asyncio.Queue type (asynchronous queue) to implement the asynchronous read and write relationship between the agent training coroutine and the reward modeling and reward calculation coroutine.

[0150] Use the above training framework to implement the online self-learning process and learn the parameters:

[0151] 2.2.4 Feedback Experience

[0152] The step of returning experience requires that the current state best action, current state image, and next state image calculated by the deployment machine be assembled into JSON and then returned to the training machine (server) via HTTP. The server uses the HTTP content length field to determine whether the client is returning experience data.

[0153] 2.2.5 Deployment Strategy

[0154] This section takes the TensorRT Windows platform as an example to introduce the implementation details of the deployment strategy in detail.

[0155] ① When the deployment conditions in Section 1.2.5 are met, select the latest checkpoint model that can be deployed in step {3. Online self-learning}. The judgment of meeting condition 3 needs to be sent by the deployment machine.

[0156] ② Export the model to ONNX format: Since the present invention uses the PyTorch framework, the generated model file is a .pth file. ③ Convert the model file in ONNX format to the inference backend model file used.

[0157] Specifically, use Nvidia's official model conversion tool trtexec to convert the ONNX format model to obtain TensorRTplanfile.

[0158] ④Transfer the backend model file to the deployment machine via HTTP.

[0159] Finally, use Python http.server and BaseHTTPRequestHandler packages to send the serialized planfile model byte stream file to the deployment machine.

[0160] 2.2.6 Collection

[0161] The algorithm flow of this step is as follows Figure 4 , this section focuses on the 3 steps in the green box:

[0162] ①Read the inference model:

[0163] In this example, since the training machine and the deployment machine are separated, it is necessary to read the byte stream model from HTTP. To improve efficiency, C++ code is used here, and the libcurl library is used to directly read the byte stream from the HTTP data packet without transferring it.

[0164] ②Exposure compensation calculation: See {7. Exposure compensation} steps for details.

[0165] ③Exposure compensation application:

[0166] For details, see the method of applying exposure compensation in the [Real-time Video Stream] module in Section 2.1.5.

[0167] Finally, before the user terminates the collection step, the collection status needs to be updated to '0' to the server (training machine).

[0168] 2.2.7 Exposure Compensation

[0169] Finally, the exposure compensation step requires reasoning about the planfile in trt format to obtain the Q value vector, and use the maximum greedy strategy to obtain the action a with the maximum Q value in the current state t , record the corresponding exposure compensation, and apply the exposure compensation to the camera module in the exposure compensation application link in the {6. Acquisition} step. Record s t and t+1 , and then sent back to the training machine in the {5. Send back experience} step. This section focuses on the implementation of the inference TensorRTplanfile and the maximum greedy strategy. Again, for the sake of execution efficiency, this section is completed in C++, and the TensorRT inference library uses the tensorRT_Pro library.

Claims

1. A camera exposure control method based on online self-learning, characterized in that: The following steps are involved: Obtain image data through public datasets and preprocess them; Build a deep learning pre-trained model and train the model using the trained image data; Obtain real-time video stream, use the trained deep learning pre-training model to calculate the exposure prediction value of the state image of two adjacent frames in the video stream, process it, and store the processing results in the experience pool; Construct a deep reinforcement learning iterative model, and use the processed exposure prediction value as the reward of the model to train the deep reinforcement learning iterative model; According to the deployment conditions, the trained deep reinforcement learning iterative model is deployed to the camera to achieve exposure control of the camera.

2. The camera exposure control method based on online self-learning according to claim 1, characterized in that: The deep learning pre-training model adopts a deep neural network structure, the input is image data, the output is the exposure prediction value of the image, and the loss function L of the deep learning pre-training model is trained. pretrain for: Where D is the deviation image, T is the wrong exposure image, w is the image width, h is the image height, y is the network output, t is the optimal exposure compensation value, and L discrepancy is the deviation loss part, L regression is the regression loss part.

3. The camera exposure control method based on online self-learning according to claim 1, characterized in that: The reward of the deep reinforcement learning iterative model is: Among them, r t is the reward at time t, score t 、score t-1 are the scores at time t and time t-1 respectively, Neural network mapping for deep learning pre-trained models, s t 、s t-1 are the states at time t and time t-1 respectively.

4. The camera exposure control method based on online self-learning according to claim 1, characterized in that: The deep reinforcement learning iterative model adopts a competitive deep Q-value network structure, the input is a frame of image collected by the video stream, and the output is the Q-value vector of the current state. The training process of the deep reinforcement learning iterative model is specifically as follows: The estimated Q network asynchronously obtains a set of s from the experience pool k and k+1 , the output of the Q network is estimated by forward propagation calculation At the same time, estimate the last layer output feature map of the Q network backbone network Calculate action a p : Where a is the action to estimate the output of the Q network, To estimate the Q network parameter vector; Target Q network acquisitions k+1 , and calculate Q(s) by forward propagation k+1 ,a p ; ω), ω is the target Q network parameter vector; Q(s k+1 ,a p ;ω) and These calculation results are substituted into the loss function for gradient descent to update the parameters of the estimated Q network; When the number of iterations or the average reward value of each generation in the iteration process or the user's action reaches the deployment condition, all parameters of the estimated Q network are applied to the target Q network to complete the update of the target Q network.

5. The camera exposure control method based on online self-learning according to claim 4, characterized in that: The loss function L online for: Among them, L DQN is the DQN loss, L KD is the distillation loss, r k is the k-time reward, γ is the reinforcement learning parameter, To estimate the network feature map output, E f (s k ;ω e ) is the network feature map output of the deep learning pre-training model, is the estimated Q network parameter vector, ω is the target Q network parameter vector, ω e Parameter vector of a pre-trained model for deep learning.

6. The camera exposure control method based on online self-learning according to claim 1, characterized in that: The deployment conditions are: Deployment condition 1: Record the maximum reward value generated after each iteration, and calculate its average value every 10 iterations. If the ratio of the average value calculated this time to the average value calculated last time exceeds the set threshold, this condition is met; Deployment condition 2: This condition is met when the set number of iterations have been completed since the last deployment action; Deployment condition 3: If the user stops collecting video streams at a certain moment, this condition is met; When any one of deployment conditions 1 and 2 is met, and deployment condition 3 is met, the deployment action is performed.

7. The camera exposure control method based on online self-learning according to claim 1, characterized in that: The deployment is specifically as follows: 1) Export the target Q network to ONNX format; 2) Convert the model file in ONNX format to the inference backend model file used; 3) Transfer the backend model file to a remote machine via HTTP or store it on the local disk.

Citation Information

Cited By

  • Exposure parameter decision and high dynamic range image adaptive exposure control method

    CN121262473A