Python 表单识别器V2/成本呈爆炸式增长

Python 表单识别器V2/成本呈爆炸式增长,python,azure-cognitive-services,form-recognizer,Python,Azure Cognitive Services,Form Recognizer,作为对ChadZ的回答,这里是我所说的表单识别器的度量。 在我们的测试中,我们检查一个目录中的文件,并按顺序分析它们,等待每个响应,写入结果,获取下一个文件,等等。没有多线程 看看4月份的最大峰值,14次,有15330个电话。如果我们假设在4月份,14次通话需要10秒,这会很快,正常情况下可能需要1分钟,而分析则需要153300秒,即2555分钟或42,58小时。即使分析只需要5秒钟,也需要20多个小时 当然,我可能错了,但目前最好的逻辑解释是,get请求也会被跟踪和计费 原职 我正在使用一个自

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

看看4月份的最大峰值,14次,有15330个电话。如果我们假设在4月份,14次通话需要10秒,这会很快,正常情况下可能需要1分钟,而分析则需要153300秒,即2555分钟或42,58小时。即使分析只需要5秒钟,也需要20多个小时

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

原职 我正在使用一个自定义模型,其中的标签是使用示例标签工具创建的,并使用本页底部的Python表单识别器Async Analyze V2 SDK代码获得结果。 虽然V2中的异步功能比我描述的V1慢得多,但它似乎也要昂贵得多

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.")
不幸的是,这已经不起作用了

    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

我可以确认,在Form Recognitor v2中,GET呼叫不计费。火车电话也是免费的。如果有账单问题,请联系客户服务部

GetAnalyzerResults调用不计费。表单识别器仅对分析过的页面计费,不按事务和请求计费。graph Form Recognitor Metrics显示所有事务和API调用,包括GetAnalyzerResults,但不为这些事务和API调用付费。V1和V2的计费是相同的。如果您遇到账单问题,请联系客户服务


Neta MSFT

感谢Chaz的参与,我已经用指标更新了原始帖子。
    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