CN116643814A - Model library construction method, model calling method based on model library and related equipment - Google Patents

Model library construction method, model calling method based on model library and related equipment Download PDF

Info

Publication number
CN116643814A
CN116643814A CN202310546132.3A CN202310546132A CN116643814A CN 116643814 A CN116643814 A CN 116643814A CN 202310546132 A CN202310546132 A CN 202310546132A CN 116643814 A CN116643814 A CN 116643814A
Authority
CN
China
Prior art keywords
model
information
scene
original
library
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310546132.3A
Other languages
Chinese (zh)
Inventor
郭玮
苏力强
王忠强
唐凯杰
陈鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bohan Intelligent Shenzhen Co ltd
Original Assignee
Bohan Intelligent Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bohan Intelligent Shenzhen Co ltd filed Critical Bohan Intelligent Shenzhen Co ltd
Priority to CN202310546132.3A priority Critical patent/CN116643814A/en
Publication of CN116643814A publication Critical patent/CN116643814A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Mathematical Physics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a model library construction method, a model calling method based on a model library and related equipment, wherein the model library construction method comprises the following steps: acquiring original model data; wherein the raw model data comprises: original model application scene information, original model parameters, original model network structure information and original model name information; performing code definition according to the original model name information and the original model network structure information to obtain a model code file; screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the original model parameters; performing association processing on the selected scene interface and the model code file to obtain model association information; and storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library. The invention makes the model extraction operation simple and quick.

Description

