CN111860095A - State detection model training method and device and state detection method and device - Google Patents

State detection model training method and device and state detection method and device Download PDF

Info

Publication number
CN111860095A
CN111860095A CN202010209693.0A CN202010209693A CN111860095A CN 111860095 A CN111860095 A CN 111860095A CN 202010209693 A CN202010209693 A CN 202010209693A CN 111860095 A CN111860095 A CN 111860095A
Authority
CN
China
Prior art keywords
state detection
image data
model
integer
detection model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010209693.0A
Other languages
Chinese (zh)
Inventor
林航东
张法朝
徐志远
唐剑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Didi Infinity Technology and Development Co Ltd
Original Assignee
Beijing Didi Infinity Technology and Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Didi Infinity Technology and Development Co Ltd filed Critical Beijing Didi Infinity Technology and Development Co Ltd
Priority to CN202010209693.0A priority Critical patent/CN111860095A/en
Publication of CN111860095A publication Critical patent/CN111860095A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/50Context or environment of the image
    • G06V20/59Context or environment of the image inside of a vehicle, e.g. relating to seat occupancy, driver state or inner lighting conditions
    • G06V20/597Recognising the driver's state or behaviour, e.g. attention or drowsiness
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

The application provides a state detection model training method and device and a state detection method and device, wherein the state detection model training method comprises the following steps: acquiring sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data; taking each floating point type image data as the input of a state detection model, taking a state detection result corresponding to the floating point type image data as the output of the state detection model, and training model parameters of the state detection model to obtain trained floating point type model parameters; and quantizing the floating point type model parameters based on the target quantization coefficient to obtain a state detection model comprising integer model parameters and the target quantization coefficient, wherein the storage space of the integer model parameters is smaller than that of the floating point type model parameters. The method and the device reduce the occupied resources of the model, and improve the calculation speed of the model and the processing efficiency of the model.

Description

