Flask framework-based lightweight deep learning model deployment method

The lightweight deep learning model deployment method of the Flask framework solves the problems of high hardware requirements and difficulty in cross-language calls in the existing technology, achieves rapid deployment and low-cost model deployment, supports single-channel and multi-channel modes, and enhances flexibility.

CN118567658APending Publication Date: 2024-08-30FREESENSE IMAGE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410712509.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing deep learning model deployment methods such as TensorRT are strict on computer hardware conditions, increase the cost of model deployment, and are difficult to support cross-language calls.

Method used

Using a lightweight deep learning model deployment method based on the Flask framework, rapid deployment of models is achieved by defining API interfaces and configuration files, and supports single-channel and multi-channel modes, reducing equipment hardware requirements.

Benefits of technology

It achieves rapid deployment and cross-language calling of models, reduces deployment costs, reduces requirements for equipment hardware, and improves flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567658A
    Figure CN118567658A
Patent Text Reader

Abstract

The invention discloses a lightweight deep learning model deployment method based on a flash framework, and the method comprises the following steps: S1, a preprocessing stage: defining related configuration information and an API interface at a flash server; s2, selecting a single channel or multiple channels according to different items; s3, the flash server starts model service and prints related channel information, the client transmits image information through an API interface to call a corresponding model deployment scheme and waits for the response of the flash server, the technology can rapidly achieve model deployment and support cross-language call, and meanwhile the requirement for equipment hardware is low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning model deployment, and mainly involves a model deployment solution based on a lightweight flask framework, which greatly reduces the algorithm's requirements for hardware devices. Background Art

[0002] Deep learning is now widely used in various fields of real life. Relying on the model deployment method, the model trained on the PC can be applied to different devices, such as mobile phones and other mobile devices.

[0003] Currently, common model deployment methods include TensorRT, etc. However, these deployment methods have strict requirements on computer hardware conditions, which increases the cost of model deployment to a certain extent.

[0004] As a lightweight deployment method, Flask framework technology can deploy the trained model by building an API service and act as a server, waiting for the client to pass information such as pictures and then call and access it. This technology can quickly deploy the model and support cross-language calls, while having low requirements for device hardware. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention provides a lightweight deep learning model deployment method based on the flask framework. The present invention uses the Flask framework technology as a lightweight deployment method, and can deploy the trained model and act as a server by building an API service, waiting for the client to pass information such as pictures, and then call and access it. This technology can quickly realize the deployment of the model and support cross-language calls, while having low requirements for device hardware.

[0006] To achieve the above object, the present invention provides the following technical solutions: A lightweight deep learning model deployment method based on the flask framework includes the following steps: Step S1: In the preprocessing stage, define relevant configuration information and API interface on the flask server; Step S2: Select single channel or multi-channel according to the application of different projects; Step S3: The flask server starts the model service and prints the relevant channel information. The client passes the image information through the API interface to call the corresponding model deployment solution and waits for the response of the flask server.

[0007] As a further solution of the present invention, in step S1, defining relevant configuration information includes defining the current model deployment configuration file, which includes an IP address, a port number, a model repository, pre-processing operations, and post-processing operations.

[0008] As a further solution of the present invention, in step S2, the single-channel mode represents preloading a single model deployment solution in the flask server; the multi-channel mode represents preloading multiple model deployment solutions in the flask server.

[0009] As a further solution of the present invention, in step S2, the single-channel mode is set as follows: the model deployment scheme involved in the single channel is configured in advance on the flask server, the model scheme is loaded, and the information of the current channel is printed; different results are returned according to the category of the model finally returned in the scheme for pre-processing operations and post-processing operations; the pre-processing operation performs certain pre-processing operations on the image transmitted by the client, and the post-processing operation performs further judgment operations on the results obtained by model inference.

[0010] As a further solution of the present invention, in step S2, the multi-channel mode is set as follows: pre-configure a multi-model deployment scheme on the flask server, load multiple model schemes, and print information of multiple channels; return different results for pre-processing and post-processing operations according to the category of the model finally returned in the scheme; the pre-processing operation performs certain pre-processing operations on the image transmitted by the client, and the post-processing operation performs further judgment operations on the results obtained by model inference.

[0011] The present invention has the following beneficial effects: The present invention adopts a lightweight deep learning model deployment method based on the flask framework, and adopts a lightweight deployment method based on the flask framework, which can complete the deployment of the model by pre-defining the required configuration of the model. Through different API interfaces, the client is supported to call multiple model solutions to complete different tasks. This deployment method reduces the deployment cost and reduces the rigid requirements for device hardware. This deployment method supports cross-language calls and increases flexibility.