Model library construction method, model calling method based on model library and related equipment
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a model library construction method, a model calling method based on a model library and related equipment.
Background
With the development of computer technology, more models are built by the deep learning algorithm, and more scenes complete data processing, data prediction and the like through the deep learning model. For example, common application scenarios are image recognition, text classification, speech recognition, etc. However, as the application scenes increase, the number of models increases correspondingly, and each time a model is used, the model needs to be built by using a python programming language and a deep learning framework, and the model building process is complex and long. Although the developed model is required to be searched in a plurality of files again, so that the model extraction operation is complex and the service time is long.
Disclosure of Invention
The present invention aims to solve at least one of the technical problems existing in the prior art. Therefore, the invention provides a model library construction method which can construct a model library which can be quickly called through model names, so that the model extraction operation is simple and quick.
The invention also provides a model calling method based on the model library.
The invention also provides a model library construction system.
The invention further provides electronic equipment.
The invention also proposes a computer readable storage medium.
In a first aspect, an embodiment of the present invention provides a model library construction method, including:
acquiring original model data; wherein the raw model data comprises: original model application scene information, original model parameters, original model network structure information and original model name information;
performing code definition according to the original model name information and the original model network structure information to obtain a model code file;
screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the original model parameters;
performing association processing on the selected scene interface and the model code file to obtain model association information;
and storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library.
According to other embodiments of the present invention, the method for constructing a model library, according to the original model application scene information and the model parameters, screens out a selected scene interface from preset candidate scene interfaces, includes:
screening a preliminary scene interface from the candidate scene interfaces according to the original model application scene information;
And setting interface parameters of the preliminary scene interface according to the model parameters to obtain the selected scene interface.
According to a model library construction method of other embodiments of the present invention, after the storing the model association information, the model code file, and the selected scene interface in a preset database, the model library construction method further includes:
acquiring newly added model data; wherein the newly added model data includes: newly adding model name information and model import sentences;
screening selected model application scene information from the original model application scene information according to the newly added model name information;
searching a selected code file in the model library according to the selected model application scene information;
adding the model import statement into the selected code file to obtain a new code file;
and storing the newly added code file into the model library to update the model library.
According to other embodiments of the present invention, the method for constructing a model library, according to the application scenario information of the selected model, searches for a selected code file in the model library, includes:
Screening selected scene interfaces from the candidate scene interfaces according to the selected model application scene information;
and calling out a corresponding model code file in the model library according to the selected scene interface to serve as the selected code file.
In a second aspect, an embodiment of the present invention provides a model calling method based on a model library, including:
acquiring calling model name information;
extracting a target model from a preset model library according to the calling model name information; wherein the model library is obtained by the model library construction method according to the first aspect.
According to further embodiments of the present invention, a model calling method based on a model library, the model library includes: model association information, selected model interfaces, and model code files; the extracting the target model from a preset model library according to the calling model name information comprises the following steps:
searching calling model application scene information from a preset model application scene information mapping table according to the calling model name information;
searching a target scene interface in the model association information according to the call model application scene information;
and screening out an object code file from the model code files according to the object scene interface and the selected model interface, and operating the object code file to operate the object model.
According to other embodiments of the present invention, after the object code file is selected from the model code files according to the object scene interface and the model selection interface, and the object code file is executed to execute the object model, the model calling method based on the model library further includes:
obtaining model training data;
training the target model according to the model training data;
acquiring data to be predicted;
and inputting the data to be predicted into the trained target model for model reasoning to obtain target data.
In a third aspect, one embodiment of the present invention provides a model library construction system including:
the data acquisition module is used for acquiring original model data; wherein the raw model data comprises: original model application scene information, model parameters, original model network structure information and original model name information;
the code definition module is used for carrying out code definition according to the original model name information and the original model network structure information to obtain a model code file;
The interface screening module is used for screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the model parameters;
the association module is used for carrying out association processing on the selected scene interface and the model code file to obtain model association information;
and the storage module is used for storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library.
In a fourth aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the model library construction method of the first aspect or to perform the model library-based model invocation method of the second aspect.
In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the model library construction method according to the first aspect or the model library-based model invocation method according to the second aspect.
The model library construction method, the model calling method based on the model library and the related equipment provided by the embodiment of the application use the deep learning unified development interface tensor x to write the model, can be developed and operated in different software and hardware environments, and can be matched with the optimal environment to exert the extremely high-efficiency training performance. Meanwhile, a standard input and output format of the model and a training/reasoning scene interface are established so as to connect the model in the model library through the scene interface, so that a user side can quickly select the model from the model library through the scene interface to train/reason. In addition, when the user side needs to realize the custom model, the custom model can be completed only by inputting new model name information and imported sentences so as to update the model library, so that the model library is updated more simply.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and drawings.
Drawings
FIG. 1 is a flowchart of a model library construction method according to an embodiment of the present application;
FIG. 2 is a flowchart of step S103 in FIG. 1;
FIG. 3 is a diagram of model call relationships in a specific embodiment of a model library construction method in accordance with an embodiment of the present application;
FIG. 4 is a flowchart of a model library construction method according to another embodiment of the present application;
FIG. 5 is a flowchart illustrating step 403 in FIG. 4;
FIG. 6 is a flowchart of an embodiment of a model call method based on a model library according to an embodiment of the present application;
FIG. 7 is a flowchart of step S106 in FIG. 1;
FIG. 8 is a flowchart of an embodiment of a model call method based on a model library according to another embodiment of the present application;
FIG. 9 is a block diagram of a module of one embodiment of a modular library construction system in accordance with an embodiment of the present application;
FIG. 10 is a block diagram of a model call system based on a model library according to an embodiment of the present application
FIG. 11 is a block diagram of an embodiment of an electronic device in accordance with an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
It should be noted that although functional block division is performed in a device diagram and a logic sequence is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the block division in the device, or in the flowchart. The terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the application only and is not intended to be limiting of the application.
First, several nouns involved in the present application are parsed:
artificial intelligence (artificial intelligence, AI): is a new technical science for researching and developing theories, methods, technologies and application systems for simulating, extending and expanding the intelligence of people; artificial intelligence is a branch of computer science that attempts to understand the nature of intelligence and to produce a new intelligent machine that can react in a manner similar to human intelligence, research in this field including robotics, language recognition, image recognition, natural language processing, and expert systems. Artificial intelligence can simulate the information process of consciousness and thinking of people. Artificial intelligence is also a theory, method, technique, and application system that utilizes a digital computer or digital computer-controlled machine to simulate, extend, and expand human intelligence, sense the environment, acquire knowledge, and use knowledge to obtain optimal results.
Model library: refers to storing and managing a collection of pre-trained models, typically comprising various types of deep learning models, such as image classification, object detection, speech recognition, etc. The developer can take the ready-made model through the model library and apply it to his own tasks, avoiding the significant time and computing resources required to train the model from scratch. Common model libraries include TensorFlow Hub, pyTorch Hub, NVIDIANGC, and the like.
TensorLayerX: is a cross-platform deep learning development tool which is developed by using pure Python codes. By packaging the Python interfaces of multiple back ends, the TensorLayerX provides a set of unified APIs compatible with the deep learning development of multiple frames, and the bottom program of each back end frame is responsible for calling hardware calculation, so that a developer can perform the deep learning development without regard to the back end frames and hardware platforms. In this process, there is little loss of computational performance.
With the development of random computer technology, deep learning algorithms are also developed, more and more model structures are proposed, and the model can achieve excellent effects in many scenes. Therefore, the method is widely applied to various industries. In the process of self-developing or implementing the deep learning model, python programming language and a deep learning framework are required, and ensorFlow, pytorch, paddlePaddle, mindSpore is a common deep learning framework. However, for some common use scenes, such as image detection, text classification and the like, an ideal effect can be achieved by directly using the open source implementation of the public model, and meanwhile, a user does not need to develop the model, so that the workload is greatly reduced. However, the models of different types are respectively stored in different positions, are difficult to call in a unified manner, and the existing models have no concept of scene division, so that the models are difficult to directly replace even two models for similar work, a user is required to make certain modification and customization on the models, and the required models are difficult to quickly extract.
Based on the above, the embodiment of the application provides a model library construction method, a model calling method based on a model library and related equipment, wherein a model code file is constructed based on model name information and original model network structure information, and then a scene interface and the model code file are associated to obtain model association information so as to store the model association information, the model code file and a selected scene interface into a database to construct the model library. Therefore, by constructing a model library containing various types of models so as to connect the models in the model library based on a general model interface, a user can quickly call the corresponding model from the model library for training and reasoning only by providing a model application scene and a model name, and the efficiency of model call and use is improved.
The method for constructing the model library, the model calling method based on the model library and the related equipment provided by the embodiment of the application are specifically described through the following embodiments, and the method for constructing the model library in the embodiment of the application is described first.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Among these, artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The embodiment of the application provides a model library construction method and a model calling method based on a model library, which relate to the technical field of artificial intelligence. The model library construction method and the model calling method based on the model library provided by the embodiment of the application can be applied to a terminal, a server side and software running in the terminal or the server side. In some embodiments, the terminal may be a smart phone, tablet, notebook, desktop, etc.; the server side can be configured as an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligent platforms and the like; the software may be an application or the like that implements the model library construction method, but is not limited to the above form.
The application is operational with numerous general purpose or special purpose computer system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It should be noted that, in each specific embodiment of the present application, when related processing is required according to user information, user behavior data, user history data, user location information, and other data related to user identity or characteristics, permission or consent of the user is obtained first, and the collection, use, processing, and the like of the data comply with related laws and regulations and standards. In addition, when the embodiment of the application needs to acquire the sensitive personal information of the user, the independent permission or independent consent of the user is acquired through popup or jump to a confirmation page and the like, and after the independent permission or independent consent of the user is definitely acquired, the necessary relevant data of the user for enabling the embodiment of the application to normally operate is acquired.
Fig. 1 is an optional flowchart of a model library construction method according to an embodiment of the present application, where the method in fig. 1 may include, but is not limited to, steps S101 to S105.
Step S101, obtaining original model data; wherein the raw model data comprises: original model application scene information, original model parameters, original model network structure information and original model name information;
step S102, code definition is carried out according to original model name information and original model network structure information, and a model code file is obtained;
step S103, selecting a selected scene interface from preset candidate scene interfaces according to the original model application scene information and the original model parameters;
step S104, carrying out association processing on the selected scene interface and the model code file to obtain model association information;
step S105, storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library.
In the steps S101 to S105 shown in the embodiment of the present application, the original model data is obtained, and the original model data includes: the method comprises the steps of original model application scene information, original model parameters, original model network structure information and original model name information. When the model needs to be put in storage, registering and constructing a model library, firstly, defining original model name information and original model structure information by using codes to obtain a model code file so as to write and execute codes corresponding to the original model. And screening selected scene interfaces from the candidate scene interfaces according to the application scene information of the original model and the parameters of the original model, namely determining the selected scene interface corresponding to each original model realization scene, and correlating the selected scene interface with the model code file to obtain model correlation information, wherein the mapping relationship between the selected scene interface and the model code file is represented by the model correlation information. And finally, storing the model association information, the model code file and the selected scene interface into a database to write and register the model to construct a model library containing various scene models.
In step S101 of some embodiments, original model application scene information, original model parameters, original model network structure information, and original model name information are acquired; the original model application scene information characterizes a scene used by the original model. In this embodiment, the original model application scene information is a model corresponding to a scene in 3 fields 12, and the original model application scene information includes: target detection, image classification, semantic segmentation, face detection, face recognition, human body gesture recognition, face key point detection, text recognition, text classification, text condition generation, text labeling and automatic speech recognition. The method comprises the steps of target detection, image classification, semantic segmentation, face detection, face recognition, human body gesture recognition, face key point detection and character recognition, and belongs to the field of vision, the field of text classification, text condition generation and text labeling, and the field of automatic language recognition is the field of voice. Therefore, a model library with more abundant model application scene information is constructed by acquiring a plurality of application scene corresponding models.
In step S102 of some embodiments, the original model network structure information characterizes the network structure of the original model, that is, determines the input data format and the output data format of the original model, so that the original model network structure information required by the original network is completely defined by the code to obtain a model code file, and the original model name information is defined by the code to integrate the original model name information in the form of the code into the model code file, so that the corresponding model code file is conveniently found based on the model name information. Thus, the network structure and name information of the original model are described by code to facilitate subsequent model calls through model name lookup.
Referring to fig. 2, in some embodiments, step S103 may include, but is not limited to, steps S201 to S202:
step S201, a preliminary scene interface is screened out from candidate scene interfaces according to the original model application scene information;
step S202, setting interface parameters of the preliminary scene interface according to the model parameters to obtain the selected scene interface.
In step S201 of some embodiments, before the model performs the warehouse entry registration, an interface corresponding to the original model needs to be defined. For the same original model application scene information, the input and output formats of the original model are approximately the same as the task targets are basically the same. And selecting a corresponding preliminary scene interface from the candidate scene interfaces based on the original model application scene information, namely defining the corresponding candidate scene interface as the preliminary scene interface based on the original model application scene information, and defining the same input and output format for the original model of the same original model application scene information.
Specifically, referring to fig. 3, fig. 3 shows a relationship diagram of model library call, including a user side, a scene interface, and a model library, where the model library is provided with a model interface and a scene interface connection. The user side can call the model interface through the scene interface and then call the model through the model interface so as to realize the unified interface call of the model, and can quickly find the model corresponding to the application scene of the model to train and infer, thereby improving the efficiency of model call. Therefore, when the model is called, only the model name is required to be specified to determine the model application scene information so as to realize quick call of the model. Wherein each original model application scene information and each original model appear as a python class and the candidate scene interface appears as a function of the python class. Generally, the candidate scene interfaces have four functions of __ init __ and loss_ fn, forward, predict, and the model interfaces have three functions of __ init __ and build, forward, so that the candidate scene interfaces and the model interfaces of the original model are predefined and cannot be modified. Because the candidate scene interface and the model interface are defined in advance, the operation of the model corresponding to the information of the other application scene is completely the same when the user side calls the original model, and only the python class needs to be replaced when the original model calls the replacement, so that the mode of calling the original model through the model application scene is the same.
In step S202 of some embodiments, the preliminary scene interfaces for the same original model application scene are the same, but the same original model application scene may have models of different scales, so the interface parameters of the preliminary scene interfaces are adjusted based on the model parameters to obtain the selected scene model. For example, if the original model application scene information is image classification, the corresponding preliminary scene interface is tlxzo. The preliminary scene interface is characterized by a function, so that the selected scene interface is tlxzo.imageclassifier (model= "resnet 101") by modifying the interface parameters of the preliminary scene interface, that is, modifying the model names in the function.
In the steps S201 to S202 shown in the embodiment of the present application, by determining the preliminary scene interface corresponding to the application scene information of the original model, and the preliminary scene interface is characterized by a function, and modifying the name in the function based on the model parameters to obtain the selected scene interface corresponding to the larger model, the scene interface definition of various models is realized.
In step S104 of some embodiments, the model association information is obtained by associating the selected scene interface with the model code file, that is, constructing a mapping relationship between the selected scene interface and the model code file. If the selected scene interface corresponding to the image classification model is a tlxzo.imageclassification file (model= "resnet 101") and the model code file corresponding to the image classification model is an a code file, a mapping relationship between the tlxzo.imageclassification file (model= "resnet 101") -a code file is established, so that the model corresponding to the model code file is directly called according to the scene interface, and quick model calling is realized.
In step S105 of some embodiments, a model library including a plurality of application scenario models is constructed by storing model code files, model associations, and selected scenario interfaces in a database. Meanwhile, the model code file, the model association relation and the selected scene interface are stored in the model library, which is equivalent to the completion of the registration of the original model to the model library.
Referring to fig. 4, in some embodiments, after step S105, the model library construction method may further include, but is not limited to, steps S401 to S405:
Step S401, obtaining newly added model data; wherein the newly added model data includes: newly adding model name information and model import sentences;
step S402, screening out selected model application scene information from original model application scene information according to newly added model name information;
step S403, searching out a selected code file in a model library according to the selected model application scene information;
step S404, adding a model import statement into the selected code file to obtain a new code file;
step S405, the newly added code file is stored in the model library to update the model library.
After the model library is built, the model library already stores the original models of a plurality of application scenes, and when the models need to be further added in the model library. In step S401 of some embodiments, newly added model name information and a model import statement are acquired, and the model import statement is a statement that needs to be added in a model code file for the newly added model to realize model addition.
In step S402 of some embodiments, filtering is performed in the original model application scenario information based on the newly added model name information, that is, the closest original model name information is found according to the newly added model name information and is used as the selected model name information, and then the original model application scenario corresponding to the selected model name information is obtained and is used as the selected model application scenario information. For example, if the newly added model name information is an industrial image recognition model, the model application scene information corresponding to the image recognition model is found to be image recognition.
In step S403 of some embodiments, a scene interface in the model library is determined based on the selected model application scene information, and a corresponding model code file is called from the model library based on the scene interface as a selected code file, so as to find an import code of a model class corresponding to the newly added model name information in the model library. The selected code file corresponding to each model application scene information is in a fixed place, and when a new model is added in a scene, an imported code needs to be found.
In step S404 of some embodiments, a model import statement of the newly added model is added to the selected code file, so that only a small number of statements need to be modified in the original approximate model code file to newly add the model each time the model is newly added, so that the operation of newly adding the model in the model library is simple.
In step S405 of some embodiments, after the new code file is constructed, the new code file is directly stored in the model library, and the model application scenario information and the model association information corresponding to the new code file are the same as the associated selected model application scenario information. Therefore, when the model is customized, only new model name information and model import sentences are needed to be input, so that the model customization operation is simple.
In steps S401 to S405 illustrated in this embodiment, a corresponding model code file is found in the model library based on the newly added model name information to be used as a selected code file, and then a model import statement is added in the selected code file to implement model customization in the model library, and the custom model is easy to operate, and the model can be newly added only by modifying a small portion of the codes without reconstructing the codes.
Referring to fig. 5, in some embodiments, step S403 may include, but is not limited to, steps S501 to S502:
step S501, selecting a selected scene interface from candidate scene interfaces according to the selected model application scene information;
step S502, according to the selected scene interface, a corresponding model code file is called out from the model library to be used as a selected code file.
In step S501 of some embodiments, since the scene interfaces are associated with the model interfaces, when the model code file in the model library is called, the matched selected scene interface needs to be searched from the candidate scene interfaces according to the selected model scene information, so as to determine the corresponding model interface according to the selected scene interface, so that the model in the model library is called.
In step S502 of some embodiments, the selected scene interface is directly called to the corresponding model interface, and then the corresponding model code file is called out as the selected code file through the model interface, so that the selected code file is called out accurately and quickly.
It should be noted that, the existing official model library of frames such as pyrach/tensorflow focuses on the implementation of the model, and has no scene interface level, at this time, the user side needs to directly call the model in the model library, if there are multiple models in the model library, it takes a lot of time to search the models one by one, so that the model call efficiency is low. Meanwhile, in the prior art, the same scene interface does not exist, and the calling mode and the pre-post processing mode of each original model are different, so that a user needs to write additional code adaptation. And the method is equivalent to that one model is called each time, and even the original model of the application scene of the same model is called, the development needs to be carried out once again. Therefore, the application associates the user side and the model library by adding the scene interface, and provides the standard scene interface for each model application scene, and the user side can complete the model call by only calling a small number of scene interfaces, so that the model call is simpler.
In steps S501 to S502 illustrated in this embodiment, a selected scene interface is selected from candidate scene interfaces based on the selected model scene information, and a corresponding selected code file is called in the model library based on the selected scene interface. Therefore, model code file calling corresponding to the model is realized based on the scene interface, so that model code file extraction is easier.
Referring to fig. 6, the embodiment of the present application further provides a model calling method based on a model library, where the model calling method based on the model library includes, but is not limited to, steps S601 to S602:
step S601, acquiring calling model name information;
step S602, extracting a target model from a preset model library according to calling model name information; the model library is obtained by the model library construction method.
In steps S601 to S602 illustrated in this embodiment, after the model library is constructed by the model library construction method, when the model in the model library needs to be called, only the model name information needs to be called to directly call out the target model in the model library, so that the target model is called more efficiently.
It should be noted that the model library is a deep learning model library based on tensor, and the models in the model library may run on different frameworks/platforms. The model libraries are stored in a distributed mode according to the model application scene, and the model code file of each model library contains model name information, so that model calling can be completed only by providing calling model name information by a user side. Therefore, for the common scene and model, the user side can automatically call the target model from the model library only by designating the scene name and the model name.
Referring to fig. 7, in some embodiments, the model library includes: model association information, selected model interfaces, and model code files; step S106 may include, but is not limited to, steps S701 to S703:
step S701, searching calling model application scene information from a preset model application scene information mapping table according to calling model name information;
step S702, searching out a target scene interface in the model association information according to the calling model application scene information;
step S703, screening out object code files from the model code files according to the object scene interface and the selected model interface, and running the object code files to run the object model.
In step S701 of some embodiments, a preset model application scenario mapping table includes a mapping relationship between model application scenario information and model name information; for example, the industrial image recognition model, the environment image recognition model and the image content recognition model are all corresponding to one model scene information for image recognition. Therefore, the corresponding model application scene information is searched in the model application scene information mapping table based on the calling model name information so as to determine the model application scene needing to call the model.
In step S702 of some embodiments, the model association information includes association information between the model code file and the selected scene interface, so that the selected scene interface in the model association information is selected as the target scene interface based on the calling model application scene information, so as to determine the scene interface that needs to call the model, and further determine the corresponding model interface.
In step S703 of some embodiments, a matched selected model interface is found according to the target scene interface, and then a model code file is extracted from the model interface corresponding to the selected model interface as the target code file. The object code file characterizes model network structure information of the object model, so the object model is brought up by running the object code file to enable the object model to start training or reasoning.
In steps S701 to S703 illustrated in the present embodiment, the model application scenario information corresponding to the calling model name information is determined first, then the target scenario interface corresponding to the model application scenario information is determined, and finally the target code file is directly called out from the model library based on the target scenario interface, so that the target model is operated through the target code file, and the target model is more simply called.
Referring to fig. 8, in some embodiments, after step S703, the model library-based model invoking method further includes, but is not limited to, steps S801 to S804:
step S801, obtaining model training data;
step S802, training a target model according to model training data;
step S803, obtaining data to be predicted;
step S804, inputting the data to be predicted into the trained target model for model reasoning to obtain the target data.
In steps S801 to S802 of some embodiments, after the target model call is completed, model training data is acquired, and the model training data includes a training data set and a test data set, and the training data set is input to the target model to obtain an output data set; and carrying out parameter adjustment on the target model based on the test data set and the output data set, and carrying out parameter optimization on the target model through an optimizer so as to store optimal model parameters after training is completed. For example, if the target model is an image classification model, an optimizer is set to optimize the image classification model, then an accuracy index is calculated in a specified training process, and when the accuracy index converges, the image classification model training is completed, and model parameters are saved.
In steps S803 to S804 of some embodiments, after the training of the target model is completed, the data to be predicted is input into the target model to perform inference calculation to obtain the target data, so that the target is directly used after being called, and the inference calculation is rapidly completed. For example, if the target model is an image classification model, reading pre-stored model parameters, replacing the parameters of the target model with the model parameters, then reading data to be predicted, inputting the data to be predicted into the target model for reasoning processing, and obtaining the target data. The target data is an reasoning result, and the reasoning result is printed out after the reasoning result operation is completed.
The embodiment of the application uses a deep learning unified development interface tensor programming model, and the same codes can run on frames such as TensorFlow, pytorch, paddlePaddle, mindSpore, can be developed and run in different software and hardware environments, and can play the extremely high-efficiency training performance by matching with the optimal environment. Meanwhile, the common use situation of the model scene is divided into 12 scenes in 3 fields, and for each scene, the standard input and output format of the model and the scene interface of training/reasoning are formulated so as to connect the model in the model library through the scene interface, so that the user side can quickly select the model from the model library through the scene interface to train/reason. In addition, when the user side needs to realize the custom model, the custom model can be completed only by inputting new model name information and imported sentences so as to update the model library, so that the model library is updated more simply.
Referring to fig. 9, the embodiment of the present application further provides a model library construction system, which can implement the above model library construction method, where the system includes:
the data acquisition module 901 is used for acquiring original model data; wherein the raw model data comprises: original model application scene information, model parameters, original model network structure information and original model name information;
the code definition module 902 is configured to perform code definition according to the original model name information and the original model network structure information to obtain a model code file;
the interface screening module 903 is configured to screen a selected scene interface from preset candidate scene interfaces according to the original model application scene information and the model parameters;
the association module 904 is configured to perform association processing on the selected scene interface and the model code file to obtain model association information;
the storage module 905 is configured to store the model association information, the model code file, and the selected scene interface into a preset database, to obtain a model library.
The specific implementation manner of the model library construction system is basically the same as that of the specific embodiment of the model library construction method, and is not described herein.
Referring to fig. 10, the embodiment of the present application further provides a model calling system based on a model library, which can implement the model calling method based on the model library, where the system includes:
An information obtaining module 1001, configured to obtain calling model name information;
the model extraction module 1002 is configured to extract a target model from a preset model library according to calling model name information; the model library is obtained by the model library construction method.
The specific implementation manner of the model calling system based on the model library is basically the same as that of the specific embodiment of the model calling method based on the model library, and is not described herein.
The embodiment of the application also provides electronic equipment, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the model library construction method or the model calling method based on the model library when executing the computer program. The electronic equipment can be any intelligent terminal including a tablet personal computer, a vehicle-mounted computer and the like.
Referring to fig. 11, fig. 11 illustrates a hardware structure of an electronic device according to another embodiment, the electronic device includes:
the processor 1101 may be implemented by a general purpose CPU (central processing unit), a microprocessor, an application specific integrated circuit (ApplicationSpecificIntegratedCircuit, ASIC), or one or more integrated circuits, etc. for executing related programs to implement the technical solution provided by the embodiments of the present application;
The memory 1102 may be implemented in the form of read-only memory (ReadOnlyMemory, ROM), static storage, dynamic storage, or random access memory (RandomAccessMemory, RAM). The memory 1102 may store an operating system and other application programs, and when the technical solutions provided in the embodiments of the present disclosure are implemented by software or firmware, relevant program codes are stored in the memory 1102, and the processor 1101 invokes a model library construction method for executing the embodiments of the present disclosure, or a model library-based model invoking method;
an input/output interface 1103 for implementing information input and output;
the communication interface 1104 is configured to implement communication interaction between the device and other devices, and may implement communication in a wired manner (e.g. USB, network cable, etc.), or may implement communication in a wireless manner (e.g. mobile network, WIFI, bluetooth, etc.);
bus 1105 transmits information between the various components of the device (e.g., processor 1101, memory 1102, input/output interface 1103, and communication interface 1104);
wherein the processor 1101, memory 1102, input/output interface 1103 and communication interface 1104 enable communication connection therebetween within the device via bus 1105.
The embodiment of the application also provides a computer readable storage medium, which stores a computer program, and the computer program realizes the model library construction method or model calling method based on the model library when being executed by a processor.
The memory, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
It will be appreciated by persons skilled in the art that the embodiments of the application are not limited by the illustrations, and that more or fewer steps than those shown may be included, or certain steps may be combined, or different steps may be included.
The above described apparatus embodiments are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Those of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
The terms "first," "second," "third," "fourth," and the like in the description of the application and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the above-described division of units is merely a logical function division, and there may be another division manner in actual implementation, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including multiple instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method of the various embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing a program.
The preferred embodiments of the present application have been described above with reference to the accompanying drawings, and are not thereby limiting the scope of the claims of the embodiments of the present application. Any modifications, equivalent substitutions and improvements made by those skilled in the art without departing from the scope and spirit of the embodiments of the present application shall fall within the scope of the claims of the embodiments of the present application.