State detection model training method and device and state detection method and device
Technical Field
The application relates to the technical field of data processing, in particular to a state detection model training method and device and a state detection method and device.
Background
At present, with the rapid development of the internet, more and more internet products are used by people, such as internet appointment car products. The network appointment platform can provide various travel services for passengers, particularly the services provided by drivers, and in the service process, the service state of the drivers is important, for example, when the drivers drive fatiguedly, the personal safety of the passengers and the drivers can be influenced. Therefore, the network appointment platform trains a Driver Monitoring System (DMS) as a state detection model of a driver during driving in advance, detects a state of the driver during service by acquiring image data of the driver during order service, and based on the image data and the state detection model.
However, the state detection model in the prior art occupies more processing resources, which further results in low processing efficiency.
Disclosure of Invention
In view of the above, an object of the present application is to provide a state detection model training method and apparatus, and a state detection method and apparatus, which can reduce service processing resources occupied by a state detection model and improve processing efficiency of the state detection model.
In a first aspect, an embodiment of the present application provides a state detection model training method, where the method includes:
acquiring sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
taking each floating point type image data as the input of a state detection model, taking a state detection result corresponding to the floating point type image data as the output of the state detection model, and training model parameters of the state detection model to obtain trained floating point type model parameters;
quantizing the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
In a possible implementation, determining the target quantization coefficients corresponding to the floating-point model parameters includes:
acquiring a maximum parameter value and a minimum parameter value of the floating-point model parameter;
acquiring a maximum storage value and a minimum storage value of a target integer storage range;
Determining a target quantization coefficient according to the maximum numerical value and the minimum numerical value of the floating point type model parameter and the maximum numerical value and the minimum numerical value of the target integer type storage range; wherein the processing results of the maximum parameter value and the minimum parameter value, respectively, based on the target quantized coefficients are located within the target integer storage range.
In a possible implementation, the determining a target quantization factor according to the maximum and minimum values of the floating-point model parameter and the maximum and minimum values of the target integer storage range includes:
generating a first operation expression based on the minimum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the target integer storage range;
generating a second operation expression based on the maximum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the target integer storage range;
and determining the target quantization coefficient based on the first operational expression and the second operational expression.
In one possible embodiment, the method further comprises:
And determining the target integer storage range according to the model layer number and the parameter number of the state detection model.
According to the state detection model training method provided by the embodiment of the application, after the trained state detection model comprising the high-precision floating point type model parameters is obtained by training the state detection model, the high-precision floating point type model parameters of the state detection model are subjected to quantization processing to obtain the integer model parameters of the state detection model, the storage resources occupied by the model are reduced, in the model application process, the integer model parameters are processed, the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
In a second aspect, an embodiment of the present application further provides a state detection model training method, where the method includes:
acquiring sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
quantizing the floating point type image data based on the first quantization coefficient to obtain integer type image data, and quantizing the floating point type model parameter of the state detection model based on the second quantization coefficient to obtain integer type model parameter;
And taking each of the integer image data and the first quantization coefficient as the input of the state detection model, taking a state detection result corresponding to the integer image data as the output of the state detection model, and training the model parameters of the state detection model based on the integer model parameters and the second quantization coefficient to obtain the trained state detection model comprising the target integer model parameters and the target second quantization parameter.
In one possible embodiment, determining the first quantized coefficient corresponding to the floating-point image data includes:
acquiring maximum image data and minimum image data of the floating-point image data;
acquiring a maximum storage value and a minimum storage value of a first integer storage range;
determining a first quantization coefficient from the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In one possible embodiment, the determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value includes:
Generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In one possible embodiment, the method further comprises:
and determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to a floating point type model parameter, and the floating point type model parameter corresponds to an integer type model parameter and a second quantization coefficient; in training the model parameters of the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation, in the training of the model parameters of the state detection model, the method further includes:
obtaining a calculation formula applied to training model parameters of the state detection model;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
training the model parameters of the state detection model based on the calculation result of the expanded fourth operation expression.
According to the state detection model training method provided by the embodiment of the application, in the process of training the state detection model, high-precision floating point type model parameters of the state detection model and floating point type image data used by the training model are quantized, and the state detection model is trained on the basis of the quantized integer model parameters, integer image data and corresponding quantization coefficients to obtain the trained state detection model comprising target integer model parameters and target second quantization parameters; therefore, through the quantitative processing of the training of the state detection model, the processing resources consumed in the model training process are reduced, the storage resources occupied by the trained model are also reduced, and in the model application process, the model is processed through the integer model parameters, so that the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
In a third aspect, an embodiment of the present application further provides a state detection method applied to a state detection model, where the state detection model is obtained by training based on the state detection model training method described in any one of the first aspects, or is obtained by training based on the state detection model training method described in any one of the second aspects, and the method includes:
acquiring floating point type image data to be processed of a service provider corresponding to a target order;
quantizing the floating point type image data to be processed according to the first quantization coefficient to obtain integer type image data to be processed;
inputting the to-be-processed integer image data into the pre-trained state detection model to obtain an output result of the state detection model;
and determining the state information of the service provider corresponding to the target order based on the output result of the state detection model.
In a possible implementation, determining the first quantized coefficient corresponding to the floating-point image data to be processed includes:
acquiring maximum image data and minimum image data of the floating point type image data to be processed;
acquiring a maximum storage value and a minimum storage value of a first integer storage range;
Determining a first quantization coefficient from the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In one possible embodiment, the determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value includes:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In one possible embodiment, the method further comprises:
and determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to an integer model parameter, and each integer model parameter corresponds to a second quantization coefficient; in processing the reshaped image data by the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation, during the processing of the reshaped image data by the state detection model, the method further comprises:
obtaining a calculation formula applied by the state detection model to process the integer image data;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
and determining an output result of the state detection model based on a calculation result of the expanded fourth operation formula.
The state detection method provided by the embodiment of the application applies the trained state detection model comprising the integer model parameters and the corresponding quantitative parameters, and the model occupies less storage resources; in the process of processing the floating point type image data to be processed of the service provider corresponding to the target order in the service process through the state detection model, the floating point type image data to be processed input into the model is quantized, and then the state information of the service provider corresponding to the target order is determined based on the output result of the model.
In a fourth aspect, an embodiment of the present application further provides a state detection model training apparatus, where the apparatus includes:
the first acquisition module is used for acquiring sample data of a service provider corresponding to a plurality of completed orders in the service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
the training module is used for taking each floating point type image data as the input of a state detection model, taking a state detection result corresponding to the floating point type image data as the output of the state detection model, and training model parameters of the state detection model to obtain well-trained floating point type model parameters;
the quantization processing module is used for carrying out quantization processing on the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum parameter value and the minimum parameter value of the floating-point type model parameter;
The third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the target integer storage range;
the first determining module is used for determining a target quantization coefficient according to the maximum numerical value and the minimum numerical value of the floating-point model parameter and the maximum numerical value and the minimum numerical value of the target integer storage range; wherein the processing results of the maximum parameter value and the minimum parameter value, respectively, based on the target quantized coefficients are located within the target integer storage range.
In a possible implementation, the first determining module determines a target quantization factor according to the maximum and minimum values of the floating-point model parameter and the maximum and minimum values of the target integer storage range, and includes:
generating a first operation expression based on the minimum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the target integer storage range;
generating a second operation expression based on the maximum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the target integer storage range;
and determining the target quantization coefficient based on the first operational expression and the second operational expression.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the target shaping storage range according to the model layer number and the parameter number of the state detection model.
The state detection model training device provided by the embodiment of the application trains the state detection model, and after the trained state detection model comprising the high-precision floating point type model parameters is obtained, the high-precision floating point type model parameters of the state detection model are subjected to quantization processing to obtain the integer model parameters of the state detection model, so that the storage resources occupied by the model are reduced, in the model application process, the integer model parameters are processed, the calculation speed of the model is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
In a fifth aspect, an embodiment of the present application further provides a state detection model training apparatus, where the apparatus includes:
the first acquisition module is used for acquiring sample data of a service provider corresponding to a plurality of completed orders in the service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
The quantization processing module is used for performing quantization processing on the floating point type image data based on a first quantization coefficient to obtain integer type image data and performing quantization processing on a floating point type model parameter of the state detection model based on a second quantization coefficient to obtain an integer type model parameter;
and the training module is used for taking each integer image data and the first quantization coefficient as the input of the state detection model, taking a state detection result corresponding to the integer image data as the output of the state detection model, training the model parameters of the state detection model based on the integer model parameters and the second quantization coefficient, and obtaining the trained state detection model comprising the target integer model parameters and the target second quantization parameter.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum image data and the minimum image data of the floating-point image data;
the third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the first integer storage range;
a first determining module for determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In a possible implementation, the first determining module determines a first quantized coefficient according to the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value, including:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to a floating point type model parameter, and the floating point type model parameter corresponds to an integer type model parameter and a second quantization coefficient; the training module further comprises, in the process of training the model parameters of the state detection model:
For each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation manner, the training module, in training the model parameters of the state detection model, includes:
obtaining a calculation formula applied to training model parameters of the state detection model;
If the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
training the model parameters of the state detection model based on the calculation result of the expanded fourth operation expression.
In the state detection model training device provided by the embodiment of the application, in the process of training the state detection model, high-precision floating point type model parameters of the state detection model and floating point type image data used by the training model are quantized, and the state detection model is trained based on the quantized integer model parameters, integer image data and corresponding quantization coefficients to obtain the trained state detection model comprising target integer model parameters and target second quantization parameters; therefore, through the quantitative processing of the training of the state detection model, the processing resources consumed in the model training process are reduced, the storage resources occupied by the trained model are also reduced, and in the model application process, the model is processed through the integer model parameters, so that the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
In a sixth aspect, an embodiment of the present application further provides a state detection apparatus, which is applied to a state detection model, where the state detection model is obtained by training based on the state detection model training apparatus according to any one of the fourth aspects, or is obtained by training based on the state detection model training apparatus according to any one of the fifth aspects, and the apparatus includes:
the first acquisition module is used for acquiring floating point type image data to be processed of a service provider corresponding to the target order;
the quantization processing module is used for performing quantization processing on the floating point type image data to be processed according to a first quantization coefficient to obtain integer type image data to be processed;
the computing module is used for inputting the to-be-processed integer image data into the pre-trained state detection model to obtain an output result of the state detection model;
and the determining module is used for determining the state information of the service provider corresponding to the target order based on the output result of the state detection model.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum image data and the minimum image data of the floating point type image data to be processed;
The third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the first integer storage range;
a first determining module for determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In a possible implementation, the first determining module determines a first quantized coefficient according to the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value, including:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to an integer model parameter, and each integer model parameter corresponds to a second quantization coefficient; the calculation module further includes, during the processing of the integer image data by the state detection model:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation, the calculation module, in processing the reshaped image data by the state detection model, includes:
obtaining a calculation formula applied by the state detection model to process the integer image data;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
and determining an output result of the state detection model based on a calculation result of the expanded fourth operation formula.
The state detection device provided by the embodiment of the application applies the trained state detection model comprising the integer model parameters and the corresponding quantitative parameters, and the model occupies less storage resources; in the process of processing the floating point type image data to be processed of the service provider corresponding to the target order in the service process through the state detection model, the floating point type image data to be processed input into the model is quantized, and then the state information of the service provider corresponding to the target order is determined based on the output result of the model.
In a seventh aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the state detection model training method according to any one of the first aspect.
In an eighth aspect, this application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the state detection model training method according to any one of the first aspect.
In a ninth aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the state detection model training method according to any one of the second aspect.
In a tenth aspect, the present embodiments further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, performs the steps of the state detection model training method according to any one of the second aspects.
In an eleventh aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the state detection method according to any one of the third aspect.
In a twelfth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the state detection method according to any one of the third aspects.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
FIG. 1 is a flow chart illustrating a method for training a state detection model according to an embodiment of the present disclosure;
FIG. 2 is a flow chart illustrating another method for training a state detection model according to an embodiment of the present disclosure;
FIG. 3 is a flow chart illustrating another method for training a state detection model according to an embodiment of the present disclosure;
FIG. 4 is a flow chart illustrating another method for training a state detection model according to an embodiment of the present disclosure;
FIG. 5 is a flow chart illustrating another method for training a state detection model according to an embodiment of the present disclosure;
FIG. 6 is a flow chart illustrating a status detection method provided by an embodiment of the present application;
FIG. 7 is a schematic structural diagram illustrating a state detection model training apparatus according to an embodiment of the present disclosure;
FIG. 8 is a schematic structural diagram of another state detection model training apparatus provided in the embodiments of the present application;
fig. 9 is a schematic structural diagram illustrating a state detection apparatus according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
fig. 11 is a schematic structural diagram of another electronic device provided in an embodiment of the present application;
fig. 12 shows a schematic structural diagram of another electronic device provided in an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
To enable those skilled in the art to utilize the present disclosure, the following embodiments are presented in conjunction with a specific application scenario, "network appointment area". It will be apparent to those skilled in the art that the general principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the application. Although the present application is described primarily in the context of the "net appointment area," it should be understood that this is merely one exemplary embodiment.
The terms "passenger," "requestor," "service requestor," and "customer" are used interchangeably in this application to refer to an individual, entity, or tool that can request or order a service. The terms "driver," "provider," "service provider," "provider" are used interchangeably in this application to refer to an individual, entity, or tool that can provide a service. It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
The following describes a state detection model training method and a state detection method provided in the embodiments of the present application in detail.
Referring to fig. 1, a method for training a state detection model according to a first embodiment of the present application is provided, where the method includes:
s101, acquiring sample data of a plurality of service providers corresponding to completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data.
S102, taking each floating point type image data as input of a state detection model, taking a state detection result corresponding to the floating point type image data as output of the state detection model, and training model parameters of the state detection model to obtain trained floating point type model parameters.
S103, quantizing the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
According to the state detection model training method provided by the embodiment of the application, after the trained state detection model comprising the high-precision floating point type model parameters is obtained by training the state detection model, the high-precision floating point type model parameters of the state detection model are subjected to quantization processing to obtain the integer model parameters of the state detection model, the storage resources occupied by the model are reduced, in the model application process, the integer model parameters are processed, the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
The above exemplary steps of the present application are specifically described below.
S101, acquiring sample data of a plurality of service providers corresponding to completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data.
In the embodiment of the application, the vehicle-mounted equipment is pre-installed in the operation vehicle (namely, inside the operation vehicle) registered by the network car booking platform, the vehicle-mounted equipment comprises the camera, the service provider (namely, a driver) starts the operation vehicle and simultaneously starts the vehicle-mounted equipment, and correspondingly, the vehicle-mounted equipment acquires the image data in the operation vehicle where the vehicle-mounted equipment is located through the camera and sends the image data to the server. Wherein the image data comprises image data of state information of the driver in the service process.
After the driver searches for the service request sent by the passenger through the service request terminal through the service providing terminal and confirms to provide the service (namely, order taking), the server generates a corresponding order, records order information of the order, and simultaneously records image data of the driver corresponding to the order in the service process.
In the embodiment of the application, the training process of the state detection model is performed at the server side. The server obtains image data corresponding to a plurality of completed orders (namely historical orders), and generates a state detection result corresponding to each completed order based on a state labeling result of each image data. The status labeling result is corresponding status information of the driver in the corresponding completed order execution process, and the status information is, for example, a face position, an eye position, a mouth position, a nose position, whether the driver is tired of driving, whether the driver has bad behavior (such as smoking), and the like.
In the embodiment of the application, the obtained completed order (i.e., the historical order) corresponds to image data, and the image data is preprocessed, for example, the image data is normalized, and the preprocessed image data is accurate to a decimal place, so that the cloud server stores the processed image data by using float32 bits, and obtains the floating-point image data. And the server takes the floating point type image data corresponding to the completed orders and the state detection result corresponding to each image data as training sample data.
The process of preprocessing (such as normalization processing) the image data is as follows: the image data is a 256-by-256 matrix, each data in the matrix is a numerical value with color brightness between 0 and 255, the matrix is normalized, for example, a ratio of each value in the matrix to a first target numerical value (for example, 255) is calculated, a product of the ratio and a second target numerical value (for example, 2) is calculated, a difference value of the product and a third target numerical value (for example, 1) is calculated to obtain a processed matrix, and then the processed matrix is obtained, and the processed image data is accurate to decimal bits, so that the server stores the processed image data through float32 bits, and then the floating-point type image data is obtained.
S102, taking each floating point type image data as input of a state detection model, taking a state detection result corresponding to the floating point type image data as output of the state detection model, and training model parameters of the state detection model to obtain trained floating point type model parameters.
In the embodiment of the application, the state detection model comprises an input layer, a plurality of intermediate layers and an output layer which are sequentially connected; wherein the intermediate layers of the two edges are connected with the input layer and the output layer respectively. Each intermediate layer corresponds to a model parameter, wherein in order to improve the training precision of the state detection model and further improve the accuracy of the detection result of the state detection model, the model parameters of the state detection model are accurate to decimal places, so that the server stores the model parameters of the state detection model through float32 bits to obtain floating point type model parameters.
Each floating point type image data is used as the input data of an input layer, the input layer outputs the input data to an intermediate layer, each intermediate layer calculates the input data of the intermediate layer and the floating point type model parameters corresponding to the intermediate layer, the calculation result is used as the input data of the intermediate layer next to the intermediate layer, the analogy is carried out in sequence, the calculation result of the last intermediate layer is sent to the output layer, the output layer outputs the detection result, then the detection result output by the output layer is compared with the state detection result corresponding to the floating point type image data, the model parameters of the state detection model are updated according to the comparison result, namely the model parameters corresponding to each intermediate layer of the state detection model are updated until the error between the actual detection result of the state detection model based on the floating point type image data and the state detection result corresponding to the floating point type image data is within the preset range, and obtaining a state detection model comprising the trained model parameters.
S103, quantizing the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
In the embodiment of the application, the model parameters of the trained state detection model are accurate to decimal places, and the state detection model needs to be stored through float32 bits; in the embodiment of the present application, the state detection model is applied to the vehicle-mounted device, where the vehicle-mounted device is usually an embedded device based on an android system (i.e., LINUX system), and the resource of the vehicle-mounted device is limited, so that the state detection model may occupy more storage resources of the vehicle-mounted device, and may also occupy more processing resources in the process of applying the state detection model. In order to reduce the occupation of resources of the vehicle-mounted device, in the embodiment of the present application, the floating-point model parameters are quantized, and the floating-point model parameters are quantized into integer model parameters, so as to obtain a state detection model including the integer model parameters.
The specific quantization process comprises: and determining a target quantization coefficient corresponding to the floating point model parameter, and quantizing the trained floating point model parameter based on the target quantization coefficient to obtain a state detection model comprising an integer model parameter and the target quantization coefficient. The target quantization coefficient is a numerical value, and the quantization process may be to calculate and round the product of the floating-point model parameter and the target quantization coefficient. The integer model parameter is mapped to a target integer storage range corresponding to a target quantization coefficient, for example, to a storage range corresponding to int8, that is, to a storage range corresponding to integer 8 bits.
For example, the floating-point type model parameter-1.54 is multiplied by the target quantization factor 4 to obtain the integer model parameter-6 within the (-127, 128) storage range corresponding to int 8.
Further, as shown in fig. 2, the method for training a state detection model provided in the embodiment of the present application, for determining a target quantization coefficient corresponding to the floating-point model parameter, includes:
s201, obtaining the maximum parameter value and the minimum parameter value of the floating-point model parameter.
In the embodiment of the present application, the floating-point type model parameter is a matrix, the matrix includes a plurality of parameter values, and a maximum parameter value and a minimum parameter value are selected from the matrix.
S202, acquiring the maximum storage value and the minimum storage value of the target integer storage range.
In the embodiment of the application, the target integer storage range is determined according to the number of model layers and the parameter quantity of the state detection model. For example, the larger the number of model layers and the number of parameters, the smaller the target integer storage range that can be set accordingly.
For example, the target shaping storage range is a storage range (-127, 128) corresponding to int8, and accordingly, the maximum storage value (e.g., 128) and the minimum storage value (e.g., 127) are selected from the target shaping storage range.
S203, determining a target quantization coefficient according to the maximum numerical value and the minimum numerical value of the floating-point model parameter and the maximum numerical value and the minimum numerical value of the target integer storage range; wherein the processing results of the maximum parameter value and the minimum parameter value, respectively, based on the target quantized coefficients are located within the target integer storage range.
In the embodiment of the application, two equations are constructed according to the maximum parameter value and the minimum parameter value of the floating-point model parameter and the maximum storage value and the minimum storage value of the target integer storage range, and the two equations include a variable of a target quantization coefficient to be determined, so that the target quantization coefficient can be calculated based on the two equations.
Wherein the result of the processing of the maximum parameter value and the minimum parameter value, respectively, based on the determined target quantization factor is located within the target integer storage range, and correspondingly, the result of the processing of the maximum parameter value based on the determined target quantization factor is close to or equal to the maximum storage value of the target integer storage range, and the result of the processing of the minimum parameter value based on the determined target quantization factor is close to or equal to the minimum storage value of the target integer storage range, in order to reduce the loss of precision after the floating-point model parameters are converted into integer model parameters.
Further, the method for training a state detection model provided in the embodiment of the present application, where a target quantization coefficient is determined according to the maximum numerical value and the minimum numerical value of the floating-point model parameter and the maximum numerical value and the minimum numerical value of the target integer storage range, includes the following steps:
and generating a first operation expression based on the minimum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the target integer storage range.
And generating a second operation expression based on the maximum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the target integer storage range.
And determining the target quantization coefficient based on the first operational expression and the second operational expression.
In the embodiment of the application, the target integer storage range is (-127, 128) corresponding to int8, x is used to represent any value in the target integer storage range, and correspondingly, -127 < x < 128; and s is used for representing a target quantization coefficient to be determined, and correspondingly, -1.5 < s (x-q) < 2.0, wherein q represents a bias coefficient and is used for adjusting the output result of the model. Where ". x" denotes a multiplication calculation.
Accordingly, the formula is converted as follows:
Figure BDA0002422395450000121
based on this equation, the following equation is obtained:
equation 1:
Figure BDA0002422395450000122
equation 2:
Figure BDA0002422395450000123
based on the above two equations, s and q can be calculated, and accordingly, s is the target quantization coefficient.
According to the state detection model training method provided by the embodiment of the application, after the trained state detection model comprising the high-precision floating point type model parameters is obtained by training the state detection model, the high-precision floating point type model parameters of the state detection model are subjected to quantization processing to obtain the integer model parameters of the state detection model, the storage resources occupied by the model are reduced, in the model application process, the integer model parameters are processed, the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
As shown in fig. 3, a second embodiment of the present application further provides a state detection model training method, where the training method performs quantization processing in the state detection model process to reduce processing resources consumed in the state detection model training process, improve training efficiency of the state detection model, reduce occupied resources of the state detection model, and improve processing efficiency of the state detection model, and the method includes:
S301, acquiring sample data of a plurality of service providers corresponding to completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data.
The specific content of this step is the same as S101, and is not described here again.
S302, the floating point type image data are quantized based on the first quantization coefficient to obtain integer type image data, and floating point type model parameters of the state detection model are quantized based on the second quantization coefficient to obtain integer type model parameters.
In the embodiment of the application, the model parameters of the floating-point image data and the state detection model are accurate to decimal places, and the detection accuracy of the model can be improved based on the high-precision floating-point image data and the floating-point model parameter training model. Correspondingly, the server stores the floating-point type image data and the floating-point type model parameters through float32 bits, and trains the relevant model based on the floating-point type image data and the floating-point type model parameters, so that in the model training process, the occupied processing resources are large, and the training efficiency is low.
Based on this, the embodiment of the application quantizes the floating-point image data and the floating-point model parameters to be quantized in the integer storage range, so as to reduce the computational resources consumed in the model training process and improve the training efficiency.
In the embodiment of the application, a first quantization coefficient corresponding to the floating-point image data is determined, and the floating-point image data is quantized based on the first quantization coefficient to obtain integer image data. The first quantization coefficient is a numerical value, and the quantization process may be to calculate and round a product of the floating point image data and the first quantization coefficient. The integer image data is mapped into a first integer storage range corresponding to the first quantized coefficient, for example, a storage range corresponding to int8, i.e., a storage range corresponding to 8 bits of integer (-127, 128).
And determining a second quantization coefficient corresponding to the floating point type model parameter, and carrying out quantization processing on the floating point type model parameter based on the second quantization coefficient to obtain an integer type model parameter. The second quantization coefficient is a numerical value, and the quantization process may be calculating and rounding a product of the floating point model parameter and the second quantization coefficient. The integer model parameter is mapped to a first integer storage range corresponding to the second quantized coefficient, for example, a storage range corresponding to int8, i.e., a storage range corresponding to 8 bits of integer (-127, 128).
And S303, taking each of the integer image data and the first quantization coefficient as the input of the state detection model, taking the state detection result corresponding to the integer image data as the output of the state detection model, and training the model parameters of the state detection model based on the integer model parameters and the second quantization coefficient to obtain the trained state detection model comprising the target integer model parameters and the target second quantization parameter.
In the embodiment of the application, the state detection model comprises an input layer, a plurality of intermediate layers and an output layer which are sequentially connected; wherein the intermediate layers of the two edges are connected with the input layer and the output layer respectively. Each intermediate layer corresponds to a floating point type model parameter, the floating point type model parameter corresponds to a converted integer type model parameter, and the integer type model parameter corresponds to a second quantization coefficient.
Each integer image data and the first quantization coefficient are used as input data of an input layer, each intermediate layer is output to an intermediate layer from the input layer, each intermediate layer obtains an output result of the intermediate layer on the basis of the input data of the intermediate layer, the integer model parameters corresponding to the intermediate layer and the second quantization coefficient, the output result is obtained on the basis of the input data of the intermediate layer and input data of the intermediate layer next to the intermediate layer, calculation is performed by analogy in sequence, the calculation result of the last intermediate layer is sent to the output layer, the output layer outputs a detection result, the detection result of the output layer based on the state detection model is compared with the state detection result corresponding to the floating point image data, the model parameters of the state detection model are updated according to the comparison result, namely the model parameters corresponding to each intermediate layer of the state detection model are updated until the error between the actual detection result of the state detection model based on the floating point image data and the state detection result corresponding to the floating point image data is within, and obtaining a state detection model comprising the trained model parameters.
Further, as shown in fig. 4, in the state detection model training method provided in the embodiment of the present application, determining the first quantization coefficient corresponding to the floating-point image data includes:
s401, acquiring the maximum image data and the minimum image data of the floating-point image data.
In the embodiment of the present application, the floating-point image data corresponds to a matrix, the matrix includes a plurality of numerical values, the maximum numerical value is selected from the matrix as the maximum image data, and the minimum numerical value is selected from the matrix as the minimum image data.
S402, acquiring the maximum storage value and the minimum storage value of the first integer storage range.
In the embodiment of the application, the first shaping storage range is determined according to the number of model layers and the parameter quantity of the state detection model. For example, the larger the number of model layers and the number of parameters, the smaller the first shaping memory range that can be set accordingly.
For example, the first shaping storage range is a storage range (-127, 128) corresponding to int8, and accordingly, the maximum storage value (e.g., 128) and the minimum storage value (e.g., 127) are selected from the first shaping storage range.
S403, determining a first quantization coefficient according to the maximum image data, the minimum image data, the maximum storage value and the minimum storage value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In the embodiment of the present application, two equations are constructed according to the maximum image data and the minimum image data of the floating-point image data and the maximum storage value and the minimum storage value of the first integer storage range, where the two equations include a variable of a first quantization coefficient to be determined, and therefore, the first quantization coefficient can be calculated based on the two equations.
Wherein the processing result of the maximum image data and the minimum image data based on the determined first quantization coefficient, respectively, is located within the first integer storage range, and correspondingly, the processing result of the maximum image data based on the determined first quantization coefficient is close to or equal to the maximum storage value of the first integer storage range, and the processing result of the minimum image data based on the determined first quantization coefficient is close to or equal to the minimum storage value of the first integer storage range, in order to reduce the loss of precision of the floating point type image data.
Further, in the state detection model training method provided in the embodiment of the present application, the determining a first quantization coefficient according to the maximum image data, the minimum image data, the maximum storage value, and the minimum storage value includes:
And generating a first operation expression based on the minimum image data, the first quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the first integer storage range.
And generating a second operation expression based on the maximum image data, the first quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the first integer storage range.
Determining the first quantized coefficient based on the first and second arithmetic expressions.
In the embodiment of the application, the first integer storage range is (-127, 128) corresponding to int8, x represents any value in the first integer storage range, and correspondingly, -127 < x < 128; a first quantization factor is determined in s, correspondingly, -1.5 < s (x-q) < 2.0, wherein q represents a bias factor for adjusting the output result of the model. Where ". x" denotes a multiplication calculation.
Accordingly, the formula is converted as follows:
Figure BDA0002422395450000141
based on this equation, the following equation is obtained:
equation 1:
Figure BDA0002422395450000151
equation 2:
Figure BDA0002422395450000152
based on the above two equations, s and q can be calculated, and accordingly, s is the first quantized coefficient.
The second quantized coefficients are determined in a manner similar to the calculation of the target quantized coefficients in the first embodiment and the first quantized coefficients in the present embodiment, and will not be described here.
Further, in the state detection model training method provided in the embodiment of the present application, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to a floating point type model parameter, and the floating point type model parameter corresponds to an integer type model parameter and a second quantization coefficient; in training the model parameters of the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In the embodiment of the present application, for a first intermediate layer, that is, an intermediate layer directly connected to an input layer, input data of the first intermediate layer is integer image data and a first quantization coefficient corresponding to the integer image data, and the intermediate layer determines an output result of the intermediate layer based on the integer image data, the first quantization coefficient, an integer model parameter corresponding to the intermediate layer, and a second quantization coefficient corresponding to the model parameter, and uses the output result as input data of a next intermediate layer. The output result of the middle layer may exceed the first integer storage range, and therefore, the output result needs to be stored through the second integer storage range, for example, the first integer storage range is a storage range corresponding to int8, and the second integer storage range may be a storage range corresponding to int 16. When the output result is used as input data of a next intermediate layer, it is necessary to determine the output result as a third quantization coefficient corresponding to the input data, and perform quantization processing on the input data based on the third quantization coefficient to map data in the second integer storage range into the first integer storage range, and accordingly, re-determine a fourth quantization coefficient corresponding to the input data according to the third quantization coefficient. And determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer and the second quantization coefficient corresponding to the integer model parameter, and repeating the process until the output result of the last intermediate layer is sent to the output layer.
Then, outputting a detection result based on the output layer, comparing the detection result based on the output layer of the state detection model with a state detection result corresponding to the floating point type image data, and updating model parameters of the state detection model according to the comparison result, namely updating model parameters corresponding to each intermediate layer of the state detection model until the error between the actual detection result based on the floating point type image data and the state detection result corresponding to the floating point type image data of the state detection model is within a preset range, so as to obtain the state detection model comprising a target integer type model parameter and a target second quantization parameter.
Further, as shown in fig. 5, in the state detection model training method provided in the embodiment of the present application, in the process of training the model parameters of the state detection model, the method further includes:
s501, obtaining a calculation formula applied to training of model parameters of the state detection model.
S502, if a third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula.
And S503, training the model parameters of the state detection model based on the calculation result of the expanded fourth operation expression.
In the embodiment of the present application, the third operation formula may be ln (1+ y), eyCosy, siny, etc.; wherein y represents the output result of a certain intermediate layer; the target expansion formulas corresponding to different third operation formulas are different, and the target expansion formula can be a taylor series expansion formula of a target dimension, wherein the target dimension refers to a constant of a maximum term in the taylor series expansion formula.
For example, the target dimension is 7, the third formula is ln (1+ y), and the expansion formula is as follows:
Figure BDA0002422395450000161
according to the state detection model training method provided by the embodiment of the application, in the process of training the state detection model, high-precision floating point type model parameters of the state detection model and floating point type image data used by the training model are quantized, and the state detection model is trained on the basis of the quantized integer model parameters, integer image data and corresponding quantization coefficients to obtain the trained state detection model comprising target integer model parameters and target second quantization parameters; therefore, through the quantitative processing of the training of the state detection model, the processing resources consumed in the model training process are reduced, the storage resources occupied by the trained model are also reduced, and in the model application process, the model is processed through the integer model parameters, so that the model calculation speed is increased, the processing resources consumed in the model calculation process are reduced, and the processing efficiency is improved.
As shown in fig. 6, a third embodiment of the present application further provides a state detection method applied to a state detection model, where the state detection model is obtained by training based on a state detection model training method in the first embodiment, or is obtained by training based on a state detection model training method in the second embodiment, and the method includes:
s601, floating point type image data to be processed of a service provider corresponding to the target order are obtained.
The state detection method provided by the embodiment of the application can be applied to a server and can also be applied to terminal equipment. In the embodiment of the present application, a description will be given by taking as an example an in-vehicle device applied to the field of network appointment.
In the embodiment of the application, the vehicle-mounted equipment is installed inside a running vehicle registered on a network booking platform, the vehicle-mounted equipment comprises a camera, a service provider (namely a driver) starts the running vehicle and simultaneously starts the vehicle-mounted equipment, and correspondingly, the vehicle-mounted equipment acquires image data in the running vehicle where the vehicle-mounted equipment is located through the camera and sends the image data to the server. Wherein the image data comprises image data of state information of the driver in the service process. And acquiring image data corresponding to the target order in the execution process of the target order.
S602, carrying out quantization processing on the floating point type image data to be processed according to the first quantization coefficient to obtain integer type image data to be processed.
In the embodiment of the application, the acquired image data is preprocessed, for example, the image data is normalized, and the preprocessed image data is accurate to a decimal place, so that the cloud server stores the processed image data by using float32 bits to obtain floating point type image data. And the server takes the floating point type image data corresponding to the completed orders and the state detection result corresponding to each image data as training sample data.
The process of preprocessing (such as normalization processing) the image data is as follows: the image data is a 256-by-256 matrix, each data in the matrix is a value with color brightness between 0 and 255, the matrix is normalized, for example, a ratio of each value in the matrix to a first target value (for example, 255) is calculated, a product of the ratio and a second target value (for example, 2) is calculated, and a difference value between the product and a third target value (for example, 1) is calculated to obtain a processed matrix, namely processed image data, the processed image data is accurate to decimal bits, so that the server stores the processed image data through float32 bits, namely floating-point type image data is obtained.
In the embodiment of the application, a first quantization coefficient corresponding to the floating-point image data is determined, and the floating-point image data is quantized based on the first quantization coefficient to obtain integer image data. The first quantization coefficient is a numerical value, and the quantization process may be to calculate and round a product of the floating point image data and the first quantization coefficient. The integer image data is mapped to a first integer memory range corresponding to the first quantized coefficient, for example, to a memory range corresponding to int8, i.e., to a memory range (-127, 128) corresponding to 8 bits of integer.
S603, inputting the to-be-processed integer image data into the pre-trained state detection model to obtain an output result of the state detection model.
In the embodiment of the application, the state detection model comprises an input layer, a plurality of intermediate layers and an output layer which are sequentially connected; wherein the intermediate layers of the two edges are connected with the input layer and the output layer respectively. Each intermediate layer corresponds to an integer model parameter, which corresponds to a second quantized coefficient.
And taking the integer image data to be processed and the second quantization coefficient as input data of an input layer of the state detection model, outputting the input data to intermediate layers from the input layer, determining an output result of each intermediate layer based on the input data of the intermediate layer, the corresponding integer model parameter of the intermediate layer and the second quantization coefficient corresponding to the integer model parameter, calculating by analogy in turn when the output result is used as the input data of the intermediate layer next to the intermediate layer, sending the calculation result of the last intermediate layer to the output layer, and outputting the detection result by the output layer.
S604, determining the state information of the service provider corresponding to the target order based on the output result of the state detection model.
In the embodiment of the application, the position of the face, the position of the eyes, the position of the mouth and the position of the nose, whether the driver is tired and whether the driver has bad behaviors (such as smoking) and the like.
Further, the state detection method provided in the embodiment of the present application, which determines the target quantization coefficient corresponding to the floating point type image data to be processed, includes the following three steps:
the method comprises the following steps of firstly, acquiring maximum image data and minimum image data of the floating point type image data to be processed.
In the embodiment of the present application, the floating-point image data corresponds to a matrix, the matrix includes a plurality of numerical values, the maximum numerical value is selected from the matrix as the maximum image data, and the minimum numerical value is selected from the matrix as the minimum image data.
And secondly, acquiring the maximum storage value and the minimum storage value of the first integer storage range.
In the embodiment of the application, the first shaping storage range is determined according to the number of model layers and the parameter quantity of the state detection model. For example, the larger the number of model layers and the number of parameters, the smaller the first shaping memory range that can be set accordingly.
For example, the first shaping storage range is a storage range (-127, 128) corresponding to int8, and accordingly, the maximum storage value (e.g., 128) and the minimum storage value (e.g., 127) are selected from the first shaping storage range.
Thirdly, determining a target quantization coefficient according to the maximum image data, the minimum image data, the maximum storage value and the minimum storage value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the target quantization coefficients are located within the first shaping storage range.
In the embodiment of the present application, two equations are constructed according to the maximum image data and the minimum image data of the floating-point image data and the maximum numerical value and the minimum numerical value of the first integer storage range, and the two equations include a variable of a first quantization coefficient to be determined, so that the first quantization coefficient can be calculated based on the two equations.
Wherein the processing result of the maximum image data and the processing result of the minimum image data based on the determined first quantization coefficient are respectively located in the first integer storage range, and correspondingly, the processing result of the maximum image data based on the determined first quantization coefficient is close to or equal to the maximum storage value of the first integer storage range, and the processing result of the minimum image data based on the determined first quantization coefficient is close to or equal to the minimum storage value of the first integer storage range, in order to reduce the precision loss after the floating point type model parameters are converted into the integer type model parameters.
Further, in the state detection method provided by the embodiment of the present application, the determining a first quantization coefficient according to the maximum image data, the minimum image data, the maximum storage value, and the minimum storage value includes the following steps:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In the embodiment of the application, the first integer storage range is (-127, 128) corresponding to int8, and any value in the first integer storage range is represented by x, and correspondingly, -127 < x < 128; the target quantization factor is denoted by s, and correspondingly, -1.5 < s (x-q) < 2.0, wherein q denotes a bias factor for adjusting the output result of the model. Where ". x" denotes a multiplication calculation.
Accordingly, the formula is converted as follows:
Figure BDA0002422395450000181
based on this equation, the following equation is obtained:
Equation 1:
Figure BDA0002422395450000182
equation 2:
Figure BDA0002422395450000183
based on the above two equations, s and q can be calculated, and accordingly, s is the first quantized coefficient.
Further, in the state detection model training method provided by the embodiment of the present application, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to an integer model parameter, and each integer model parameter corresponds to a second quantization coefficient; in processing the reshaped image data by the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In the embodiment of the present application, the process is similar to the mode of the state detection model in the training process, and details are not repeated here.
Further, in the state detection method provided in the embodiment of the present application, in the process of processing the integer image data by the state detection model, the method further includes the following three steps:
firstly, obtaining a calculation formula applied by the state detection model to process the integer image data;
secondly, if a third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
and thirdly, determining an output result of the state detection model based on a calculation result of the expanded fourth operation formula.
In the embodiment of the present application, the third operation formula may be ln (1+ y), eyCosy, siny, etc., wherein y represents the output of a certain interlayer; the target expansion formulas corresponding to different third operation formulas are different, and the target expansion formula can be a taylor series expansion formula.
For example, the target dimension is 7, the third formula is ln (1+ y), and the expansion formula is as follows:
Figure BDA0002422395450000191
the state detection method provided by the embodiment of the application applies the trained state detection model comprising the integer model parameters and the corresponding quantitative parameters, and the model occupies less storage resources; in the process of processing the floating point type image data to be processed of the service provider corresponding to the target order in the service process through the state detection model, the floating point type image data to be processed input into the model is quantized, and then the state information of the service provider corresponding to the target order is determined based on the output result of the model.
Based on the same inventive concept, a state detection model training device corresponding to the state detection model training method provided in the first embodiment is also provided in the fourth embodiment of the present application, and since the principle of solving the problem of the device in the embodiment of the present application is similar to that of the state detection model training method provided in the first embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
As shown in fig. 7, a fourth embodiment of the present application further provides a state detection model training apparatus, including:
a first obtaining module 701, configured to obtain sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
a training module 702, configured to use each floating-point type image data as an input of a state detection model, use a state detection result corresponding to the floating-point type image data as an output of the state detection model, train model parameters of the state detection model, and obtain trained floating-point type model parameters;
A quantization processing module 703, configured to perform quantization processing on the floating-point model parameter based on a target quantization coefficient to obtain a state detection model including an integer model parameter and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum parameter value and the minimum parameter value of the floating-point type model parameter;
the third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the target integer storage range;
the first determining module is used for determining a target quantization coefficient according to the maximum numerical value and the minimum numerical value of the floating-point model parameter and the maximum numerical value and the minimum numerical value of the target integer storage range; wherein the processing results of the maximum parameter value and the minimum parameter value, respectively, based on the target quantized coefficients are located within the target integer storage range.
In a possible implementation, the first determining module determines a target quantization factor according to the maximum and minimum values of the floating-point model parameter and the maximum and minimum values of the target integer storage range, and includes:
Generating a first operation expression based on the minimum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the target integer storage range;
generating a second operation expression based on the maximum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the target integer storage range;
and determining the target quantization coefficient based on the first operational expression and the second operational expression.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the target shaping storage range according to the model layer number and the parameter number of the state detection model.
Based on the same inventive concept, a state detection model training device corresponding to the state detection model training method provided in the second embodiment is also provided in the fifth embodiment of the present application, and since the principle of solving the problem of the device in the embodiment of the present application is similar to the state detection model training method provided in the second embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
As shown in fig. 8, a fifth embodiment of the present application further provides a state detection model training apparatus, including:
a first obtaining module 801, configured to obtain sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
a quantization processing module 802, configured to perform quantization processing on the floating-point image data based on a first quantization coefficient to obtain integer image data, and perform quantization processing on a floating-point model parameter of the state detection model based on a second quantization coefficient to obtain an integer model parameter;
a training module 803, configured to use each of the integer image data and the first quantization coefficient as an input of the state detection model, use a state detection result corresponding to the integer image data as an output of the state detection model, and train model parameters of the state detection model based on the integer model parameters and the second quantization coefficient, so as to obtain a trained state detection model including target integer model parameters and target second quantization parameters.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum image data and the minimum image data of the floating-point image data;
the third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the first integer storage range;
a first determining module for determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In a possible implementation, the first determining module determines a first quantized coefficient according to the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value, including:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
Determining the first quantized coefficient based on the first and second arithmetic expressions.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to a floating point type model parameter, and the floating point type model parameter corresponds to an integer type model parameter and a second quantization coefficient; the training module 803 further includes, in the process of training the model parameters of the state detection model:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation, the training module 803, in training the model parameters of the state detection model, includes:
obtaining a calculation formula applied to training model parameters of the state detection model;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
training the model parameters of the state detection model based on the calculation result of the expanded fourth operation expression.
Based on the same inventive concept, a state detection device corresponding to the state detection method provided in the third embodiment is also provided in the sixth embodiment of the present application, and since the principle of solving the problem of the device in the embodiment of the present application is similar to that of the state detection method provided in the third embodiment of the present application, reference may be made to the implementation of the device in the method, and repeated details are omitted.
As shown in fig. 9, a sixth embodiment of the present application further provides a state detection apparatus applied to a state detection model, where the state detection model is obtained by training based on the state detection model training apparatus according to the fourth embodiment, or is obtained by training based on the state detection model training apparatus according to the fifth embodiment, the apparatus includes:
A first obtaining module 901, configured to obtain floating point type image data to be processed of a service provider corresponding to a target order;
a quantization processing module 902, configured to perform quantization processing on the floating-point image data to be processed according to a first quantization coefficient to obtain integer image data to be processed;
a calculating module 903, configured to input the to-be-processed integer image data into the state detection model trained in advance, so as to obtain an output result of the state detection model;
a determining module 904, configured to determine, based on an output result of the state detection model, state information of a service provider corresponding to the target order.
In a possible embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the maximum image data and the minimum image data of the floating point type image data to be processed;
the third acquisition module is used for acquiring the maximum storage value and the minimum storage value of the first integer storage range;
a first determining module for determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
In a possible implementation, the first determining module determines a first quantized coefficient according to the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value, including:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
In a possible embodiment, the apparatus further comprises:
and the second determining module is used for determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
In one possible embodiment, the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to an integer model parameter, and each integer model parameter corresponds to a second quantization coefficient; the calculation module 903 further includes, in the process of processing the integer image data through the state detection model:
For each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
In a possible implementation, the calculation module 903, in processing the reshaped image data by the state detection model, includes:
obtaining a calculation formula applied by the state detection model to process the integer image data;
If the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
and determining an output result of the state detection model based on a calculation result of the expanded fourth operation formula.
As shown in fig. 10, a seventh embodiment of the present application provides an electronic device 1000, including: a processor 1001, a memory 1002 and a bus, wherein the memory 1002 stores machine-readable instructions executable by the processor 1001, when the electronic device is operated, the processor 1001 and the memory 1002 communicate with each other through the bus, and the processor 1001 executes the machine-readable instructions to execute the steps of the state detection model training method provided by the first embodiment.
Specifically, the memory 1002 and the processor 1001 may be general-purpose memories and processors, which are not specifically limited herein, and when the processor 1001 runs a computer program stored in the memory 1002, the state detection model training method corresponding to the first server may be executed.
Corresponding to the above state detection model training method, an eighth embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the state detection model training method provided in the above first embodiment.
As shown in fig. 11, a ninth embodiment of the present application provides an electronic device 1100, including: a processor 1101, a memory 1102 and a bus, wherein the memory 1102 stores machine-readable instructions executable by the processor 1101, when the electronic device runs, the processor 1101 communicates with the memory 1102 through the bus, and the processor 1101 executes the machine-readable instructions to execute the steps of the state detection model training method provided by the second embodiment.
Specifically, the memory 1102 and the processor 1101 can be general memories and processors, which are not limited to the specific embodiments, and when the processor 1101 runs a computer program stored in the memory 1102, the state detection model training method provided by the second embodiment can be executed.
Corresponding to the above state detection model training method, a tenth embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the state detection model training method provided in the second embodiment.
As shown in fig. 12, an electronic device 1200 provided in an eleventh embodiment of the present application includes: a processor 1201, a memory 1202 and a bus, wherein the memory 1202 stores machine-readable instructions executable by the processor 1201, when the electronic device is operated, the processor 1201 and the memory 1202 communicate through the bus, and the processor 1201 executes the machine-readable instructions to execute the steps of the state detection method provided by the third embodiment.
Specifically, the memory 1202 and the processor 1201 can be general-purpose memories and processors, which are not limited to specific ones, and the state detection method provided by the second embodiment can be executed when the processor 1201 runs a computer program stored in the memory 1202.
Corresponding to the above state detection method, a twelfth embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the state detection method provided by the above third embodiment.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and there may be other divisions in actual implementation, and for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or modules through some communication interfaces, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (25)