[0012] The present invention proposes a lightweight deep learning model deployment method based on the flask framework, which defines multiple model deployment schemes by setting the form of an API interface, and supports both single-channel and multi-channel modes. The server pre-loads model configuration files such as model weight files, single target categories in images and other model configuration information through the defined IP address and port number. After the service is successfully started, the current single or multiple channel information will be printed. After the server is successfully started, the client only needs to select the API interface to be called and pass in information such as images to send a request to the server for calling. After the call is successful, it waits to receive the response sent by the server, which solves the problem of high cost of existing deployment schemes; the scheme completes deployment through the API interface and has low requirements for hardware equipment, reduces the cost of model deployment, and supports cross-language deployment calls.

[0013] In order to more clearly illustrate the structural features and effects of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 This is a configuration file sample mentioned in the embodiment of the present invention.

[0015] Figure 2 This is an overview diagram of the flask framework call mentioned in the embodiment of the present invention.

[0016] Figure 3 This is an overview diagram of model calls within the flask framework server mentioned in an embodiment of the present invention.

[0017] Figure 4 This is a single channel mode calling flow chart mentioned in an embodiment of the present invention.

[0018] Figure 5 This is a multi-channel mode calling flow chart mentioned in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The present invention will be further explained below in conjunction with the accompanying drawings and related knowledge, and described clearly and completely. Obviously, the described application is only a part of the embodiments of the present invention, rather than all the embodiments.

[0020] In view of the problem that the existing deployment scheme has strict requirements on the hardware conditions of the equipment and the high cost of model deployment, the purpose of the present invention is to effectively solve the problem by proposing a lightweight deployment scheme based on the flask framework. This scheme will take a variety of models as an example. First, the flask server pre-sets the API interface and pre-loads all the models that need to be called. For example, if the current project needs to call the detection model algorithm, the relevant detection model in the server is called through the set API service. If the current project needs to call the segmentation model algorithm, the relevant segmentation model is called. Secondly, the client transmits relevant pictures and other information according to specific needs. Finally, the client will receive the model inference results transmitted by the server. This method can realize the deployment of the model, while meeting most of the needs, reducing the cost of deployment.

[0021] Reference Figure 1-Figure 5 As shown, the present invention provides a lightweight deep learning model deployment method based on the flask framework, comprising the following steps: Step S1: In the preprocessing stage, define relevant configuration information and API interfaces on the flask server, including port number, preloaded model weight file, etc. Step S2: Select single channel or multi-channel according to the application of different projects, refer to Figure 3As shown in the figure, the solution supports both single-channel and multi-channel modes. The single-channel mode means that a single model deployment solution is preloaded in the server, which is suitable for some relatively simple projects. The multi-channel mode means that multiple model deployment solutions are preloaded in the server, which is suitable for more complex projects, such as multiple cameras shooting images at different angles and needing to execute different model solutions; Step S3: The flask server starts the model service and prints the relevant channel information. The client calls the corresponding model deployment solution by passing information such as images through the API interface and waits for the response from the server. The present invention defines multiple model deployment schemes by setting the form of an API interface, and supports both single-channel and multi-channel modes. The server pre-loads model configuration files such as model weight files, single target categories in images and other model configuration information through the defined IP address and port number. After the service is successfully started, the current single or multiple channel information will be printed. After the server is successfully started, the client only needs to select the API interface to be called and pass in information such as images to send a request to the server for calling. After the call is successful, it waits to receive the response sent by the server; the method proposed by the present invention can solve the limitations of most current deployment schemes and reduce costs, and is ultimately applied to actual projects.

[0022] In the present invention, reference is made to Figure 4 As shown, the settings for single channel mode are as follows: Pre-configure the model deployment scheme involved in a single channel on the server side, load the model scheme, and print the information of the current channel, such as API interface, model information, etc. If the client calls the wrong API interface, the relevant error will be displayed. In the model deployment scheme, the current scheme may be a single model, dual models, multiple models, etc. Different results will be returned according to the category of the model finally returned in the scheme. For example, the classification model will output classification category information, the detection model will output a single target category and point set information, and the segmentation model will output a single target category, point set and mask information. The pre-processing operation is mainly to perform certain pre-processing operations on the image transmitted by the client, such as image scaling, image cropping, etc. The post-processing operation is mainly to perform further judgment operations on the results obtained by model inference, such as judging whether there is collision or contact between point sets based on the point set information obtained by the segmentation model.

