Model encapsulation method and apparatus, model decapsulation method and apparatus, device, and storage medium

WO2026032204A1PCT designated stage Publication Date: 2026-02-12HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/112431
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-08-05
Filing Date
2025-08-04
Publication Date
2026-02-12

AI Technical Summary

Technical Problem

Existing deep learning neural network models lack efficient, secure, and widely applicable encapsulation and transmission methods during deployment and transmission, resulting in resource waste and insufficient flexibility.

Method used

By encapsulating model files, encapsulated model files and model description files are generated. Multiple data segments of the same model are marked with the same identifier, and model encapsulated representation files are generated for transmission, supporting flexible transmission of complete or partial models.

Benefits of technology

It improves the flexibility and efficiency of model data transmission, adapts to the deployment needs of different platforms, reduces the amount of data transmitted, and enhances security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025112431_12022026_PF_FP_ABST
    Figure CN2025112431_12022026_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a model encapsulation method and apparatus, a model decapsulation method and apparatus, a device, and a storage medium. In an example of the present application, the model encapsulation method comprises: acquiring a file to be encapsulated, the file to be encapsulated comprising a model file and a model description file; performing data encapsulation on the model file to obtain an encapsulated model file; and generating a model encapsulation representation file on the basis of the encapsulated model file and the model description file.
Need to check novelty before this filing date? Find Prior Art

Description

Model packaging method, model unpackaging method, device, equipment and storage medium TECHNICAL FIELD

[0001] The present application relates to the field of deep learning neural networks, in particular to a model packaging method, a model unpackaging method, a device, equipment and a storage medium. BACKGROUND

[0002] Deep learning neural network training requires a large amount of computing resources and time cost, and uses a large amount of training data to obtain a model meeting the task requirements. The model can be packaged for transmission.

[0003] However, with the continuous development of deep learning, on the one hand, the number of models and the types of tasks are increasing, and on the other hand, the specifications of deployable platforms are different, and there is currently a lack of an efficient, safe and widely applicable model packaging and transmission method. SUMMARY

[0004] Therefore, the present application provides a model packaging method, a model unpackaging method, a device, equipment and a storage medium.

[0005] Specifically, the present application is realized by the following technical solutions:

[0006] According to a first aspect of the embodiments of the present application, a model packaging method is provided, comprising:

[0007] Obtaining a file to be packaged; wherein the file to be packaged includes a model file and a model description file; wherein a model file contains data of a complete model, or data of a part of the structure of the model;

[0008] Data packaging is performed on the model file to obtain a packaged model file; wherein one packaged model file contains one or more model data segments, and one model data segment is used to store complete data of one model or part of the data of the model; multiple model data segments used to store data of the same model are provided with the same identifier;

[0009] Generating a model packaging representation file according to the packaged model file and the model description file; wherein the model packaging representation file is used for transmission to a receiving end device.

[0010] According to a second aspect of the embodiments of the present application, a model unpackaging method is provided, comprising:

[0011] Obtaining a model packaging representation file; wherein the model packaging representation file is packaged by the method provided in the first aspect;

[0012] unpack the model packaging representation file to obtain an unpacked file; wherein the unpacked file comprises a model file and a model description file;

[0013] determine a model for task processing according to the unpacked file; wherein the model is used to obtain inference output according to model input.

[0014] According to a third aspect of the embodiment of the present application, a model packaging apparatus is provided, comprising:

[0015] an obtaining unit, configured to obtain a file to be packaged; wherein the file to be packaged comprises a model file and a model description file; wherein one model file contains data of a complete model, or data of a partial structure of the model;

[0016] a packaging unit, configured to perform data packaging on the model file to obtain a packaged model file; wherein one packaged model file contains one or more model data segments, one model data segment is used to store complete data of one model or partial data of the model; and multiple model data segments used to store data of the same model are provided with the same identifier;

[0017] a generating unit, configured to generate a model packaging representation file according to the packaged model file and the model description file; wherein the model packaging representation file is used to be transmitted to a receiving end device.

[0018] According to a fourth aspect of the embodiment of the present application, a model unpacking apparatus is provided, comprising:

[0019] an obtaining unit, configured to obtain a model packaging representation file; wherein the model packaging representation file is obtained by packaging using the method provided in the first aspect;

[0020] an unpacking unit, configured to unpack the model packaging representation file to obtain an unpacked file; wherein the unpacked file comprises a model file and a model description file;

[0021] a determining unit, configured to determine a model for task processing according to the unpacked file; wherein the model is used to obtain inference output according to model input.

[0022] According to a fifth aspect of the embodiment of the present application, an electronic device is provided, comprising a processor and a memory, wherein the memory stores machine executable instructions capable of being executed by the processor, and the processor is used to execute the machine executable instructions to implement the method provided in the first aspect or the second aspect.

[0023] According to a sixth aspect of the embodiments of the present application, a machine readable storage medium is provided, and the machine readable storage medium stores machine executable instructions. The machine executable instructions are executed by a processor to implement the method provided in the first aspect or the second aspect.

[0024] According to a seventh aspect of the embodiments of the present application, a model warehouse sending end device is provided, comprising a model pool, a device library, and a communication and control module; wherein:

[0025] The model pool is configured to store a standard model file.

[0026] The device library is configured to store model converters corresponding to different model deployment platforms, and the model converters are configured to convert the standard model into a model executable by the model deployment platform.

[0027] The communication and control module is configured to perform model packaging on the standard model to be transmitted by using the method provided in the first aspect, and transmit the obtained model packaging representation file to a receiving end device.

[0028] According to an eighth aspect of the embodiments of the present application, a model warehouse receiving end device is provided, comprising a model pool, a device library, and a communication and control module; wherein:

[0029] The communication and control module is configured to receive the model packaging representation file sent by the sending end device, and perform unpacking on the received model packaging representation file by using the method provided in the second aspect to obtain a standard model.

[0030] The device library is configured to store model converters corresponding to the model warehouse receiving end device, and the model converters are configured to convert the standard model into a model executable by the model warehouse receiving end device.

[0031] The model pool is configured to store the model executable by the model warehouse receiving end device.

[0032] The model packaging method provided in the embodiments of the present application comprises the following steps: obtaining a to-be-packaged file, the to-be-packaged file comprising a model file and a model description file; for the model file, data packaging is performed on the model file to obtain a packaged model file, and a model packaging representation file used for transmission to a receiving end device is generated according to the packaged model file and the model description file. One model file can contain data of a complete model, or can contain data of a partial structure of the model, and one packaged model file can contain one or more model data segments, one model data segment being used for storing complete data of one model or partial data of one model. Therefore, complete data of a model can be packaged into one packaged model file according to requirements, or data of a partial structure of a model can be packaged into one packaged model file, the flexibility of model data packaging is improved, and therefore, when model data transmission is performed, complete data of a model can be transmitted, or data of a partial structure of a model can be transmitted, the flexibility of model data transmission is improved. BRIEF DESCRIPTION OF DRAWINGS

[0033] FIG. 1 is a flow diagram of a model packaging method according to an example embodiment of the present application.

[0034] FIG. 2 is a flow diagram of a model unpackaging method according to an example embodiment of the present application.

