简体   繁体   English

如何提高谷歌云视觉api的处理速度?

[英]How to improve processing speed of google cloud vision api?

On my website I am taking a photo and storing it to Google Storage and right after saving the url (of the location in storage) to firestore database.在我的网站上,我正在拍摄一张照片并将其存储到 Google 存储中,并且在将 url(存储中的位置)保存到 firestore 数据库之后。 Upon the creation of a document in firestore, firebase functions are called, which use vision api to detect text on the image (the vision api uses the link to the image from firestore).在 Firestore 中创建文档后,调用 firebase 函数,这些函数使用视觉 api 检测图像上的文本(视觉 api 使用来自 firestore 的图像的链接)。 This process is taking quite a lot of time (5 seconds when it's quick, sometimes also over 10), so I was wondering whether there is a way to optimise this process to improve the processing speed.这个过程需要相当长的时间(快速时 5 秒,有时甚至超过 10 秒),所以我想知道是否有办法优化这个过程以提高处理速度。

Google Cloud Vision can receive parallel requests, and would get it done faster. Google Cloud Vision 可以接收并行请求,并且可以更快地完成。 You can also include more than 1 image in a single annotate request .您还可以在单个注释请求中包含多个图像。

If you just want to send the requests into the API fast and retrieve the results sometime later, you could use asyncBatchAnnotate .如果您只想将请求快速发送到 API 并稍后检索结果,您可以使用asyncBatchAnnotate

You may want to check this example and then use threads in your preferred programming language for sending/receiving parallel operations.您可能需要检查此示例,然后使用首选编程语言中的线程来发送/接收并行操作。

Additionally, there's a guide on best practices for optimizing the perfomance of the Cloud Functions that you can also check and follow.此外,您还可以查看并遵循优化云功能性能的最佳实践指南。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM