【问题标题】:Form Recognizer V2 / Costs are exploding表单识别器 V2 / 成本呈爆炸式增长
【发布时间】:2020-07-30 06:15:50
【问题描述】:

作为对 ChadZ 的回应,这里是表单识别器的度量标准,我正在谈论 Form Recognizer Metrics。 在我们的测试中,我们检查目录中的文件并按顺序分析它们,等待每个响应,写入结果,获取下一个文件等等。没有多线程。

看看 4 月 14 日的最大峰值是 15330 次通话。如果我们假设在 4 月 14 日的每个呼叫需要 10 秒(这会很快,通常可能需要一分钟),那么分析需要 153300 秒,即 2555 分钟或 42.58 小时。即使分析只需要 5 秒,那也将超过 20 小时。

当然我可能是错的,但目前最好的逻辑解释是 get-requests 也会被跟踪和计费。

原帖

我正在使用带有标签的自定义模型(使用示例标签工具创建),并使用此 this 页面底部的“Python Form Recognizer Async Analyze”V2 SDK 代码获取结果。 虽然 V2 中的异步功能比 V1 慢得多(我描述了 here),但它似乎也贵得多。

在 post api 调用后获取结果的原始示例代码如下所示:

n_tries = 15
n_try = 0
wait_sec = 5
max_wait_sec = 60
while n_try < n_tries:
    try:
        resp = get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
        resp_json = resp.json()
        if resp.status_code != 200:
            print("GET analyze results failed:\n%s" % json.dumps(resp_json))
            quit()
        status = resp_json["status"]
        if status == "succeeded":
            print("Analysis succeeded:\n%s" % json.dumps(resp_json))
            quit()
        if status == "failed":
            print("Analysis failed:\n%s" % json.dumps(resp_json))
            quit()
        # Analysis still running. Wait and retry.
        time.sleep(wait_sec)
        n_try += 1
        wait_sec = min(2*wait_sec, max_wait_sec)     
    except Exception as e:
        msg = "GET analyze results failed:\n%s" % str(e)
        print(msg)
        quit()
print("Analyze operation did not complete within the allocated time.")

正如您在原始示例代码中所见,它每 5 秒查看一次以获取结果。

我的问题: 在我看来,不仅要为分析文档的 api 调用付费,而且还要为获取结果的每个 get-request 付费。

自从使用 V2 以来,我们的账单增加了十倍甚至更多。 我们目前处于测试阶段,我们通常每月大约有 400-500 个文档,这些文档在 V1 中被正确跟踪和计费。使用 V2 和上面的示例代码,我们现在有 63690 (!!!!!) 呼叫,每个呼叫都计费,成本正在爆炸式增长。

有人可以确认这种行为吗?

我个人想找回同步操作,其中 api 调用的响应还包含任何文档分析的结果。

    try:
        url = base_url + "/models/" + model_id + "/analyze"
        with open(filepath, "rb") as f:
            data_bytes = f.read()
        response = requests.post(url=url, data=data_bytes, headers=headers)
        return response.json()
    except Exception as e:
        print(str(e))
        return None

不幸的是,这不再起作用了.....

    try:
        response = requests.post(url=post_url, data=data_bytes, headers=headers)  # , params=params)
        if response.status_code != 202:
            return None
        # Success
        get_url = response.headers["operation-location"]
        return form_recognizerv2_getdata(get_url, subscription_key)
    except Exception as e:
        print("POST analyze failed:\n%s" % str(e))
        return None

【问题讨论】:

    标签: python azure-cognitive-services form-recognizer


    【解决方案1】:

    GetAnalyzeResults 调用不计费。表单识别器仅针对已分析页面而非交易和请求计费。 “表单识别器指标”图表显示了您的所有交易和 API 调用,包括 GetAnalyzeResults,但您无需为此付费。 V1 和 V2 的计费方式相同。如果您遇到计费问题,请联系客服。

    Neta-MSFT

    【讨论】:

      【解决方案2】:

      我可以确认,在 Form Recognizer v2 中,GET 调用不计费。火车电话也是免费的。如果有账单问题,请联系客服。

      【讨论】:

      • 感谢 Chaz 的参与,我已经用指标更新了原始帖子。
      猜你喜欢
      • 2020-06-17
      • 1970-01-01
      • 2018-08-07
      • 2017-12-10
      • 2017-09-27
      • 2020-11-23
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      相关资源
      最近更新 更多