[0035] FIG. 3 is a structural diagram of a model packaging representation file according to an example embodiment of the present application.

[0036] FIG. 4 is a flow diagram of an overall model packaging and distribution according to an example embodiment of the present application.

[0037] FIG. 5 is a flow diagram of model unpackaging according to an example embodiment of the present application.

[0038] FIG. 6 is a transmission flow diagram of model partial update according to an example embodiment of the present application.

[0039] FIG. 7 is a structural diagram of a model packaging apparatus according to an example embodiment of the present application.

[0040] FIG. 8 is a structural diagram of a model unpackaging apparatus according to an example embodiment of the present application.

[0041] FIG. 9 is a hardware structural diagram of an electronic device according to an example embodiment of the present application.

[0042] FIG. 10 is a structural diagram of a model warehouse sending end according to an example embodiment of the present application.

[0043] FIG. 11 is a structural diagram of a model warehouse receiving end according to an example embodiment of the present application.

[0044] FIG. 12 is a schematic diagram of model sending and receiving, according to an example embodiment of the present application. DETAILED DESCRIPTION

[0045] The example embodiments will be described in detail below with reference to the accompanying drawings. In the following description, unless otherwise indicated, like numbers in the different drawings represent similar or analogous elements. The following description of example embodiments is not representative of all possible embodiments consistent with the present application. Rather, it is merely an example of apparatus and methods consistent with some aspects of the present application as detailed in the appended claims.

[0046] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0047] In order for those skilled in the art to better understand the technical solutions provided by the embodiments of the present application, the following will first explain some terms involved in the embodiments of the present application.

[0048] 1. Deep learning model: refers to the model parameters and structure obtained by using deep neural network and training data, which is generally fixed and unchanged during inference.

[0049] 2. Model packaging: refers to the operation of more reasonable data arrangement, information supplement, etc. on the original inference model, so as to facilitate the transmission of the model.

[0050] In some examples, through model packaging, the parameters, structure, meta information and additional files required for running of the deep learning model can be packaged into an independent unit, so as to facilitate the storage, transmission and subsequent deployment of the model.

[0051] In order to make the above-mentioned purposes, features and advantages of the embodiments of the present application more apparent and easy to understand, the technical solutions in the embodiments of the present application will be further described in detail below with reference to the drawings.

[0052] It should be noted that the sequence numbers of the steps in the embodiments of the present application do not mean the order of execution, and the execution order of the processes should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0053] Please refer to FIG. 1, which is a flowchart of a model packaging method according to an embodiment of the present application. As shown in FIG. 1, the model packaging method can include the following steps:

[0054] In step S100, a file to be packaged is acquired; the file to be packaged includes a model file and a model description file; one model file contains data of a complete model or data of a partial structure of the model.

[0055] For example, the model file can include weight information and structure information of the model and other model data.

[0056] For example, one model file can contain weight information and structure information of a complete model, or one model file can contain weight information and structure information of a partial structure of a model.

[0057] For example, the model description file is used to describe attribute information and technical information of the model.

[0058] For example, the attribute information of the model refers to basic physical information related to the model, which can include but is not limited to information such as the name and size of the model. The technical information of the model refers to algorithm level information related to the model, which can include but is not limited to information such as the model version, the model data type, the running requirement information, and the input and output.

[0059] In step S110, the model file is data-packaged to obtain a packaged model file; one packaged model file contains one or more model data segments; one model data segment is used to store complete data of a model or partial data of a model; the multiple model data segments used to store data of the same model are provided with the same identifier.

[0060] In the embodiments of the present application, in order to improve the flexibility of model data transmission, when the model file is data-packaged, the model data in the same model file can be stored in one or more model data segments of the packaged model file.

[0061] For example, the model data in the model file can be stored in the same model data segment, or for the data of a complete model, the data can be segmented, and the segmented model data is stored in different model data segments.

[0062] For example, in order to enable the receiving end to accurately identify the model data of the same model, the multiple model data segments used to store data of the same model can be provided with the same identifier (which can also be referred to as a model identifier).

[0063] In step S120, a model packaging representation file is generated according to the packaged model file and the model description file; the model packaging representation file is used to be transmitted to a receiving end device.

[0064] In the embodiment of the present application, in the case that the packaging model file is obtained in the above manner, the packaging model file and the model description file can be organized into a single file (which can be referred to as a model packaging representation file), which can be used to send to the receiving end device.

[0065] For example, the model description file can be stored in the form of binary data at the tail of the packaging model file to obtain the model packaging representation file.

[0066] For example, in the case that the receiving end device receives the model packaging representation file, the model packaging representation file can be unpackaged to obtain the model file and the model description file, and relevant processing can be performed according to the obtained files. The specific implementation can be referred to the relevant description in the method flow shown in FIG. 2, and the embodiment of the present application will not be repeated here.

[0067] As can be seen in the method flow shown in FIG. 1, the file to be packaged is obtained, which includes the model file and the model description file. For the model file, data packaging can be performed to obtain the packaging model file, and the model packaging representation file used for transmission to the receiving end device can be generated according to the packaging model file and the model description file. One model file can contain data of a complete model, or can include data of part of the structure of the model, and one packaging model file can contain one or more model data segments, one model data segment being used to store complete data of one model or part of data of one model. Thus, complete data of a model can be packaged into one packaging model file according to requirements, or data of part of the structure of a model can be packaged into one packaging model file, which improves the flexibility of model data packaging, and thus, when model data transmission is performed, complete data of a model can be transmitted, or data of part of the structure of a model can be transmitted, which improves the flexibility of model data transmission.

[0068] In some embodiments, one packaging model file contains a file header and the one or more model data segments.

[0069] The file header contains a file header start code, a file header magic number, a file version, and the number of model data segments in the packaging model file.

[0070] The file header start code can be used to identify the file header, facilitating personnel positioning of the file header, and the value thereof is usually a default value.

[0071] The file header magic number can be used to perform integrity verification on the file header, and the value thereof is usually a default value. In the process of reading the file header, if the file header magic number is not the default value, it can be indicated that the integrity of the file header is damaged, indicating that the file can be damaged, and in this case, subsequent data reading can not be performed.

[0072] The file version is used to identify the version information of the file, and its value can be customized.

[0073] The number of model data segments in the encapsulation model file is used to identify the number of model data segments included in the encapsulation model file, and its value can be set according to requirements.

[0074] In some embodiments, a model data segment contains a model header and model data.

[0075] The model header contains a model header start code, a model header identifier, check information, and model data size; wherein the model header identifiers in the plurality of model data segments storing data of the same model are the same.

[0076] For example, a model data segment can contain a model header and model data.

[0077] For example, the model header can include a model header start code, which is used to identify the model header, facilitating positioning of the model header.

[0078] The model header can also include a model header identifier, check information, and model data size.

[0079] The model header identifier can be used to identify the correspondence between the model data segment and the model. When the model is too large or has a segmented transmission requirement, the model data of a model can be stored in a plurality of model data segments with the same model header identifier, and the value of the model header identifier can be customized.

[0080] The check information can be used to check the model data in the model data segment, and its value can be determined according to the specific data calculation result.

