Background technique
With the development of depth learning technology, the various machine vision cloud services based on deep learning are using more and more.
Again because current depth model generally needs stronger calculation power, the prevailing scenario of deep learning application is that user will be original
Image data uploads to cloud and is identified, it is more and more huger to result in the need for the image data amount uploaded, to bring greatly
Upload flow burden and transmission delay.In addition, development and software defined network (SDN) technology due to processor technology
Propulsion, the operational capability of current edge device (referring mainly to base station, the network facilities close to user side such as CDN) is more and more stronger,
Therefore it is able to for some processor active tasks being placed on edge to complete.
In this regard, there are mainly two types of ways at present.First, by the compression of cloud neural network depth model or cutting, then
Edge side is deployed to avoid directly uploading data to cloud.But since the performance of edge side can not show a candle to the property of Cloud Server
Can be powerful, and particular, it is important that in true application scenarios, due to the consideration of intellectual property and privacy etc., cloud service factory
Quotient tends not to depth model being supplied to user, this results in user that can not be customized deployment to depth model, therefore should
In terms of scheme only rests on academic research, it is unable in actual deployment to production environment;Second scheme is to utilize compression of images
Algorithm uploads to cloud after being compressed image data, still, most of image compression algorithm is all with the mankind at present
Judgment criteria of the visual similarity as compression effectiveness, actually in current application scenarios, more image datas
It is no longer to be checked to the mankind, but judged to depth model, classified, therefore, with being directed to, human visual system is excellent
The compression algorithm of change is carried out compressed picture and is checked to depth model, is not a kind of way of science.
There is few quantifier elimination article in academia, it is intended to exploitation is directed to the compression algorithm of depth model judging nicety rate, but
It is that existing academic research requires to obtain depth model, then needs to carry out re -training and optimization for depth model,
In the case where the original training data for not having depth model and depth model, a set of targetedly compression can not be trained and calculated
Method.
The disclosure of background above technology contents is only used for auxiliary and understands inventive concept and technical solution of the invention, not
The prior art for necessarily belonging to present patent application shows above content in the applying date of present patent application in no tangible proof
Before have disclosed in the case where, above-mentioned background technique should not be taken to evaluation the application novelty and creativeness.
Summary of the invention
It is a primary object of the present invention to propose a kind of picture dynamic self-adapting compression method based on intensified learning, in nothing
In the case that method knows cloud deep learning model detail, the joint training of cloud-edge side is carried out, is directed to cloud so that training is a set of
The image compression algorithm for holding deep learning model judging nicety rate completes figure according to the adaptively selected Compression Strategies of picture feature
The dynamic self-adapting of piece compresses.
The present invention proposes following technical scheme for the above-mentioned purpose:
A kind of picture dynamic self-adapting compression method based on intensified learning, including first stage and second stage;
First stage: 1.1, initial time is worth neural network to the depth-size strategy for being deployed in edge side and carries out at random just
Beginningization;1.2, operation 1 and operation 2 are executed to the current image that user uploads, original image operation 1: is uploaded to cloud;Operation 2: it mentions
It takes characteristics of image and is sent into the depth-size strategy value neural network of random initializtion, calculate using the compression algorithm being pre-configured
After the compression degree of Selection Strategy Maximum Value is compressed, compression is schemed for the policy value that different compression degrees are compressed
It is uploaded to cloud;Image recognition is carried out to original image and compression figure by cloud deep learning model;1.3, receive what cloud returned
Original image recognition result and compression figure recognition result and the comparison for carrying out the two, obtain deep learning model under current compression degree
Compression figure recognition accuracy;1.4, it combines the characteristics of image of current image, compression degree, recognition accuracy and reward value
In queue at memory step one finite length of deposit;So far, a test step is completed;1.5, it to next picture, repeats
Step 1.2~1.4;1.6, it when executing step 1.2~1.5 to when completing M test step, is taken out at random from the queue N number of
Memory step composing training collection starts to train the depth-size strategy value neural network;Meanwhile continuing to execute step to the picture received
Rapid 1.2~1.5 to be continuously updated the queue, also, every K test step of completion just taken out at random from the queue it is N number of
Memory step continues to train the depth-size strategy value neural network;1.7, extremely to depth-size strategy value neural metwork training
Pre-determined number, into the second stage;Wherein: M, N and K are preset value, M >=N;It is accurate that reward value is equal to identification
Rate subtracts compression ratio;In the first stage, recognition result of the cloud to original image is back to user;
Second stage: 2.1, the picture newly uploaded to active user extracts characteristics of image and is sent into trained depth plan
It is slightly worth in neural network, to calculate the policy value compressed using the different compression degrees for the compression algorithm being pre-configured;
2.2, the compression degree of Selection Strategy Maximum Value, the picture that active user is newly uploaded using the compression algorithm of the pre-configuration
It is compressed, cloud is uploaded to after compression, and recognition result of the cloud to compressed picture is back to user.
Present invention technical solution set forth above, is considered as a black-box model for the deep learning model in cloud, uses depth
The method of intensified learning joins the deep learning model that the depth-size strategy for running on marginal end is worth neural network and cloud
Training is closed, so that the depth-size strategy value neural network that marginal end is trained to out can be adaptively according to cloud depth
The feature for practising model and the picture for currently needing to upload changes Compression Strategies.Meanwhile cloud is not influenced also to picture recognition
Accuracy rate.
Specific embodiment
The invention will be further described with specific embodiment with reference to the accompanying drawing.It should be noted that of the invention
Mentioned in " original image " be not in traditional sense directly by the picture pick-up device of user generate and without the original image of any processing,
It, usually will not be by the original graph of user's shooting in the application service since present invention is generally directed to image recognition API cloud services
It is identified as being directly uploaded to cloud, the way of default is that user's picture passes through JPEG compression algorithm to default compression degree
(typically referring to Q=75) compression after is uploaded to cloud again, therefore in the present invention this " by JPEG compression algorithm to default
Picture after compression degree compression " is defined as " original image ".It is further to note that " DQN " is " depth-size strategy value nerve
The abbreviation of network ".
The present invention is directed to image recognition API cloud service framework, proposes a kind of picture dynamic self-adapting based on intensified learning
Compression method, the compression by uploading different compression degrees is schemed and original image is to cloud and according to the recognition result of cloud feedback, no
The intensified learning training of disconnected ground is deployed in depth-size strategy value neural network (DQN) of edge side, reaches DQN and cloud depth model
Joint training and learn the effect to some relevant knowledges of cloud depth model, enable DQN according to the feature of picture with
And cloud depth model adaptively to select suitable compression degree for picture, the picture compressed under the compression degree can be more
It is identified by cloud depth model well rather than on the basis of the vision of people.
With reference to Fig. 1, method of the invention is deployed in the edge device between user terminal and cloud, including the pre-training stage
The re -training stage during (first stage), deployment phase (second stage) and deployment.
The process of first stage includes following 1.1~1.7:
1.1, it carves at the beginning, random initializtion is carried out to the DQN for being deployed in edge side;
1.2, when user uploads a picture, operation 1 and operation 2 is executed to the picture, operation 1: original image is uploaded to
Cloud;Operation 2: extracting characteristics of image by be deployed in edge the one small-scale nonupdatable deep neural network of parameter,
And be sent into the DQN of random initializtion, the DQN of the initialization is allowed to calculate the different compression journeys using the compression algorithm being pre-configured
The policy value compressed is spent, then the compression degree (it is recommended that compression degree) of Selection Strategy Maximum Value carries out the picture
After compression, compression figure is uploaded to cloud;Image recognition is carried out to original image and compression figure by cloud deep learning model;It is prewired
The compression algorithm set is common some compression algorithms in API service, such as can be JPEG compression algorithm.Utilize depth nerve
It is the prior art that network, which carries out image characteristics extraction and its extraction step, and details are not described herein, the characteristics of image extracted
For the one-dimensional floating-point array with regular length, such as the one-dimensional floating-point array that length is 1280.
1.3, the original image recognition result and compression figure recognition result that cloud returns and the comparison for carrying out the two are received, obtains depth
Learning model is spent to the recognition accuracy of the compression figure under current compression degree.We define recognition result of the cloud to original image
Correctly to identify, as the benchmark of compression figure recognition accuracy, even compression figure recognition result is consistent with original image recognition result,
Then the recognition accuracy is 1, otherwise being just 0.1~0.5.
1.4, the characteristics of image of current image, compression degree, recognition accuracy and reward value are combined into a memory step
In deposit memory pond;The processing of one picture experience 1.2~1.4 is called one " test step " by we.Here reward value is
A concept in intensified learning, the recognition accuracy that the reward value of a test step is equal to compression figure in the test step subtract this
Compress the compression ratio of figure.Compression ratio is equal to the size of compression figure and the ratio of original image size." memory pond " is in edge device
The queue of one finite length is remembered pond in the training process and is being updated always.
1.5, to the next picture from user terminal, continue to repeat step 1.2~1.4.
1.6, when complete M test step remember there is M memory to walk in pond when it is necessary to starting to be trained DQN: from
N number of memory step composing training collection is taken out in memory pond at random, starts to train the depth-size strategy value neural network;It is instructed in DQN
While white silk, test step is still being carried out, that is, is continued to picture execution step 1.2~1.5 received to be continuously updated memory pond,
Also, every K test step of completion just takes out N number of memory step at random from memory pond, a DQN training is carried out, until convergence.M,
N and K is preset value, M >=N.In a specific embodiment of the invention, when completing M=200 test step
Start to be trained DQN, N=64 memory step composing training collection is taken out in training at random from memory pond every time, hereafter every 5 step
(K=5) a DQN training is carried out.It should be understood that the present invention does not limit the value of M, N, K, only the value of M is not
It is preferably too small, it must guarantee to form the memory pond with certain amount memory step.
1.7, through after training, reward value can tend towards stability after a period of time, the present invention is by a large amount of experiments repeatedly
Verifying, when DQN frequency of training reaches about 200 times, will restrain, at this time can be with deconditioning, into second stage.Entire
First stage, training process of the invention is in addition to carrying out certain upload load (because to upload original image and survey simultaneously to Netowrk tape
The compression figure of examination) except, it has no effect on user and calls API service, in this stage, the present invention returns to the recognition result of original image
To user.
Wherein, the specific steps of DQN training, are input with feature, using target value relevant to reward value as target:
Step i is remembered to each of training set, target value y is setic=ric+γmaxcQ(φ,c;θ);Wherein, ricIndicate award
Value;γ is award decay factor, and value range is 0.6~0.999;C indicates compression degree, maxcQ(φ,c;θ) exist for DQN
In the case where parameter set θ, all compression degrees of maximum policy value can be chosen in to(for) input feature vector φ;Pass through
Gradient descent algorithm trains DQN, updates the parameter θ of DQN to minimize target value yicWith DQN output valve Q (φ, c;Between θ)
Distance (yic-Q(φ,c;θ))2.It will be restrained after training for about 200 times in experience, the can be entered with deconditioning at this time
Two-stage.
It is suitable that second stage then starts the picture selection for using the above-mentioned trained DQN of the present invention to upload for user
Compression degree is compressed, and only uploads compression figure.Specifically include: the picture newly uploaded to active user extracts characteristics of image
And be sent into trained DQN, trained DQN is calculated using the compression algorithm being pre-configured not according to present image feature
The policy value compressed with compression degree;Then, that compression degree conduct corresponding when selection strategy Maximum Value
It is recommended that compression degree compressed picture is finally uploaded to cloud and is identified to be compressed.In this stage, training
The knowledge for the cloud depth model that good DQN was learnt according to characteristics of image and its training stage, can be picture to be identified
Its suitable compression degree of selection, and due to no longer uploading original image, upload amount can be greatly reduced and guarantee cloud image
The accuracy rate of identification.
During second stage carries out, since the scene change of user's picture is (such as from daytime to evening, from fine day
To misty rain day etc.), it may result in originally trained DQN and be deteriorated to the compression degree estimation of picture, therefore, Wo Menxu
" occasionally " to test whether DQN current is also applicable in, test method is exactly to go to run using the picture received to survey
Try, so that it may accuracy rate is obtained, according to accuracy rate it is known that re -training whether is needed to update DQN.
What opportunity the problem whether current DQN is also applicable in is tested about, and invention defines a test probabilities
ptest, the frequency of test DQN applicability is determined with this probability.In this regard, the present invention generates 0 by a random generator
Random number δ between~1 then carries out an Operability Testing when this random number is less than current test probability, can
See, test probability is smaller, and the frequency for carrying out Operability Testing can be lower.And test probability ptestNor fixed, it is needed
DQN recognition accuracy is crossed in vehicle according to Operability Testing come dynamic change, dynamic more new formula are as follows: ptest'=ptest- λ Δ α,
ptest' indicate that the probability updated, λ value 1.5~5, Δ α indicate that the identification of all Operability Testings until current is accurate
The derivative of rate average value α, probability when initial be it is preset, can be set to 0.2~0.5.
During second stage carries out, at least carries out W Operability Testing and then judge whether to need re -training
DQN;The standard of judgement is: the recognition accuracy average value during V times nearest Operability Testing is opened lower than second stage
When the recognition accuracy average value of the R Operability Testing process of beginning, then re -training depth-size strategy is worth neural network;Again
Training using the picture of the newest upload of user, re-execute the steps 1.2~1.6.Unlike pre-training, due to DQN
There are some priori knowledges, therefore the re -training stage is often more shorter than pre-training, during re -training, works as institute
When stating reward value less than a preset threshold, then re -training is completed, and reenter second stage.Preset threshold is preferably set to
0.3~0.6.Wherein, W, V, R are preset value, are natural number, and V+R≤W.For example, being applicable in when nearest 10 times
Property test recognition accuracy average value lower than start 10 times test recognition accuracy average value when, can be with re -training
DQN.It should be understood that the present invention does not carry out detailed restriction to the value of W, V, R, those skilled in the art can be according to specific
Demand carries out different designs.
User's usage scenario 1 of the invention: large-scale cloud deep learning vision application API Calls, it at this time can band
Load largely is uploaded, at this point, it is deployed in the present invention of edge side, it can be adaptively according to rear end (cloud) depth model
With the suitable compression degree of front-end image feature selecting to be effectively reduced upload load and maintain comparable accuracy rate.
User's usage scenario 2: the cloud deep learning vision application API Calls under the conditions of low bandwidth, vulnerable network, the present invention
Upload load can be compressed, to reduce transmission delay.
For identifying that the higher occasion of request frequency, the present invention more can be reduced upload amount and keep cloud deep learning model
The accuracy rate of identification.Just because of can be reduced upload amount, therefore it can be reduced transmission delay, to the reduction of delay under the conditions of vulnerable network
It becomes apparent.
To sum up, technical solution proposed by the present invention:
1, by the way that intensified learning model is placed on training in interactive environment relevant to rear end depth model, so that side
The DQN that acies is trained to out, not only according to image feature selection compression degree, while also according to the rear end depth learnt
Some relevant knowledges of model select Compression Strategies;
2, by being introduced into rear end depth model as a part in interactive training environment, so that in corresponding training ring
The intensified learning DQN come is trained in border can acquire some knowledge relevant to cloud model, to be directed to different cloud moulds
Type selects different Compression Strategies;
3, by the test probability of a dynamic change, balance uploads load and cloud differentiates accuracy rate, adaptively weighs
The validity that current DQN estimates compression degree is newly measured, once current compression strategy causes accuracy rate to decline, it will automatic weight
Training is opened, to guarantee that long-term accuracy rate maintains maintenance level.
The above content is a further detailed description of the present invention in conjunction with specific preferred embodiments, and it cannot be said that
Specific implementation of the invention is only limited to these instructions.For those skilled in the art to which the present invention belongs, it is not taking off
Under the premise of from present inventive concept, several equivalent substitute or obvious modifications can also be made, and performance or use is identical, all answered
When being considered as belonging to protection scope of the present invention.