使用推理模式时如何删除输入周围的包装器

How can I remove the wrapper around the input when using Inference Schema

当使用推理模式为我的 AzureML 端点自动生成 swagger 文档时(详见 here and here),我看到它在我的 input_sample 周围创建了一个包装器。有没有办法 没有将输入包装在这个“数据”包装器中?

这是我的 score.py 的样子:

input_sample = {
                "id": 123,
                "language": "en"
                "items": [{
                    "item": 1,
                    "desc": "desc"
                }]
            }
output_sample = [{'prediction': 'true', 'predictionConfidence': 0.8279970776764844}]

@input_schema('data', StandardPythonParameterType(input_sample))
@output_schema(StandardPythonParameterType(output_sample))
def run(data):
"""
    {
        data: { --> DON'T WANT this "data" wrapper
                "id": 123,
                "language": "en"
                "items": [{
                    "item": 1,
                    "desc": "desc"
                }]
            }
    }
    """
    try:
        id = data['id']
        ...
        

InferenceSchema 与 Azure 机器学习部署一起使用,然后此包的代码最近根据 MIT 许可在 https://github.com/Azure/InferenceSchema 上发布。所以您可以使用它来创建一个特定于您需要的版本。