[0081] The model data size can be used to identify the size of the model data stored in the model data segment.

[0082] In one example, the data of a complete model is stored in the same model data segment; or, the data of a complete model is divided into at least two parts, and the model data of the at least two parts is stored in different model data segments of the same encapsulation model file.

[0083] For example, in order to improve the flexibility of model data encapsulation, for the data of a complete model, it can be encapsulated in the same model data segment, or the data of the complete model can be divided into at least two parts according to requirements.

[0084] For example, assuming that the length of the data of a complete model is 100, the data can be divided into two parts with lengths of 60 and 40, or lengths of 70 and 30, or lengths of 50 and 50, etc.; or the data can be divided into three parts with lengths of 50, 30, and 20, or lengths of 40, 10, and 50, or lengths of 30, 30, and 40, etc.

[0085] For example, in a case where the data of a complete model is divided into at least two parts, the model data of the at least two parts can be stored in different model data segments of the same packaged model file.

[0086] For example, the model header identifiers in the model data segments for storing the model data of the at least two parts are the same, and are used to identify that the model data stored in the model data segments belong to the same model.

[0087] In some embodiments, the data packaging of the model file to obtain the packaged model file can include:

[0088] In a case where it is determined that the model needs to be subjected to specified processing, the data of the model corresponding to the model file is subjected to specified processing; wherein the specified processing includes model compression processing and / or model encryption processing.

[0089] The data of the model subjected to the specified processing is subjected to data packaging to obtain a packaged model file.

[0090] For example, in the process of data packaging of the model file, the data of the model can also be subjected to specified processing according to actual needs.

[0091] For example, the specified processing can include, but is not limited to, model compression processing and / or model encryption processing.

[0092] For example, the model encryption processing can include encrypting the model data in the model data segment.

[0093] In an example, the processing methods of the specified processing performed on the data of the same model stored in different model data segments can be allowed to be different. In the process of packaging the model data, which part of the model data is to be stored in which model data segment can be determined, and thus the data of the model can be subjected to specified processing according to actual needs according to the model data segment before the final packaging processing, and the processing methods of the specified processing corresponding to the model data segments for storing the data of the same model are the same or different.

[0094] Exemplarily, in the case that data of the same model is to be stored in a plurality of different model data segments, different processing methods can be allowed to be specified for the data of the same model to be stored in different model data segments.

[0095] Exemplarily, the processing method of the model compression processing can include, but is not limited to, model compression manners such as pruning, quantization, and / or low-rank decomposition.

[0096] Exemplarily, the processing method of the model encryption processing can include, but is not limited to, symmetric encryption manners (such as AES (Advanced Encryption Standard), SM4 (a block cipher standard)), asymmetric encryption manners (such as RSA (a kind of asymmetric encryption algorithm), SM2 (a kind of elliptic curve public key cryptography algorithm standard)), or multi-level encryption manners, etc.

[0097] Exemplarily, the processing method of the specified processing performed on the data of the same model stored in different model data segments is the same; or the processing method of the specified processing performed on the data of the same model stored in different model data segments is not completely the same, for example, assuming that the data of the same model is stored in model data segments 1-3, the processing method of the specified processing performed on the data of the model in the model data segment 1 can be the same as the processing method of the specified processing performed on the data of the model in the model data segment 2, and different from the processing method of the specified processing performed on the data of the model in the model data segment 3; or the processing method of the specified processing performed on the data of the same model stored in different model data segments is completely different.

[0098] In some embodiments, the model description file can include a model attribute information file (or referred to as a model attribute information sub-file) and a model technology information file (or referred to as a model technology information sub-file);

[0099] The model attribute information file is used to store model attribute information, and the model attribute information includes a model name and model size information;

[0100] The model technology information file is used to store model technology information, and the model technology information includes model version information, model data type information, hardware support information required by the model, basic environment information for running the model, model input information, and model output information.

[0101] Exemplarily, the model size information can include, but is not limited to, the number of model parameters and / or the amount of model calculation, etc.

[0102] The unit of the number of model parameters can include, but is not limited to, MB or GB; and the unit of the amount of model calculation can include, but is not limited to, MFLOP (million floating point operations per second) or GFLOPS (gigaflops).

[0103] Exemplarily, the model data type can include, but is not limited to, FP32 (single-precision floating-point number), FP16 (half-precision floating-point number), BF16 (BFloat16), and the like.

[0104] Exemplarily, the hardware support information required by the model can include the requirement of one or more of a CPU (Center Process Unit), a GPU (Graphics Processing Unit), and a memory, and the like.

[0105] Exemplarily, the basic environment information for running the model can include, but is not limited to, a system, a program, and the like.

[0106] Exemplarily, the model input information can include the type of data input by the model, such as image (picture), text (text), video (video), or speech (speech), and the like.

[0107] The model output information can include the type of data output by the model, such as image (picture), text (text), video (video), speech (speech), coordinates (coordinates), probability (probability), and the like.

[0108] In one example, the model attribute information can further include one or more of the following information:

[0109] Model task information, model evaluation index information, model open source agreement, model production date, algorithm description document, and script description document.

[0110] Exemplarily, the model task information is used to describe the model task type, for example, a picture classification task, a picture segmentation task, a picture style transfer task, an OCR character recognition task, an object detection task, a translation task, or an image generation task, and the like.

[0111] Exemplarily, the model evaluation index information is used to describe the evaluation index of the model, such as precision, recall, F1 score, or accuracy, and the like.

[0112] In one example, the model technology information can further include one or more of the following information:

[0113] The configuration file of the model runtime, the model running framework, the model input resolution type, the model converter input configuration file, the pre-training large model structure information, and the model file information.

[0114] For example, the configuration file of the model runtime can be used to modify the settings of input and output path, threshold, output format setting, etc.

[0115] For example, the model input resolution type can include fixed resolution or dynamic resolution, etc.

[0116] In some embodiments, the file to be packaged further includes a model program file; the model program file includes a runtime library and / or a runtime script.

[0117] The above generating the model packaging representation file according to the packaging model file and the model description file can include:

[0118] Generating the model packaging representation file according to the packaging model file, the model description file and the model program file.

[0119] For example, the file to be packaged can further include a model program file. The model program file can include a runtime library and / or a runtime script.

[0120] For example, the runtime library can include a program file required by the running framework and the running environment.

[0121] For example, the runtime script can include a program script related to the model, which obtains a running result through input data, such as interface calling, model inference, etc.

[0122] For example, in the case of obtaining the packaging model file in the manner described in the above embodiments, the packaging model file, the model description file and the model program file can be organized into a model packaging representation file.

[0123] In one example, the model program file can include a runtime library, and the runtime library includes a model converter, which is used to convert a standard model into a model used by a specified platform.

[0124] For example, in order to reduce the number of models that the model sending end needs to store, the model converter can be sent to the model receiving end together with the standard model, and the model receiving end can use the model converter to convert the standard model to obtain a model deployed on a specified platform.

[0125] Please refer to FIG. 2, which is a flowchart of a model unpackaging method provided by an embodiment of the present application. As shown in FIG. 2, the model unpackaging method can include the following steps:

[0126] Step S200, obtaining a model packaging representation file.

