8个版本
0.2.3 | 2021年2月1日 |
---|---|
0.2.3-alpha.2 | 2021年1月22日 |
0.2.2-alpha.1 | 2020年12月14日 |
0.2.0 | 2020年11月17日 |
0.1.0 | 2019年5月27日 |
#256 in 机器学习
每月 21 次下载
46KB
962 行

Orkhon:机器学习推理框架和服务器运行时
最新版本 |
|
许可证 |
|
构建状态 |
|
下载量 |
|
Gitter |
|
这是什么?
Orkhon是一个Rust框架,用于运行/使用Python编写的推理/预测代码、冻结模型以及处理未见数据。它主要专注于以高性能方式提供模型和处理未见数据。该框架试图通过内置的异步API来解决直接使用Python和服务器可扩展性问题。
主要功能
- 模型同步和异步API。
- 易于嵌入知名Rust Web框架的引擎。
- 用于与Python代码交互的API契约。
- 高处理吞吐量
- ~4.8361 GiB/s的预测吞吐量
- 平均处理3000个并发请求需要约4ms
- Python模块缓存
安装
您可以使用以下方式将Orkhon包含到项目中;
[dependencies]
orkhon = "0.2"
依赖项
您需要
- 如果您使用
pymodel
功能,则需要安装Python开发依赖项并拥有合适的Python运行时以使用Orkhon与您的项目。 - 如果您想进行Tensorflow推理,则需要将Tensorflow作为库链接安装。
- ONNX接口不需要系统侧的额外依赖项。
- 将您的
PYTHONHOME
环境变量指向Python安装目录。
Python API契约
有关Python API契约,您可以查看项目文档。
示例
异步请求Tensorflow预测
use orkhon::prelude::*;
use orkhon::tcore::prelude::*;
use orkhon::ttensor::prelude::*;
use rand::*;
use std::path::PathBuf;
let o = Orkhon::new()
.config(
OrkhonConfig::new()
.with_input_fact_shape(InferenceFact::dt_shape(f32::datum_type(), tvec![10, 100])),
)
.tensorflow(
"model_which_will_be_tested",
PathBuf::from("tests/protobuf/manual_input_infer/my_model.pb"),
)
.shareable();
let mut rng = thread_rng();
let vals: Vec<_> = (0..1000).map(|_| rng.gen::<f32>()).collect();
let input = tract_ndarray::arr1(&vals).into_shape((10, 100)).unwrap();
let o = o.get();
let handle = async move {
let processor = o.tensorflow_request_async(
"model_which_will_be_tested",
ORequest::with_body(TFRequest::new().body(input.into())),
);
processor.await
};
let resp = block_on(handle).unwrap();
同步请求ONNX预测
此示例需要启用onnxmodel
功能。
use orkhon::prelude::*;
use orkhon::tcore::prelude::*;
use orkhon::ttensor::prelude::*;
use rand::*;
use std::path::PathBuf;
let o = Orkhon::new()
.config(
OrkhonConfig::new()
.with_input_fact_shape(InferenceFact::dt_shape(f32::datum_type(), tvec![10, 100])),
)
.onnx(
"model_which_will_be_tested",
PathBuf::from("tests/protobuf/onnx_model/example.onnx"),
)
.build();
let mut rng = thread_rng();
let vals: Vec<_> = (0..1000).map(|_| rng.gen::<f32>()).collect();
let input = tract_ndarray::arr1(&vals).into_shape((10, 100)).unwrap();
let resp = o
.onnx_request(
"model_which_will_be_tested",
ORequest::with_body(ONNXRequest::new().body(input.into())),
)
.unwrap();
assert_eq!(resp.body.output.len(), 1);
许可证
许可证为MIT
文档
官方文档托管在docs.rs。
获取帮助
请前往我们的 Gitter 或使用 StackOverflow
讨论和发展
我们使用 Gitter 进行开发讨论。也请毫不犹豫地在 GitHub 上提交问题、要求功能、报告错误、评论设计等!更多的互动和想法更好!
为 Orkhon 贡献 
欢迎所有贡献、错误报告、错误修复、文档改进、增强和想法。
有关如何贡献的详细概述,请参阅 GitHub 上的 CONTRIBUTING 指南。
依赖项
~9–24MB
~394K SLoC