1

我在 Azures 的表单识别器中实现了一个自定义模型。在性能测试中,使用 PDF 和 JPEG 文件进行文本提取,漏洞处理正在 Azure 中执行,大约需要 4.5 秒来响应请求。

我的问题是,有办法改善这些响应时间吗?

这是我的测试代码:

const processFile = (path) => axios({
    url: RECOGNIZER_URL,
    method: "POST",
    headers: {
        "Ocp-Apim-Subscription-Key": RECOGNIZER_KEY,
        'Content-Type': `application/json`
    },
    data: {
        "urlSource": path 
    }
})

const getResult = (location) => axios({
    url: location,
    method: "GET",
    headers: {
        "Ocp-Apim-Subscription-Key": RECOGNIZER_KEY
    },
})

const testOcr = async (imageURL) => {
    console.time('#testOcrTime');

    let res = await processFile(imageURL)
    .then(async response => {
        let result = await getResult(response.headers["operation-location"])
        while(((result.data) || {}).status == "running"){
            result = await getResult(response.headers["operation-location"])
        }
        return result
    })
    .then(response => {console.log(response)
    return response.data.analyzeResult.documents[0].fields})
    .catch(err => console.error(err))

    console.timeEnd('#testOcrTime');
    console.log(res)
    return
}

testOcr()

Azure 的文档

4

0 回答 0