1. A method for training a state detection model, the method comprising:
acquiring sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
taking each floating point type image data as the input of a state detection model, taking a state detection result corresponding to the floating point type image data as the output of the state detection model, and training model parameters of the state detection model to obtain trained floating point type model parameters;
quantizing the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
2. The method of claim 1, wherein determining the target quantization coefficients corresponding to the floating-point model parameters comprises:
acquiring a maximum parameter value and a minimum parameter value of the floating-point model parameter;
acquiring a maximum storage value and a minimum storage value of a target integer storage range;
determining a target quantization coefficient according to the maximum numerical value and the minimum numerical value of the floating point type model parameter and the maximum numerical value and the minimum numerical value of the target integer type storage range; wherein the processing results of the maximum parameter value and the minimum parameter value, respectively, based on the target quantized coefficients are located within the target integer storage range.
3. The state detection model training method of claim 2, wherein the determining a target quantization factor according to the maximum and minimum values of the floating-point model parameter and the maximum and minimum values of the target integer storage range comprises:
generating a first operation expression based on the minimum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the minimum storage value of the target integer storage range;
Generating a second operation expression based on the maximum parameter value of the floating-point model parameter, the target quantization coefficient to be determined, the bias coefficient to be determined and the maximum storage value of the target integer storage range;
and determining the target quantization coefficient based on the first operational expression and the second operational expression.
4. The state detection model training method of claim 2, further comprising:
and determining the target integer storage range according to the model layer number and the parameter number of the state detection model.
5. A method for training a state detection model, the method comprising:
acquiring sample data of a service provider corresponding to a plurality of completed orders in a service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
quantizing the floating point type image data based on the first quantization coefficient to obtain integer type image data, and quantizing the floating point type model parameter of the state detection model based on the second quantization coefficient to obtain integer type model parameter;
and taking each of the integer image data and the first quantization coefficient as the input of the state detection model, taking a state detection result corresponding to the integer image data as the output of the state detection model, and training the model parameters of the state detection model based on the integer model parameters and the second quantization coefficient to obtain the trained state detection model comprising the target integer model parameters and the target second quantization parameter.
6. The state detection model training method according to claim 5, wherein determining the first quantized coefficients corresponding to the floating-point image data comprises:
acquiring maximum image data and minimum image data of the floating-point image data;
acquiring a maximum storage value and a minimum storage value of a first integer storage range;
determining a first quantization coefficient from the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
7. The state detection model training method of claim 6, wherein the determining a first quantization coefficient based on the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value comprises:
generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
Determining the first quantized coefficient based on the first and second arithmetic expressions.
8. The state detection model training method of claim 6, further comprising:
and determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
9. The state detection model training method according to claim 6, wherein the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to a floating point type model parameter, and the floating point type model parameter corresponds to an integer type model parameter and a second quantization coefficient; in training the model parameters of the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
10. The state detection model training method according to claim 5, wherein in training the model parameters of the state detection model, the method further comprises:
obtaining a calculation formula applied to training model parameters of the state detection model;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
training the model parameters of the state detection model based on the calculation result of the expanded fourth operation expression.
11. A state detection method applied to a state detection model trained based on the state detection model training method of any one of claims 1 to 4, or trained based on the state detection model training method of any one of claims 5 to 10, the method comprising:
acquiring floating point type image data to be processed of a service provider corresponding to a target order;
quantizing the floating point type image data to be processed according to the first quantization coefficient to obtain integer type image data to be processed;
Inputting the to-be-processed integer image data into the pre-trained state detection model to obtain an output result of the state detection model;
and determining the state information of the service provider corresponding to the target order based on the output result of the state detection model.
12. The method according to claim 11, wherein determining the first quantized coefficient corresponding to the floating-point image data to be processed comprises:
acquiring maximum image data and minimum image data of the floating point type image data to be processed;
acquiring a maximum storage value and a minimum storage value of a first integer storage range;
determining a first quantization coefficient from the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value; wherein the processing results of the maximum image data and the minimum image data, respectively, based on the first quantized coefficients are located within the first shaping storage range.
13. The state detection method according to claim 12, wherein the determining a first quantized coefficient from the maximum image data, the minimum image data, the maximum stored value, and the minimum stored value comprises:
Generating a first operation expression based on the minimum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the minimum storage value of the first integer storage range;
generating a second operation expression based on the maximum image data, a first quantization coefficient to be determined, a bias coefficient to be determined and the maximum storage value of the first integer storage range;
determining the first quantized coefficient based on the first and second arithmetic expressions.
14. The status detection method according to claim 12, characterized in that the method further comprises:
and determining the first shaping storage range according to the model layer number and the parameter quantity of the state detection model.
15. The state detection method according to claim 12, wherein the state detection model includes an input layer, a plurality of intermediate layers, and an output layer; each intermediate layer corresponds to an integer model parameter, and each integer model parameter corresponds to a second quantization coefficient; in processing the reshaped image data by the state detection model, the method further comprises:
for each intermediate layer, acquiring input data of the intermediate layer, if the input data is located in a second integer storage range, determining a third quantization coefficient corresponding to the input data, and performing quantization processing on the input data based on the third quantization coefficient to obtain quantized input data and a fourth quantization coefficient; determining an output result of the intermediate layer based on the quantized input data, the fourth quantization coefficient, the integer model parameter corresponding to the intermediate layer, and the second quantization coefficient corresponding to the integer model parameter; wherein the input data comprises the integer image data and the first quantized coefficient, or comprises data determined based on input data of a previous layer of the middle layer, an integer model parameter corresponding to the previous layer, and a second quantized coefficient corresponding to the integer model parameter; the second shaping storage range is larger than the first shaping storage range.
16. The state detection method according to claim 11, wherein in processing the reshaped image data by the state detection model, the method further comprises:
obtaining a calculation formula applied by the state detection model to process the integer image data;
if the third operation formula exists in the operation formulas, the third operation formula is expanded based on a target expansion formula to obtain an expanded fourth operation formula;
and determining an output result of the state detection model based on a calculation result of the expanded fourth operation formula.
17. A state detection model training apparatus, characterized in that the apparatus comprises:
the first acquisition module is used for acquiring sample data of a service provider corresponding to a plurality of completed orders in the service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
the training module is used for taking each floating point type image data as the input of a state detection model, taking a state detection result corresponding to the floating point type image data as the output of the state detection model, and training model parameters of the state detection model to obtain well-trained floating point type model parameters;
The quantization processing module is used for carrying out quantization processing on the floating point type model parameters based on a target quantization coefficient to obtain a state detection model comprising integer type model parameters and the target quantization coefficient; and the storage space corresponding to the integer model parameters is smaller than the storage space corresponding to the floating point model parameters.
18. A state detection model training apparatus, characterized in that the apparatus comprises:
the first acquisition module is used for acquiring sample data of a service provider corresponding to a plurality of completed orders in the service process; each sample data comprises floating point type image data and a state detection result corresponding to the floating point type image data;
the quantization processing module is used for performing quantization processing on the floating point type image data based on a first quantization coefficient to obtain integer type image data and performing quantization processing on a floating point type model parameter of the state detection model based on a second quantization coefficient to obtain an integer type model parameter;
and the training module is used for taking each integer image data and the first quantization coefficient as the input of the state detection model, taking a state detection result corresponding to the integer image data as the output of the state detection model, training the model parameters of the state detection model based on the integer model parameters and the second quantization coefficient, and obtaining the trained state detection model comprising the target integer model parameters and the target second quantization parameter.
19. A state detection apparatus applied to a state detection model trained based on the state detection model training apparatus of claim 17 or the state detection model training apparatus of claim 18, the apparatus comprising:
the first acquisition module is used for acquiring floating point type image data to be processed of a service provider corresponding to the target order;
the quantization processing module is used for performing quantization processing on the floating point type image data to be processed according to a first quantization coefficient to obtain integer type image data to be processed;
the computing module is used for inputting the to-be-processed integer image data into the pre-trained state detection model to obtain an output result of the state detection model;
and the determining module is used for determining the state information of the service provider corresponding to the target order based on the output result of the state detection model.
20. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the state detection model training method according to any one of claims 1 to 4.
21. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the state detection model training method according to any one of claims 1 to 4.
22. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the state detection model training method according to any one of claims 5 to 10.
23. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the state detection model training method according to any one of claims 5 to 10.
24. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the state detection method according to any one of claims 11 to 16.
25. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, performs the steps of the state detection method according to any one of claims 11 to 16.
CN202010209693.0A 2020-03-23 2020-03-23 State detection model training method and device and state detection method and device Pending CN111860095A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010209693.0A CN111860095A (en) 2020-03-23 2020-03-23 State detection model training method and device and state detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010209693.0A CN111860095A (en) 2020-03-23 2020-03-23 State detection model training method and device and state detection method and device