[0127] Exemplarily, the model package representation file can be packaged in the manner described in the method flow shown in FIG. 1.

[0128] In step S210, the model package representation file is unpackaged to obtain an unpackaged file; wherein the unpackaged file includes a model file and a model description file.

[0129] In the embodiments of the present application, in the case where the model package representation file is obtained, for example, in the case where the receiving end device receives the model package representation file sent by the sending end device, the model package representation file can be unpackaged to obtain an unpackaged file.

[0130] Exemplarily, the unpackaged file can include a model file and a model description file.

[0131] Exemplarily, in the case where the file to be packaged in the flow shown in FIG. 1 further includes a model program file, the unpackaged file can further include a model program file.

[0132] For example, the manner of unpackaging the model package representation file can be determined according to the packaging manner when the model package representation file is generated, and the model package representation file is re-split into a model file and a model description file, or a model file, a model description file and a model program file according to the unpackaging manner.

[0133] In step S220, a model used for task processing is determined according to the unpackaged file; wherein the model is used to obtain inference output according to model input.

[0134] In the embodiments of the present application, in the case where the unpackaged file is obtained, the model used for task processing can be determined according to the unpackaged file.

[0135] Exemplarily, the task can include but is not limited to a picture processing task, a video processing task, a text processing task or a speech processing task, etc.

[0136] Taking the picture processing task as an example, the picture processing task can include but is not limited to a picture classification task, a picture segmentation task, a picture style transfer task, an OCR (Optical Character Recognition) character recognition task, an object detection task, a translation task or an image generation task, etc.

[0137] For example, the model used for task processing can be constructed according to the weight information and the structure information in the model file.

[0138] For example, in a case where data of a complete model is contained in multiple model files, i.e., a model file contains data of a partial structure of the model, multiple model files of the same model can be determined according to the model description file, e.g., multiple model files of the same model can be determined according to model_file_info (information for associating a model and a model file) in the model description file, and then a model for task processing can be constructed according to the multiple model files.

[0139] In a case where partial data of a model is included in a model encapsulation representation file, the model encapsulation representation file is unpacked in the above manner, and a corresponding model structure (a partial structure of the model) is obtained according to the unpacked file, in an example, a model for task processing can be obtained according to the model structure and local model data.

[0140] For example, the model structure can be used to replace a relevant part in a corresponding model to obtain a model for task processing.

[0141] For example, the model structure can be used to replace a relevant part in a corresponding model to obtain a model for task processing.

[0142] It can be seen that, through the above scheme, in a case where a model is partially updated, the updated partial model data can be encapsulated and sent to a receiving end, and the receiving end can update a local model according to the updated partial model data, so that model updating can be implemented without the need to transmit data of a complete model, and the amount of data transmitted in a case of model updating is reduced.

[0143] For example, in a case where data of a complete model is contained in multiple model files, i.e., a model file contains data of a partial structure of the model, multiple model files of the same model can be determined according to the model description file, e.g., multiple model files of the same model can be determined according to model_file_info (information for associating a model and a model file) in the model description file, and then a model for task processing can be constructed according to the multiple model files.

[0144] For example, in a case where data of a complete model is contained in multiple model files, i.e., a model file contains data of a partial structure of the model, multiple model files of the same model can be determined according to the model description file, e.g., multiple model files of the same model can be determined according to model_file_info (information for associating a model and a model file) in the model description file, and then a model for task processing can be constructed according to the multiple model files.

[0145] For example, in a case where data of a complete model is contained in multiple model files, i.e., a model file contains data of a partial structure of the model, multiple model files of the same model can be determined according to the model description file, e.g., multiple model files of the same model can be determined according to model_file_info (information for associating a model and a model file) in the model description file, and then a model for task processing can be constructed according to the multiple model files.

[0146] For example, in a case where data of a complete model is contained in multiple model files, i.e., a model file contains data of a partial structure of the model, multiple model files of the same model can be determined according to the model description file, e.g., multiple model files of the same model can be determined according to model_file_info (information for associating a model and a model file) in the model description file, and then a model for task processing can be constructed according to the multiple model files.

[0147] Exemplarily, in the case of determining that the model needs to be converted, a converter attached in the model program file can also be used, or a local tool (in the case of the model needing to be converted and no converter being attached in the model program file) is used to convert the standard model file into a structure and form that can be locally inferred, that is, to convert the standard model into a model executable by the local platform.

[0148] In the embodiments of the present application, in the case of obtaining the model for task processing, the model data can be loaded by using the runtime library, and the inference output is obtained by giving the relevant input.

[0149] In order to enable a person skilled in the art to better understand the technical solutions provided by the embodiments of the present application, the technical solutions provided by the embodiments of the present application will be described below in conjunction with specific examples.

[0150] In this embodiment, a standard model packaging and transmission process is defined, and the efficiency of model storage, management and distribution is improved by using the mode of the algorithm warehouse.

[0151] Exemplarily, the model file, the model description file and the model program file related to the model deployment correspond to three modules respectively, as shown in FIG. 3, and different packaging processes are taken for the three modules respectively.

[0152] Exemplarily, the model file contains the weight information and structure information of the model, and uses a subsequent model packaging representation definition method to convert the original data into packaged data.

[0153] The model description file mainly contains model attribute information and model technical information.

[0154] The model program file mainly includes two parts: the first part is a runtime library, including a program file required by a running framework and a running environment; and the second part is a running script, including a program script related to the model, such as interface calling, model inference, etc., which obtains a running result by inputting data.

[0155] Exemplarily, to increase transmission efficiency and improve security, a model compression and data encryption process can be optionally performed.

[0156] The defined packaging method can be used to organize files of different sources together according to requirements to form a packaging representation file (i.e., the above-mentioned model packaging representation file) for subsequent transmission.

[0157] Exemplarily, a flowchart of the overall model packaging and distribution is shown in FIG. 4.

[0158] Exemplarily, contrary to the model packaging process, the receiving end divides the model packaging representation file into a model file, a model description file and a model program file when obtaining the model packaging representation file, and performs decryption and decompression operations on the model that needs to be decrypted and decompressed. The overall process can be as shown in FIG. 5.

[0159] In addition, in order to meet the deployment requirements of different platforms, a model converter can be used to convert the original unified model representation into an end-side model representation that is specific to the target platform, that is, to convert the standard model into a model executable by the target platform, so as to increase the use scenarios of the same model and reduce the storage requirements of the server side.

[0160] The following describes part of the implementation details of the model packaging / unpackaging in the embodiments of the present application.

[0161] I. Model packaging representation file directory structure

[0162] The model packaging representation file needs to follow the following structure file directory structure, which can be as shown in Table 1:

[0163] 1.1, Model (model directory): store the model data of the packaging representation.

[0164] 1.2, Program (program directory): store the runtime library, script file, etc.

[0165] 1.3, Meta-info (description information directory): store the attribute information and technical information of the model. Table 1, model and file directory structure

[0166] The model identifier is the unique identifier of the model. Different models can correspond to different model description files and different description information (including attribute information and technical information).

[0167] II. Model data structure definition