Claims (10)

1. The model library construction method is characterized by comprising the following steps of:
acquiring original model data; wherein the raw model data comprises: original model application scene information, original model parameters, original model network structure information and original model name information;
performing code definition according to the original model name information and the original model network structure information to obtain a model code file;
screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the original model parameters;
performing association processing on the selected scene interface and the model code file to obtain model association information;
and storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library.
2. The method for constructing a model library according to claim 1, wherein the step of screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the model parameters comprises:
screening a preliminary scene interface from the candidate scene interfaces according to the original model application scene information;
and setting interface parameters of the preliminary scene interface according to the model parameters to obtain the selected scene interface.
3. The model base construction method according to claim 1, wherein after the storing the model association information, the model code file, and the selected scene interface in a preset database to obtain a model base, the model base construction method further comprises:
acquiring newly added model data; wherein the newly added model data includes: newly adding model name information and model import sentences;
screening selected model application scene information from the original model application scene information according to the newly added model name information;
searching a selected code file in the model library according to the selected model application scene information;
adding the model import statement into the selected code file to obtain a new code file;
And storing the newly added code file into the model library to update the model library.
4. A method of constructing a model library according to claim 3, wherein said searching for a selected code file in said model library based on said selected model application scenario information comprises:
screening selected scene interfaces from the candidate scene interfaces according to the selected model application scene information;
and calling out a corresponding model code file in the model library according to the selected scene interface to serve as the selected code file.
5. A model calling method based on a model library, which is characterized by comprising the following steps:
acquiring calling model name information;
extracting a target model from a preset model library according to the calling model name information; wherein the model library is obtained by the model library construction method according to any one of claims 1 to 4.
6. The model call method based on the model library according to claim 5, wherein the model library comprises: model association information, selected model interfaces, and model code files; the extracting the target model from a preset model library according to the calling model name information comprises the following steps:
Searching calling model application scene information from a preset model application scene information mapping table according to the calling model name information;
searching a target scene interface in the model association information according to the call model application scene information;
and screening out an object code file from the model code files according to the object scene interface and the selected model interface, and operating the object code file to operate the object model.
7. The model call method based on model library according to claim 6, wherein after said selecting the object code file from the model code files according to the object scene interface and the model selection interface, running the object code file to run the object model, the model call method based on model library further comprises:
obtaining model training data;
training the target model according to the model training data;
acquiring data to be predicted;
and inputting the data to be predicted into the trained target model for model reasoning to obtain target data.
8. A model library construction system, the model library construction system comprising:
The data acquisition module is used for acquiring original model data; wherein the raw model data comprises: original model application scene information, model parameters, original model network structure information and original model name information;
the code definition module is used for carrying out code definition according to the original model name information and the original model network structure information to obtain a model code file;
the interface screening module is used for screening selected scene interfaces from preset candidate scene interfaces according to the original model application scene information and the model parameters;
the association module is used for carrying out association processing on the selected scene interface and the model code file to obtain model association information;
and the storage module is used for storing the model association information, the model code file and the selected scene interface into a preset database to obtain a model library.
9. An electronic device, comprising:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the model library construction method of any one of claims 1 to 4 or the model library-based model invocation method of any one of claims 5 to 7.
10. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the model library construction method according to any one of claims 1 to 4 or the model library-based model invocation method according to any one of claims 5 to 7.
CN202310546132.3A 2023-05-15 2023-05-15 Model library construction method, model calling method based on model library and related equipment Pending CN116643814A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310546132.3A CN116643814A (en) 2023-05-15 2023-05-15 Model library construction method, model calling method based on model library and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310546132.3A CN116643814A (en) 2023-05-15 2023-05-15 Model library construction method, model calling method based on model library and related equipment

Publications (1)

Publication Number Publication Date
CN116643814A true CN116643814A (en) 2023-08-25

Family

ID=87622245

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310546132.3A Pending CN116643814A (en) 2023-05-15 2023-05-15 Model library construction method, model calling method based on model library and related equipment

Country Status (1)

Country Link
CN (1) CN116643814A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110231939A (en) * 2019-05-16 2019-09-13 平安科技(深圳)有限公司 Model generating method, system, computer equipment and storage medium
CN111369011A (en) * 2020-04-16 2020-07-03 光际科技(上海)有限公司 Method and device for applying machine learning model, computer equipment and storage medium
CN113971032A (en) * 2021-12-24 2022-01-25 百融云创科技股份有限公司 Full-process automatic deployment method and system of machine learning model for code generation
CN114153911A (en) * 2021-12-21 2022-03-08 浪潮软件集团有限公司 Method and system for custom generation of database test data based on VBA technology
US20220206786A1 (en) * 2020-12-30 2022-06-30 International Business Machines Corporation Code library selection management

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110231939A (en) * 2019-05-16 2019-09-13 平安科技(深圳)有限公司 Model generating method, system, computer equipment and storage medium
CN111369011A (en) * 2020-04-16 2020-07-03 光际科技(上海)有限公司 Method and device for applying machine learning model, computer equipment and storage medium
US20220206786A1 (en) * 2020-12-30 2022-06-30 International Business Machines Corporation Code library selection management
CN114153911A (en) * 2021-12-21 2022-03-08 浪潮软件集团有限公司 Method and system for custom generation of database test data based on VBA technology
CN113971032A (en) * 2021-12-24 2022-01-25 百融云创科技股份有限公司 Full-process automatic deployment method and system of machine learning model for code generation

Similar Documents

Publication Publication Date Title
US11899681B2 (en) Knowledge graph building method, electronic apparatus and non-transitory computer readable storage medium
CN109284399B (en) Similarity prediction model training method and device and computer readable storage medium
CN110795913B (en) Text encoding method, device, storage medium and terminal
KR20200007969A (en) Information processing methods, terminals, and computer storage media
CN109408821B (en) Corpus generation method and device, computing equipment and storage medium
US11238132B2 (en) Method and system for using existing models in connection with new model development
CN110472008B (en) Intelligent interaction method and device
CN108304376B (en) Text vector determination method and device, storage medium and electronic device
US11036996B2 (en) Method and apparatus for determining (raw) video materials for news
CN111611355A (en) Dialog reply method, device, server and storage medium
CN116541493A (en) Interactive response method, device, equipment and storage medium based on intention recognition
CN117520514A (en) Question-answering task processing method, device, equipment and readable storage medium
CN117435999A (en) Risk assessment method, apparatus, device and medium
CN112966076A (en) Intelligent question and answer generating method and device, computer equipment and storage medium
CN116701604A (en) Question and answer corpus construction method and device, question and answer method, equipment and medium
CN111931503A (en) Information extraction method and device, equipment and computer readable storage medium
CN116543798A (en) Emotion recognition method and device based on multiple classifiers, electronic equipment and medium
CN116127066A (en) Text clustering method, text clustering device, electronic equipment and storage medium
CN116643814A (en) Model library construction method, model calling method based on model library and related equipment
CN115292180A (en) Code analysis method, code analysis device, electronic device, and storage medium
CN114580533A (en) Method, apparatus, device, medium, and program product for training feature extraction model
CN111753548A (en) Information acquisition method and device, computer storage medium and electronic equipment
CN110308931B (en) Data processing method and related device
CN114546354A (en) Data transmission method, device, equipment and medium based on configurable middleware
CN117648416A (en) Physical examination result processing method, device, equipment and medium

Legal Events

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