快捷方式

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]

基類: 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]

基類: 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]

基類: 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]

基類: BaseEnvelope

此函式用於處理以 kserve 格式指定的輸入請求,並將其轉換為 Torchserve 可讀格式。

引數

格式 (data - 以 kserve 格式表示的輸入請求列表) –

返回

返回 Torchserve 格式的輸入請求列表

返回型別

[list]

format_output(data)[source]

返回輸入請求的預測響應和 captum 解釋響應。

引數

outputs (List) – outputs 引數是字典列表的形式。

返回

響應作為預測和解釋的列表返回

返回型別

(list)

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]

基類: BaseEnvelope

實現。以 KServe v2 協議格式捕獲批次,也以 KServe v2 協議格式返回。

format_output(data)[source]

將 Torchserve 輸出轉換為 KServe v2 響應格式。

引數: data (list): 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]

}]

}

}]

將 KServe 請求輸入轉換為 Torchserve 所需的資料列表。

引數: data (json): KServe v2 請求輸入 json。{

“inputs”: [{

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

}]

}

}] Returns: list of data objects. [{ ‘name’: ‘input-0’, ‘shape’: [5], ‘datatype’: ‘INT64’, ‘data’: [66, 108, 111, 111, 109] }]

模組內容

文件

訪問 PyTorch 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源