[0168] The packaging model data structure includes file header information (File Header), model header information (Model Header) and model data information (Model Data). Each packaging model file has a separate file header and can contain model data segments of multiple model files. The model header and the corresponding data information of multiple model data segments are arranged in sequence after the file header, which can be as shown in Table 2. Table 2, arrangement of header information and data information

[0169] Exemplarily, the data structure definition of the file header can be as shown in Table 3, and the data structure definition of the model header can be as shown in Table 4: Table 3, file header data structure

[0170] unsigned int, where unsigned int is an unsigned integer type ranging from zero to the maximum positive value. Table 4, Model Header Data Structure

[0171] III. Model Program File Definition

[0172] The model program file mainly includes two parts: a library (Library) and a running script (Scripts). The library mainly includes the running environment (environment) relied on by the algorithm, the algorithm library file (core) compiled according to the scene and model, and the converter (converter) for converting the unified model representation into the model representation used in different platforms. The running script includes related script files for model running and control.

[0173] For example, the file structure of the model program file can be as shown in Table 5. Table 5, Model Program File Structure

[0174] IV. Model Description File Definition

[0175] The model description file is used to describe the attribute information and technical information of the model. It mainly includes two sub-files: managementinfo.json (i.e., the above-mentioned model attribute file) and technicalinfo.json (i.e., the above-mentioned model technical file). The managementinfo.json mainly stores attribute information, and the file structure can be as shown in Table 6. The technicalinfo.json mainly stores technical information, and the file structure can be as shown in Table 7. Table 6, Model Attribute File

[0176] where String is a string data type, and Dict is a dictionary data type. Table 7, Technical Information File

[0177] where List is a list data structure. Table 8, Model Task Table 9, Model Input Description

[0178] where the input size limit is used to limit the file data size of the input, and the input size limit is used to limit the resolution of the input file.

[0179] The mean and variance of the model input data can be used for normalization of the model input data. Table 10, Converter Configuration Description

[0180] wherein resize_height is the target height of the image after adjustment, and resize_wide is the target width of the image after adjustment.

[0181] bn fusion refers to the process of merging multiple Batch Normalization (BN) layers into one larger BN layer.

[0182] yolo split refers to the process of splitting or adjusting the original YOLO (a real-time object detection algorithm) model or its network structure to better adapt to specific hardware platforms (such as edge devices or low-power devices).

[0183] For example, in the case of encapsulating the transmission model in the above process, the pre-trained large model information shown in Table 11 can also be included in the model description file. This part of information belongs to the model technical information file content, which is convenient for quickly checking technical details through text.

[0184] Five, model encapsulation process:

[0185] In this embodiment, the input of the encapsulation process includes:

[0186] 5.1, model file (model weight, structure, etc. File used for model representation and inference);

[0187] 5.2, model program file (library dependent on running, converter required for deployment, and related script files, etc.);

[0188] 5.3, model description file (description file storing model attribute information and model technical information).

[0189] The specific process of model encapsulation is as follows:

[0190] S1, obtain the file to be encapsulated;

[0191] S2, in the case where the model needs to be compressed, perform the model compression process;

[0192] For example, the model compression method can include general methods such as pruning, quantization, and low-rank decomposition.

[0193] For example, the Compression method field in the model header data structure can indicate the agreed model compression method.

[0194] S3, in the case where the model needs to be encrypted, perform the model encryption process;

[0195] For example, the model encryption mode can include symmetric encryption mode (such as AES, SM4), asymmetric encryption mode (such as RSA, SM2), multi-level encryption mode, etc.

[0196] For example, the Encryption field in the model header data structure can indicate the agreed model encryption mode.

[0197] S4, encapsulate the model file header and model header information, and arrange the data as required.

[0198] For example, for a complete model file model_origin output by an original training framework, it can be split into multiple model segments model_0, model_1, …, model_n as required. The division of the model segments can be based on different modules, different structures, or other situations requiring splitting.

[0199] Each model segment can be stored in the same or different files (file), which is suitable for various types of models.

[0200] The following will be described with examples.

[0201] Embodiment 1

[0202] The original complete model is segmented and stored in different model headers and model data. For example, an original model with a data length of 100 can be recorded with a complete data content using only one model header information and model data according to the specification. Alternatively, the original data content can be split into multiple model segments according to different requirements.

[0203] For example, as shown in Table 12, the complete data of 100 can be divided into two parts of model data with lengths of 40 and 60, or model data with lengths of 40, 10, and 50. Among them, the model data should be accompanied by the corresponding model header.

[0204] For example, for different model data segments, different compression and encryption methods can be used as required to make the model storage more flexible.

[0205] In addition, the segmented model header contains the check information of each model data. When problems caused by data transmission errors occur, they can be found in the current data segment in time, reducing the error correction cost.

[0206] Embodiment 2

[0207] Assuming that only part of the parameters in the model are updated, it is mainly used for upgrading the model. After the first transmission is completed, the sender and the receiver both have a complete model model_A. However, in subsequent training iterations, only some structures or weights in model_A have changed. This situation is common in visual tasks where the backbone is frozen and only the classification head is trained, or in language models where the Adapter learns downstream knowledge. After updating some modules such as the Adapter, the second transmission only needs to transmit the corresponding Adapter structure parameters, which are replaced and merged by the receiver. The implementation process diagram can be as shown in FIG. 6.

[0208] As shown in FIG. 6, the implementation process can include:

[0209] S1, organize data as required to generate a complete initial model model_A.

[0210] For example, for the parameter part that needs to be transmitted separately (such as the Adapter), it can be part of the model header and model data, and the Identifier information in the model header at this time is recorded.

[0211] S2, transmit model_A to the receiving end.

[0212] S3, after model training and updating, the Adapter parameters change, and the second transmission only transmits the updated Adapter as model data in the model file, keeping the Identifier information consistent.

[0213] For example, compression and encryption steps can be added according to requirements.

[0214] S4, transmit the model parameters (Adapter) that need to be updated to the receiving end.

[0215] S5, after the receiving end obtains the updated Adapter, it performs decompression and decryption as needed, replaces the model data corresponding to the original model file model_A corresponding Identifier, and obtains model_B consistent with the sending end (i.e., model_A with updated Adapter).

[0216] For example, a complete model includes a fixed part (Freeze) and a learned variable part (Adapter), i.e., model_A includes the fixed part (Freeze) and the learned variable part (Adapter_A). During the first transmission, the sender transmits the complete model_A to the receiver. The receiver receives the complete model_A. Subsequently, the sender's model_A is trained and updated to model_B (including the fixed part (Freeze) and the learned variable part (Adapter_B)), i.e., the learned variable part of model_A, Adapter_A, is updated to Adapter_B. During the second transmission, the sender only needs to transmit Adapter_B to the receiver, and the receiver replaces Adapter_A with the received Adapter_B to obtain model_B.

[0217] VI. Model De-encapsulation Process:

[0218] In this embodiment, the inputs to the decapsulation process include:

[0219] The model encapsulation representation file obtained from the sending end.

[0220] For example, the decapsulation process is as follows:

[0221] S1. Obtain the file to be depackaged (model encapsulation representation file), and re-divide (depackage) the model encapsulation representation file into model file, model description file and model program file;

[0222] S2. If the model needs to be decrypted, use the pre-agreed model decryption method to decrypt the model.

[0223] For example, the sending device and the receiving device can pre-agree on optional model encryption and decryption methods. The sending device can send the identification information (such as a serial number) of the relevant model encryption method in the encapsulation file to the receiving device according to the actual model encryption method used, so that the receiving device can determine the model decryption method based on the identification information.

[0224] The same principle applies to model compression and decompression.

[0225] S3. If the model needs to be decompressed, use a pre-agreed model decompression method to decompress the model.

[0226] S4. If the model needs to be converted, use the converter included in the model program file, or a local tool (if the model needs to be converted and the model program file does not include a converter) to convert the standard model file into a structure and form that can be used for local inference.

[0227] For example, in the case that the model file received this time contains part of the structure of the model, the model can be updated, replaced, or the like in combination with the existing parameters.

[0228] S5, loading the model data by using the runtime library, obtaining the inference output given the relevant input.

[0229] The method provided in the present application is described above. The device provided in the present application is described below:

[0230] Please refer to FIG. 7, which is a structural schematic diagram of a model packaging device provided in an embodiment of the present application. As shown in FIG. 7, the model packaging device 700 can include:

[0231] The obtaining unit 710 is configured to obtain a file to be packaged; wherein the file to be packaged includes a model file and a model description file; wherein one model file contains data of a complete model, or data of part of the structure of the model;

[0232] The packaging unit 720 is configured to perform data packaging on the model file to obtain a packaged model file; wherein one packaged model file contains one or more model data segments, and one model data segment is configured to store complete data of one model or part of the data of the model; and multiple model data segments configured to store the data of the same model are provided with the same identifier.

[0233] The generating unit 730 is configured to generate a model packaging representation file according to the packaged model file and the model description file; wherein the model packaging representation file is configured to be transmitted to a receiving end device.

[0234] In some embodiments, one packaged model file contains one file header and the one or more model data segments;

[0235] The file header contains a file header start code, a file header magic number, a file version, and the number of model data segments in the packaged model file.

[0236] and / or,

[0237] One model data segment contains a model header and model data.

[0238] The model header contains a model header start code, a model header identifier, verification information, and model data size; wherein the model header identifiers in multiple model data segments configured to store the data of the same model are the same.

[0239] In some embodiments, the data of a complete model is stored in the same model data segment.

[0240] or,

[0241] Data of a complete model is divided into at least two parts, and model data of the at least two parts is stored in different model data segments of a same packaging model file.

[0242] In some embodiments, the packaging unit 720 performs data packaging on the model file to obtain a packaging model file, including:

[0243] performing specified processing on data of the model corresponding to the model file; wherein the specified processing includes model compression processing and / or model encryption processing;

[0244] performing data packaging on data of the model after the specified processing to obtain a packaging model file.

[0245] In some embodiments, for different model data segments for storing data of a same model, the processing method of the specified processing of the data stored in each model data segment is the same or different.

[0246] In some embodiments, the model description file includes a model attribute information file and a model technical information file;

[0247] The model attribute information file is used to store model attribute information, and the model attribute information includes a model name and model size information.

[0248] The model technical information file is used to store model technical information, and the model technical information includes model version information, model data type information, hardware support information required by the model, basic environment information for running the model, model input information, and model output information.

[0249] The model input information includes the type of data input by the model.

[0250] In some embodiments, the model attribute information further includes one or more of the following information:

[0251] model task information, model evaluation index information, model open source agreement, model production date, algorithm description document, and script description document;

[0252] and / or,

[0253] The model technical information further includes one or more of the following information:

[0254] a configuration file of a model runtime, a model running framework, a model input resolution type, a model converter input configuration file, pre-training large model structure information, and model file information.

[0255] In some embodiments, the file to be packaged further includes a model program file; the model program file includes a runtime library and / or a running script;

[0256] The generating a model encapsulation representation file according to the encapsulation model file and the model description file comprises:

[0257] The generating a model encapsulation representation file according to the encapsulation model file, the model description file and the model program file.

[0258] In some embodiments, the model program file comprises a runtime library, and the runtime library comprises a model converter used for converting a standard model into a model used by a specified platform.

[0259] Please refer to FIG. 8, which is a structural schematic diagram of a model encapsulation device provided by an embodiment of the present application. As shown in FIG. 8, the model encapsulation device 800 can comprise:

[0260] The obtaining unit 810 is configured to obtain a model encapsulation representation file.

[0261] For example, the model encapsulation representation file is obtained by using the method described in the above method embodiments.

[0262] The encapsulation unit 820 is configured to encapsulate the model encapsulation representation file to obtain an unencapsulated file. The unencapsulated file comprises a model file and a model description file.

[0263] The determining unit 830 is configured to determine a model used for task processing according to the unencapsulated file. The model is used to obtain inference output according to model input.

[0264] An electronic device is provided by an embodiment of the present application, which comprises a processor and a memory. The memory stores machine executable instructions which can be executed by the processor. The processor is configured to execute the machine executable instructions to implement the model encapsulation method or the model unencapsulation method described above.

[0265] Please refer to FIG. 9, which is a hardware structural schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device 900 can comprise a processor 901 and a memory 902 storing machine executable instructions. The processor 901 and the memory 902 can communicate via a system bus 903. By reading and executing the machine executable instructions corresponding to the model encapsulation or model unencapsulation logic in the memory 902, the processor 901 can execute the model encapsulation method or the model unencapsulation method described above.

[0266] The memory 902 mentioned herein can be any electronic, magnetic, optical, or other physical storage device, and can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium can be a RAM (Random Access Memory), a volatile memory, a non-volatile memory, a flash memory, a storage drive (such as a hard drive), a solid-state drive, any type of storage disc (such as an optical disc, a DVD, and the like), or similar storage medium, or a combination thereof.

[0267] In some embodiments, a machine-readable storage medium, such as the memory 902 in FIG. 9, is also provided, and the machine-executable instructions stored in the machine-readable storage medium are executed by a processor to implement the model packaging method or the model unpackaging method described above. For example, the storage medium can be a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0268] The model warehouse sending end device provided in the embodiments of the present application comprises a model pool, a device library, and a communication and control module.

[0269] The model pool is configured to store standard model files.

[0270] The device library is configured to store model converters corresponding to different model deployment platforms, and the model converters are configured to convert the standard models into models executable by the model deployment platforms.

[0271] The communication and control module is configured to perform model packaging on the standard models to be transmitted by using the model packaging method described in the above embodiments, and transmit the obtained model packaging representation file to a receiving end device.

[0272] In the embodiments of the present application, in view of the problem of model management difficulty under multiple models and multiple reasoning platforms, a model warehouse management method is proposed, which, in combination with the above packaging transmission process, further improves the management efficiency and reduces the storage demand.

[0273] For example, the model pool of the model warehouse sending end device stores standard models instead of special models corresponding to specific platforms.

[0274] In addition, in order to enable the standard models to be deployed and run on various platforms, the model warehouse can further comprise a device library for storing model converters corresponding to different model deployment platforms.