Publications (1)

Publication Number Publication Date
CN111860095A true CN111860095A (en) 2020-10-30

Family

ID=72985554

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010209693.0A Pending CN111860095A (en) 2020-03-23 2020-03-23 State detection model training method and device and state detection method and device

Country Status (1)

Country Link
CN (1) CN111860095A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113762403A (en) * 2021-09-14 2021-12-07 杭州海康威视数字技术股份有限公司 Image processing model quantization method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113762403A (en) * 2021-09-14 2021-12-07 杭州海康威视数字技术股份有限公司 Image processing model quantization method and device, electronic equipment and storage medium
CN113762403B (en) * 2021-09-14 2023-09-05 杭州海康威视数字技术股份有限公司 Image processing model quantization method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US20210004663A1 (en) Neural network device and method of quantizing parameters of neural network
US11216721B2 (en) Method for calculating a neuron layer of a multi-layer perceptron model with simplified activation function
CN110910180B (en) Information pushing method and device, electronic equipment and storage medium
CN108628807A (en) Processing method, device, equipment and the computer readable storage medium of floating-point matrix number
CN111783982B (en) Method, device, equipment and medium for acquiring attack sample
US20210089948A1 (en) Data processing method and data processing system
US20210117804A1 (en) Technique for configuring and operating a neural network
CN107315729A (en) For the data processing method of chart, medium, device and computing device
WO2021056127A1 (en) Systems and methods for analyzing sentiment
CN115082920A (en) Deep learning model training method, image processing method and device
CN111275358A (en) Dispatch matching method, device, equipment and storage medium
CN111859172B (en) Information pushing method, device, electronic equipment and computer readable storage medium
CN117036422A (en) Method, device, equipment and storage medium for tracking lane lines
CN112818462A (en) Method and device for generating wheel parameter model, storage medium and computer equipment
CN111860095A (en) State detection model training method and device and state detection method and device
CN111476389A (en) Method and device for pre-estimating order receiving waiting time
CN111260384B (en) Service order processing method, device, electronic equipment and storage medium
CN112561050B (en) Neural network model training method and device
CN115374944B (en) Model reasoning method and device, electronic equipment and storage medium
CN115019150B (en) Target detection fixed point model establishing method and device and readable storage medium
CN111275062A (en) Model training method, device, server and computer readable storage medium
CN111833080A (en) Information pushing method and device, electronic equipment and computer-readable storage medium
CN116954551A (en) Data processing method, device, equipment and storage medium
CN111950238B (en) Automatic driving fault scoring table generation method and device and electronic equipment
CN114595627A (en) Model quantization method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination