neuropod
v0.3.0-rc7
Neuropod是一个库,它提供了一个统一的界面,可以从C ++和Python中的多个框架运行深度学习模型。 Neuropod使研究人员可以轻松地在选择的框架中构建模型,同时简化这些模型的生产。
目前,它支持Tensorflow,Pytorch,Torchscript,Keras和Ludwig。
有关更多信息:
运行TensorFlow模型看起来完全像运行Pytorch模型。
x = np . array ([ 1 , 2 , 3 , 4 ])
y = np . array ([ 5 , 6 , 7 , 8 ])
for model_path in [ TF_ADDITION_MODEL_PATH , PYTORCH_ADDITION_MODEL_PATH ]:
# Load the model
neuropod = load_neuropod ( model_path )
# Run inference
results = neuropod . infer ({ "x" : x , "y" : y })
# array([6, 8, 10, 12])
print results [ "out" ]有关更多示例,请参见教程,Python指南或C ++指南。
其中一些好处包括:
任何神经模型模型都可以从C ++和Python(甚至尚未转换为Torchscript的Pytorch模型)运行。
这使您可以更多地关注要解决的问题,而不是要解决问题的框架。
例如,如果您为2D对象检测定义问题API,则任何实现该问题的模型都可以重用所有现有的推理代码和基础架构解决该问题。
INPUT_SPEC = [
# BGR image
{ "name" : "image" , "dtype" : "uint8" , "shape" : ( 1200 , 1920 , 3 )},
]
OUTPUT_SPEC = [
# shape: (num_detections, 4): (xmin, ymin, xmax, ymax)
# These values are in units of pixels. The origin is the top left corner
# with positive X to the right and positive Y towards the bottom of the image
{ "name" : "boxes" , "dtype" : "float32" , "shape" : ( "num_detections" , 4 )},
# The list of classes that the network can output
# This must be some subset of ['vehicle', 'person', 'motorcycle', 'bicycle']
{ "name" : "supported_object_classes" , "dtype" : "string" , "shape" : ( "num_classes" ,)},
# The probability of each class for each detection
# These should all be floats between 0 and 1
{ "name" : "object_class_probability" , "dtype" : "float32" , "shape" : ( "num_detections" , "num_classes" )},
]这让你
有关更多详细信息,请参见教程。
如果您有几个模型可以采用类似的输入,则可以构建和优化一个框架 - 不合时宜的输入生成管道,并在跨模型中共享。
完全独立的模型(包括自定义操作)
有效的零拷贝操作
在包括的平台上测试
模型隔离,并进行执行不足
通过一行代码从运行过程中切换到程序外运行
有关如何开始使用Neuropod的概述,请参见基本简介教程。
Python Guide和C ++指南有关运行Neuropod模型的更多详细信息。