[0275] For example, the model converters are configured to convert the standard models into models executable by the model deployment platforms.

[0276] Compared with the traditional storage mode, assuming that there are m models and n target devices, due to the optimization of each device platform and different operators, for a sending end with support of all models and platforms, a total of m*n different model files need to be stored.

[0277] However, in the case of using the unified packaging standard and the management mode of the model warehouse provided in the embodiments of the present application, for the sending end, only m standard model files need to be stored, and the standard model files are not for a specific device, but are converted into a device model file executable by the target device after being transmitted to the target device. Thus, the storage requirement of the sending end can be significantly reduced.

[0278] Exemplarily, the model warehouse sending end device can further include a communication and control module, which can perform model packaging on the standard model to be transmitted by using the model packaging method described in the above embodiments, and transmit the obtained model packaging representation file to the receiving end device.

[0279] Exemplarily, the communication and control module of the model warehouse sending end device can communicate with the receiving end device to determine the model acquisition requirement of the receiving end.

[0280] For example, the model warehouse sending end device can determine the model required by the receiving end according to the model acquisition request sent by the receiving end device in the case of receiving the model acquisition request, and transmit the standard model file corresponding to the determined model required by the receiving end to the receiving end device.

[0281] Exemplarily, the model warehouse sending end device can further communicate with the receiving end device through the communication and control module to determine whether the receiving end device has a corresponding model converter, and transmit the model converter and the standard model file to the receiving end device in the case of determining that the receiving end device does not have a corresponding model converter.

[0282] Exemplarily, the standard model files stored in the model pool of the model warehouse sending end device include model files corresponding to complete models, and can also include model files corresponding to partial structures of models.

[0283] For example, in the case of partial structure update of the model on the model warehouse sending end device side, the model warehouse sending end device can save the standard model file corresponding to the complete model before the update, and the standard model file corresponding to the partial structure of the updated model.

[0284] The model warehouse sending end device can record the model version information corresponding to each standard model file.

[0285] For example, the model version information of the standard model file corresponding to the complete model before updating (assuming the corresponding model A) can be v1.0, and the model version information of the standard model file corresponding to the partial structure of the updated model can be v1.1.

[0286] When the model repository sending end device receives the model update request sent by the receiving end device, the model repository sending end device can determine the standard model file to be transmitted according to the model version information carried in the model update request.

[0287] For example, it is assumed that the receiving end device sends a model update request, requests to update model A, and the model version information carried in the model update request is v1.0, that is, the receiving end device has a complete model of version v1.0 locally. In this case, the model repository sending end device can transmit the standard model file corresponding to the partial structure of the updated model of version v1.1 (the model version information of which is v1.1) to the receiving end device, and the receiving end device updates the local model according to the standard model file corresponding to the partial structure of the updated model to obtain the updated complete model.

[0288] It should be noted that in the embodiments of the present application, when the model repository sending end device receives the model download request of the receiving end device, the model repository sending end device can query and determine the standard model files of different versions of the model stored in the model pool. In the case that the version-updated standard model file is the standard model file corresponding to the partial structure of the model, the model repository sending end device can transmit the standard model file corresponding to the complete model of the old version and the standard model file corresponding to the partial structure of the model of the new version to the receiving end device, so that the receiving end device obtains the complete model of the latest version according to the standard model file corresponding to the complete model of the old version and the standard model file corresponding to the partial structure of the model of the new version; or the model repository sending end device can obtain the standard model file corresponding to the complete model of the latest version according to the standard model file corresponding to the complete model of the old version and the standard model file corresponding to the partial structure of the model of the new version, and transmit it to the receiving end device.

[0289] In some embodiments, the model repository sending end device can further include a designated processing module for performing designated processing on the data of the model.

[0290] For example, the designated processing can include model compression and / or model encryption.

[0291] For example, the specific implementation of the model repository sending end device performing designated processing on the data of the model in the model packaging process can refer to the related description in the above-mentioned model packaging method embodiments, and the embodiments of the present application will not be repeated here.

[0292] For example, the model warehouse sending end 1000 structure can be as shown in FIG. 10, mainly including (taking the model encryption as an example) :

[0293] The model pool 1001 stores different standard model (such as standard models A-C in FIG. 10) files, and the standard models A-C are unified representation models and do not depend on a certain specific device for execution.

[0294] The device library 1002 stores model converters of required deployment devices, and converts the unified representation model (i.e., the standard model) into a model executable on a target device, which can be transmitted together with the package.

[0295] For example, as shown in FIG. 10, the device X converter can be used to convert the unified representation model into a special model of the device X; the device Y converter can be used to convert the unified representation model into a special model of the device Y; and the device Z converter can be used to convert the unified representation model into a special model of the device Z.

[0296] The encryption and decryption module 1003 is mainly used for generating a key and encrypting data at the sending end.

[0297] The communication and control module 1004 is used to implement a model packaging process, establish communication with other sending ends and receiving ends, and transmit the model.

[0298] As can be seen, through the separation of the model and the converter, the model warehouse sending end does not need to store special model files corresponding to the deployment platform, but can store standard model files, thereby effectively reducing the number of model files stored by the model warehouse sending end, saving storage space, and reducing management difficulty.

[0299] For example, the communication and control module of the above model warehouse sending end device can include a software module, a hardware module, or a combination of the two. In embodiments, the implementation form of the communication and control module is not specifically limited as long as it can realize the functions described in the embodiments. For example, the communication and control module of the above model warehouse sending end device can be a software code, a processor executing the software code, a chip integrated with communication functions and software control functions, a computer, an electronic device, etc.

[0300] The embodiments of the present application also provide a model warehouse receiving end device, which includes a model pool, a device library, and a communication and control module.

[0301] The communication and control module is configured to receive a model packaging representation file sent by a sending end device, and use the model unpackaging method described in the above embodiments to unpack the received model packaging representation file to obtain a standard model.

[0302] The device library is configured for storing a model converter corresponding to the device, and the model converter is configured for converting the standard model into a model executable by the device.

[0303] The model pool is configured for storing the model executable by the device.

[0304] Exemplarily, the model repository receiving end device obtains the model encapsulation representation file and performs specific implementation of model decapsulation, which can be referred to the related description in the method embodiments and the related description in the model repository sending end device implementation. The embodiments of the present application do not repeat the description here.

[0305] In some embodiments, the model repository receiving end device can further include a designated processing module configured to perform inverse processing of the designated processing of the model.

[0306] Exemplarily, in the case where the designated processing includes model compression, the inverse processing of the designated processing includes model decompression; in the case where the designated processing includes model encryption, the inverse processing of the designated processing includes model decryption.

[0307] For example, the structure of the model repository receiving end 1100 can be as shown in FIG. 11, which mainly includes (taking model encryption as an example of the designated processing):

[0308] The model pool 1101 includes various model files executable by the receiving end, which are converted from the unified representation model;

[0309] Exemplarily, as shown in FIG. 11, the model A_X can be converted from the standard model A; the model B_X can be converted from the standard model B; and the model C_X can be converted from the standard model C.

[0310] The device library 1102 stores the model converter corresponding to the device, which is configured to convert the unified representation model into a model executable by the device;

