与tensorio一起使用的束模型
tensorio-bundler的Python项目详细描述
Tensorio捆绑器
创建Tensorio模型包
从命令行运行绑定器
注意:正在制作pypi包。一旦完成,这些说明就会改变
使用相应的pip install
生成的任何二进制文件。
要求
- Python3
说明
tensorio_bundler
模块附带了一个bundler
实用程序,您可以使用它来创建tensorio
直接从命令行压缩tiobundle文件。
有关如何运行bundler
的详细信息,请运行:
python -m tensorio_bundler.bundler -h
一个示例调用(使用测试数据,假设从项目根目录运行——与此目录相同 自述文件):
python -m tensorio_bundler.bundler \
--tflite-model ./tensorio_bundler/fixtures/test.tflite \
--model-json ./tensorio_bundler/fixtures/test.tiobundle/model.json \
--assets-dir ./tensorio_bundler/fixtures/test.tiobundle/assets \
--bundle-name sample.tiobundle \
--outfile sample.tiobundle.zip
通过rest api在本地调用bundler
要从项目根目录(与本自述文件相同的目录)本地运行rest api,请执行以下操作:
gunicorn tensorio_bundler.rest:api
在单独的终端窗口中,您可以按如下方式调用绑定器:
TFLITE_PATH="\"$(mktemp -d)/model.tflite\""
read -r -d '' REQUEST_BODY <<-EOF
{
"saved_model_dir": "./tensorio_bundler/fixtures/test-model",
"build": true,
"tflite_path": $TFLITE_PATH,
"model_json_path": "./tensorio_bundler/fixtures/test.tiobundle/model.json",
"assets_path": "./tensorio_bundler/fixtures/test.tiobundle/assets",
"bundle_name": "curl-test.tiobundle",
"bundle_output_path": "curl-test.tiobundle.zip"
}
EOF
curl -v -X POST \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY" \
http://localhost:8000/bundle
通过Docker运行捆绑程序
要求
- 码头工人
如果你没有它,get it
说明
当您运行
bundler或您可以在服务帐户凭据文件中绑定mount并设置
GOOGLE_APPLICATION_CREDENTIALS
指向容器中装入路径的环境变量。
注:这些说明目前非常稀少。他们不会永远这样。
Tensorio模型库
tensorio bundler现在与tensorio-models集成
通过存储库rest api。一旦构建了包,就可以使用
tensorio_bundler.bundler.register_bundle
方法将其注册到Tensorio模型
储存库。cli允许您通过
--repository-path
参数。
这需要在您的环境中设置两个环境变量:
REPOSITORY
——tensorio模型存储库api url的url(例如https://tio-models-test.dev.docai.beer/rest/v1/repository)REPISITORY_API_KEY
——用于根据存储库对请求进行身份验证的基本身份验证令牌 rest api。
如果要参与此项目,请运行测试
要求
- 码头工人
如果你没有它,get it
说明
简单运行:
./test.sh