[0023] The advantage of the single-channel mode is that when processing a single simple project, you only need to pre-load the model weight files involved in the project into the memory and wait for the call, which can quickly achieve the purpose of deployment. Its disadvantage is that if you process multiple projects or a single complex project (which requires different model solutions to assist in implementation), you need to restart the server to configure related files or set up multiple single-channel mode model deployment solutions.

[0024] In the present invention, reference is made to Figure 5 As shown, the settings for multi-channel mode are as follows: The configuration of multi-channel mode is similar to that of single-channel mode. Pre-configure multi-model deployment schemes on the server, load multiple model schemes, and print information of multiple channels, such as multiple API interfaces, multiple model information, etc. If the client calls the wrong API interface, the relevant error will be displayed. In the model deployment scheme, the current scheme may be single model, dual model, multi-model, etc. Different results will be returned according to the category of the model finally returned in the scheme. For example, the classification model will output classification category information, the detection model will output a single target category and point set information, and the segmentation model will output a single target category, point set and mask information. The pre-processing operation mainly performs certain pre-processing operations on the image transmitted by the client, such as image scaling, image cropping, etc. The post-processing operation mainly performs further judgment operations on the results obtained by model inference, such as judging whether there is collision or contact between point sets based on the point set information obtained by the segmentation model.

[0025] The advantage of multi-channel mode is that multiple deployment plans can be pre-loaded, which can be used when multiple deployment plans or multiple projects are required for the same project. The disadvantage is that multiple model files need to be loaded into memory at the same time, which increases the burden on the device.

[0026] Reference Figure 1-Figure 5 As shown, the lightweight model deployment solution based on the flask framework of the present invention defines the current model deployment configuration file, including global configurations such as IP address and port number, model warehouse (model weight file, calling method, overall image category, etc.), API interface, pre-processing operation, and post-processing operation; the model deployment solution can be divided into single-channel and multi-channel modes according to the actual needs of the project; the server is turned on and waits for the client to send requests and calls; the present invention adopts a lightweight deployment method based on the flask framework, and the model deployment can be completed by pre-defining the configuration required for the model; different API interfaces are used to support the client to call multiple model solutions to complete different tasks; this deployment method reduces the deployment cost and reduces the rigid requirements for device hardware; this deployment method supports cross-language calls and increases flexibility.

[0027] The technical principle of the present invention is described above in combination with the specific embodiments, which are only preferred implementations of the present invention. The protection scope of the present invention is not limited to the above embodiments, and all technical solutions under the idea of ​​the present invention belong to the protection scope of the present invention. Those skilled in the art can think of other specific implementations of the present invention without creative work, and these methods will fall within the protection scope of the present invention.

Claims

1. A lightweight deep learning model deployment method based on the flask framework, characterized in that: The following steps are involved: Step S1: In the preprocessing stage, define relevant configuration information and API interface on the flask server; Step S2: Select single channel or multi-channel according to the application of different projects; Step S3: The flask server starts the model service and prints the relevant channel information. The client passes the image information through the API interface to call the corresponding model deployment solution and waits for the response of the flask server.

2. A lightweight deep learning model deployment method based on the flask framework as described in claim 1, characterized in that: In step S1, defining relevant configuration information includes defining the current model deployment configuration file, which includes the IP address, port number, model repository, pre-processing operations, and post-processing operations.

3. A lightweight deep learning model deployment method based on the flask framework as described in claim 2, characterized in that: In step S2, the single-channel mode represents preloading a single model deployment solution in the flask server; the multi-channel mode represents preloading multiple model deployment solutions in the flask server.

4. A lightweight deep learning model deployment method based on the flask framework as described in claim 3, characterized in that: In step S2, the single-channel mode is set as follows: the model deployment scheme involved in the single channel is configured in advance on the flask server, the model scheme is loaded, and the information of the current channel is printed; different results are returned for pre-processing and post-processing operations according to the category of the model finally returned in the scheme; the pre-processing operation performs certain pre-processing operations on the image transmitted by the client, and the post-processing operation performs further judgment operations on the results obtained by model inference.

5. A lightweight deep learning model deployment method based on the flask framework as described in claim 4, characterized in that: In step S2, the multi-channel mode is set as follows: pre-configure a multi-model deployment scheme on the flask server, load multiple model schemes, and print information of multiple channels; return different results for pre-processing and post-processing operations according to the category of the model finally returned in the scheme; the pre-processing operation performs certain pre-processing operations on the image transmitted by the client, and the post-processing operation performs further judgment operations on the results obtained by model inference.