[0311] The encryption and decryption module 1103 is mainly configured to decrypt the encrypted model data at the receiving end;

[0312] The communication and control module 1104 is configured to implement the model decapsulation process, establish communication with other sending ends and receiving ends, and receive the model.

[0313] Exemplarily, the communication and control module of the model repository receiving end device can include a software module, a hardware module, or a combination of the two. In embodiments, the implementation form of the communication and control module is not specifically limited as long as it can realize the functions described in the embodiments. For example, the communication and control module of the model repository receiving end device can be a software code, a processor executing the software code, a chip integrated with communication function and software control function, a computer, an electronic device, etc.

[0314] For example, the schematic diagram of the model warehouse sending end (referred to as the sending end) sending a model to the model warehouse receiving end (referred to as the receiving end) can be as shown in FIG. 12.

[0315] As shown in FIG. 12, assuming that the receiving end X requests the sending end 1 for a model A_X, the sending end 1 can encapsulate the standard model file corresponding to the standard model A corresponding to the model A_X in the manner described in the above embodiment, and send it to the receiving end X together with the model converter (such as the converter X) corresponding to the receiving end X.

[0316] The receiving end X can convert the standard model A into the locally executable model A_X by using the converter X.

[0317] Assuming that the receiving end Z has a local model converter (for converting a unified representation model into a locally executable model), in the case that the receiving end Z requests the sending end 2 for a model C_Z, the sending end 2 can encapsulate the standard model file corresponding to the standard model C corresponding to the model C_Z in the manner described in the above embodiment, and send it to the receiving end Z.

[0318] The receiving end Z can convert the standard model C into the locally executable model C_Z by using the local converter.

Claims

A model packaging method characterized by, The method comprises the following steps: obtaining a file to be packaged; wherein the file to be packaged comprises a model file and a model description file; wherein one model file contains data of a complete model or data of a partial structure of the model; performing data packaging on the model file to obtain a packaged model file; wherein one packaged model file contains one or more model data segments, one model data segment is used for storing complete data of one model or partial data of the model; and multiple model data segments used for storing data of the same model are provided with the same identifier; generating a model packaging representation file according to the packaged model file and the model description file; wherein the model packaging representation file is used for transmission to a receiving end device. The method of claim 1, wherein One packaged model file contains one file header and the one or more model data segments; The file header contains a file header start code, a file header magic number, a file version and the number of model data segments in the packaged model file; and / or, One model data segment contains a model header and model data; The model header contains a model header start code, a model header identifier, check information and model data size; wherein the model header identifiers in multiple model data segments used for storing data of the same model are the same. The method according to claim 2, characterized in that Complete data of one model is stored in the same model data segment; Or, Complete data of one model is divided into at least two parts, and the model data of the at least two parts is stored in different model data segments of the same packaged model file. The method of claim 1, wherein The method of performing data packaging on the model file to obtain a packaged model file comprises the following steps: performing specified processing on data of a model corresponding to the model file; wherein the specified processing comprises model compression processing and / or model encryption processing; performing data packaging on the data of the model after the specified processing to obtain a packaged model file. The method according to claim 4, characterized in that The processing methods of the specified processing of the data stored in different model data segments used for storing data of the same model are the same or different. The method of claim 1, wherein The model description file comprises a model attribute information file and a model technical information file; The model attribute information file is used for storing model attribute information, and the model attribute information comprises a model name and model size information; The model technical information file is used for storing model technical information, and the model technical information comprises model version information, model data type information, hardware support information required by the model, basic environment information for running the model, model input information and model output information; The model input information comprises the type of data input by the model. The method according to claim 6, characterized in that The model attribute information further comprises one or more of the following information: model task information, model evaluation index information, a model open source protocol, a model production date, an algorithm description document and a script description document; and / or, The model technical information further comprises one or more of the following information: a configuration file of a model runtime, a model running framework, a model input resolution type, a model converter input configuration file, pre-training large model structure information and model file information. The method of claim 1, wherein The file to be packaged further comprises a model program file; the model program file comprises a runtime library and / or a runtime script; The model packaging representation file is generated according to the packaging model file and the model description file. The model packaging representation file is generated according to the packaging model file, the model description file and the model program file. The method of claim 8, wherein The model program file comprises a runtime library, and the runtime library comprises a model converter configured to convert a standard model into a model used by a specified platform. A model unmarshalling method, characterized in that, The method comprises: The model packaging representation file is obtained by using the method in any one of claims 1-9; The model packaging representation file is unpackaged to obtain an unpackaged file; the unpackaged file comprises a model file and a model description file; A model used for task processing is determined according to the unpackaged file; the model is used to obtain inference output according to model input. A model packaging device characterized by comprising: The method comprises: A model file and a model description file are obtained; one model file contains data of a complete model or data of a partial structure of the model; The model file is data-packaged to obtain a packaging model file; one packaging model file contains one or more model data segments; one model data segment is used to store complete data of one model or partial data of the model; multiple model data segments used to store data of the same model are provided with the same identifier; A model packaging representation file is generated according to the packaging model file and the model description file; the model packaging representation file is used to be transmitted to a receiving end device. A model unmarshalling device, characterized in that The method comprises: A model packaging representation file is obtained; the model packaging representation file is obtained by using the method in any one of claims 1-9; The model packaging representation file is unpackaged to obtain an unpackaged file; the unpackaged file comprises a model file and a model description file; A model used for task processing is determined according to the unpackaged file; the model is used to obtain inference output according to model input. An electronic device, characterized by comprising: The method comprises a processor and a memory; the memory stores machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method in any one of claims 1-9 or the method in claim 10. A machine-readable storage medium, characterized by Machine-executable instructions are stored in the machine-readable storage medium; when the machine-executable instructions are executed by a processor, the method in any one of claims 1-9 or the method in claim 10 is implemented. A model warehouse sending terminal device is characterized by comprising: The method comprises: A model pool, a device library and a communication and control module; wherein: The model pool is used to store standard model files; The device library is used to store model converters corresponding to different model deployment platforms; the model converters are used to convert standard models into models executable by the model deployment platforms; The model pool is used to store standard model files; The device library is used to store model converters corresponding to different model deployment platforms; the model converters are used to convert standard models into models executable by the model deployment platforms; The communication and control module is configured to perform model packaging on a standard model to be transmitted by using the method in any one of claims 1-9, and transmit a model packaging representation file obtained to a receiving end device. A model warehouse receiving end device, characterized in that, The method comprises the following steps: The model pool, the device library, and the communication and control module; wherein: The communication and control module is configured to receive a model packaging representation file sent by a sending end device, and perform unpacking on the received model packaging representation file by using the method in claim 10 to obtain a standard model; The device library is configured to store a model converter corresponding to the model repository receiving end device, and the model converter is configured to convert the standard model into a model executable by the model repository receiving end device; The model pool is configured to store the model executable by the model repository receiving end device.

Citation Information

Patent Citations

  • Model data protection method and readable computer storage medium

    CN111259432A

  • Model packaging method and device, and electronic equipment

    CN111985055A

  • Process IP simulation model packaging and library management method and system, and storage medium

    CN112861456A

  • Merge tool for structured object models

    EP1804177A1