目录

ts.torch_handler.request_envelope 包

子模块

ts.torch_handler.request_envelope.base 模块

所有请求包的基类。

一个请求信封重新格式化了调用处理程序时的输入/输出。 它将从模型协调器特定的格式,如Seldon或KServe,翻译成一组扁平的Python项目,并反之亦然。

class ts.torch_handler.request_envelope.base.BaseEnvelope(handle_fn)[source]

Bases: ABC

所有信封接口。 从这个类派生,替换抽象方法

abstract format_output(data)[source]
handle(data, context)[source]

在这里处理输入请求和响应。

abstract parse_input(data)[source]

ts.torch_handler.request_envelope.body 模块

默认类,用于所有处理器。从请求体中获取数据。

class ts.torch_handler.request_envelope.body.BodyEnvelope(handle_fn)[source]

Bases: BaseEnvelope

从输入数据中获取键“body”,返回一个原始列表

format_output(data)[source]
parse_input(data)[source]

ts.torch_handler.request_envelope.json 模块

使用JSON格式的输入/输出,遵循以下结构: https://www.tensorflow.org/tfx/serving/api_rest

class ts.torch_handler.request_envelope.json.JSONEnvelope(handle_fn)[source]

Bases: BaseEnvelope

实现。以JSON格式捕获批次,并返回同样以JSON格式。

format_output(data)[source]
parse_input(data)[source]

ts.torch_handler.request_envelope.kserve 模块

KServe Envelope 用于处理 Torchserve 内的 KServe 输入请求。

class ts.torch_handler.request_envelope.kserve.KServeEnvelope(handle_fn)[source]

Bases: BaseEnvelope

这个函数用于处理以kserve格式指定的输入请求,并将其转换为Torchserve可读格式。

Parameters:

格式 (数据 - kserve 输入请求列表) –

Returns:

返回以Torchserve格式表示的输入请求列表

Return type:

[列表]

format_output(data)[source]

返回输入请求的预测响应和Captcha解释响应。

Parameters:

输出 (列表) – 输出参数以字典列表的形式提供。

Returns:

响应以预测和解释的列表形式返回

Return type:

(列表)

parse_input(data)[source]

ts.torch_handler.request_envelope.kservev2 模块

KServe Envelope 用于处理 Torchserve 内的 KServe 输入请求。

class ts.torch_handler.request_envelope.kservev2.KServev2Envelope(handle_fn)[source]

Bases: BaseEnvelope

实现。捕获在KServe v2协议格式中的批次,并返回同样在FServing v2协议格式中的批次。

format_output(data)[source]

将Torchserve输出转换为KServe v2响应格式。

参数: data(列表):处理器的Torchserve响应。

返回:KServe v2响应JSON。

“id”: “f0222600-353f-47df-8d9d-c96d96fa894e”, “model_name”: “bert”, “model_version”: “1”, “outputs”: [{

“name”: “input-0”, “shape”: [1], “datatype”: “INT64”, “data”: [2]

}]

}

parse_input(data)[source]

将KServe请求输入翻译为Torchserve期望的数据列表。

参数: data (json): KServe v2 请求输入 JSON。

“inputs”: [{

“name”: “input-0”, “shape”: [37], “datatype”: “INT64”, “data”: [66, 108, 111, 111, 109]

}]

}

返回:数据对象列表。 [ { ‘name’: ‘input-0’, ‘shape’: [5], ‘datatype’: ‘INT64’, ‘data’: [66, 108, 111, 111, 109] }]

模块内容

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源