An on-device method for compressing a machine learning model by an electronic device, comprising: determining a pruning number for each of a plurality of channels included in a set hidden layer of the machine learning model, the machine learning model comprises a convolutional neural network that comprises a plurality of hidden layers including the set hidden layer, the set hidden layer comprises one or more hidden layers set in respective hidden layers; determining a pruning loss of each hidden layer in the set hidden layer based on the determined pruning number of the respective channels included in each hidden layer in the set hidden layer; determining a compression parameter of the set hidden layer in the model; compressing the model based on the determined compression parameter of the set hidden layer, wherein the compression parameter is related to a pruning of the model and comprises a pruning number of each hidden layer in the set hidden layer, and wherein the determining the compression parameter of the set hidden layer in the model is based on the pruning number of the respective channels included in each hidden layer in the set hidden layer and the pruning loss of each hidden layer in the set hidden layer of the model, the determining the compression parameter of the set hidden layer comprises: determining a relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer; and determining the pruning number of each hidden layer, by solving an optimization problem based on an overall compression target and the relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer, wherein the machine learning model corresponds to at least one of a scene text detection model which detects text visible in scenes or a keypoints detection model which detects multiple pre-set key positions of a person in a scene. determining a pruning number for each of a plurality of channels included in a set hidden layer of the machine learning model, the machine learning model comprises a convolutional neural network that comprises a plurality of hidden layers including the set hidden layer, the set hidden layer comprises one or more hidden layers set in respective hidden layers; determining a pruning loss of each hidden layer in the set hidden layer based on the determined pruning number of the respective channels included in each hidden layer in the set hidden layer; determining a compression parameter of the set hidden layer in the model; compressing the model based on the determined compression parameter of the set hidden layer, wherein the compression parameter is related to a pruning of the model and comprises a pruning number of each hidden layer in the set hidden layer, and wherein the determining the compression parameter of the set hidden layer in the model is based on the pruning number of the respective channels included in each hidden layer in the set hidden layer and the pruning loss of each hidden layer in the set hidden layer of the model, the determining the compression parameter of the set hidden layer comprises: determining a relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer; and determining the pruning number of each hidden layer, by solving an optimization problem based on an overall compression target and the relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer, determining a relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer; and determining the pruning number of each hidden layer, by solving an optimization problem based on an overall compression target and the relationship between the pruning number of the respective channels of each hidden layer in the set hidden layer and the corresponding pruning loss of each hidden layer in the set hidden layer, wherein the machine learning model corresponds to at least one of a scene text detection model which detects text visible in scenes or a keypoints detection model which detects multiple pre-set key positions of a person in a scene.