Why does TIFF/PDF document text detection take so long?

420 views
Skip to first unread message

parth....@corecompete.com

unread,
Oct 2, 2018, 10:03:23 PM10/2/18
to cloud-vision-discuss
I have a multi-frame TIFF image that I sent to the vision API and I was surprised that the request takes ~25 seconds to complete. The image I used had only 2 frames/pages. 

I tested converting the pages of the TIFF to individual PNG and running normal Vision API requests (in serial because, for some reason, "batch" annotate doesn't support batch requests??)  and recombining the output. I was able to do that in ~15-20 seconds. I didn't check the quality of the output response but I'm curious why there is such a huge difference. 

Am I doing something wrong or is this just expected of the Vision API? What are some ways to get this speedy enough to the point where I can safely call it in a Google Cloud Function?

Ji Zhu

unread,
Oct 3, 2018, 1:28:18 AM10/3/18
to parth....@corecompete.com, cloud-vision-discuss

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/840099f5-1ff8-4bfb-88a1-c7d904635c83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

parth....@corecompete.com

unread,
Oct 3, 2018, 11:31:15 AM10/3/18
to cloud-vision-discuss
That makes sense, and I guess the real pain point here is that if I have a large number of mutli-page TIFF/PDFs, there is no way to batch those requests. I'm trying to keep this all >60 seconds in a Cloud function which is why I'm concerned about runtime.


On Wednesday, October 3, 2018 at 1:28:18 AM UTC-4, Ji Zhu wrote:
On Tue, Oct 2, 2018 at 7:03 PM <parth....@corecompete.com> wrote:
I have a multi-frame TIFF image that I sent to the vision API and I was surprised that the request takes ~25 seconds to complete. The image I used had only 2 frames/pages. 

I tested converting the pages of the TIFF to individual PNG and running normal Vision API requests (in serial because, for some reason, "batch" annotate doesn't support batch requests??)  and recombining the output. I was able to do that in ~15-20 seconds. I didn't check the quality of the output response but I'm curious why there is such a huge difference. 

Am I doing something wrong or is this just expected of the Vision API? What are some ways to get this speedy enough to the point where I can safely call it in a Google Cloud Function?

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.

Ji Zhu

unread,
Oct 3, 2018, 4:53:35 PM10/3/18
to parth....@corecompete.com, cloud-vision-discuss

On Wed, Oct 3, 2018 at 8:31 AM <parth....@corecompete.com> wrote:
That makes sense, and I guess the real pain point here is that if I have a large number of mutli-page TIFF/PDFs, there is no way to batch those requests. I'm trying to keep this all >60 seconds in a Cloud function which is why I'm concerned about runtime.


On Wednesday, October 3, 2018 at 1:28:18 AM UTC-4, Ji Zhu wrote:
On Tue, Oct 2, 2018 at 7:03 PM <parth....@corecompete.com> wrote:
I have a multi-frame TIFF image that I sent to the vision API and I was surprised that the request takes ~25 seconds to complete. The image I used had only 2 frames/pages. 

I tested converting the pages of the TIFF to individual PNG and running normal Vision API requests (in serial because, for some reason, "batch" annotate doesn't support batch requests??)  and recombining the output. I was able to do that in ~15-20 seconds. I didn't check the quality of the output response but I'm curious why there is such a huge difference. 

Am I doing something wrong or is this just expected of the Vision API? What are some ways to get this speedy enough to the point where I can safely call it in a Google Cloud Function?

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.

To post to this group, send email to cloud-visi...@googlegroups.com.

parth....@corecompete.com

unread,
Oct 3, 2018, 4:58:45 PM10/3/18
to cloud-vision-discuss
Ok that makes sense, I wasn't clear on that from the documentation. Also, could you elaborate on the "continuous" sending of PDF/TIFF files? Is it possible to dynamically add new requests to an async batch operation?

On Wednesday, October 3, 2018 at 4:53:35 PM UTC-4, Ji Zhu wrote:
On Wed, Oct 3, 2018 at 8:31 AM <parth....@corecompete.com> wrote:
That makes sense, and I guess the real pain point here is that if I have a large number of mutli-page TIFF/PDFs, there is no way to batch those requests. I'm trying to keep this all >60 seconds in a Cloud function which is why I'm concerned about runtime.


On Wednesday, October 3, 2018 at 1:28:18 AM UTC-4, Ji Zhu wrote:
On Tue, Oct 2, 2018 at 7:03 PM <parth....@corecompete.com> wrote:
I have a multi-frame TIFF image that I sent to the vision API and I was surprised that the request takes ~25 seconds to complete. The image I used had only 2 frames/pages. 

I tested converting the pages of the TIFF to individual PNG and running normal Vision API requests (in serial because, for some reason, "batch" annotate doesn't support batch requests??)  and recombining the output. I was able to do that in ~15-20 seconds. I didn't check the quality of the output response but I'm curious why there is such a huge difference. 

Am I doing something wrong or is this just expected of the Vision API? What are some ways to get this speedy enough to the point where I can safely call it in a Google Cloud Function?

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.

Ji Zhu

unread,
Oct 15, 2018, 5:20:13 PM10/15/18
to cloud-vision-discuss
Parth:

You can not add new requests to an existing batch operation but you can create as many new requests as you can, before the previous requests finishes. 

The workflow looks like this:

SEND async request 1 -> store operation id
SEND async request 2 -> store operation id
SEND async request 3 -> store operation id

GET result of request 1
GET result of request 2
GET result of request 3

Jeroen Bobbeldijk

unread,
Nov 6, 2018, 3:51:26 AM11/6/18
to cloud-vision-discuss
I understand this is how it's meant to be used. But we don't have the possibility to batch requests. We provide a real-time data extraction service API.
When someone calls the API with a document, they get the response back in the same request. This works great for images, it takes a couple of seconds at most.
We used to convert PDF's to image, and send that to Vision, it worked fine, but the quality wasn't that good, especially for large documents. So we were happy when the PDF/TIFF option was added, but it's really much slower than image extraction. The amount of time it takes can really differ per scan too.
 
I compared it (these times include converting the image and parsing the Vision result): 
PDF converted to PNG using ImageMagick and using Vision AnnotateImage: ~5s (consistently)
PDF using the AsyncBatchAnnotateFiles: between 20s and 50s

It would be great if something like AnnotateImage could be created for PDF's. It doesn't really matter to me whether it accepts raw bytes or a gs:// URL, both are fine to me. I just want it to be faster and have a more consistent speed.

On Wednesday, October 3, 2018 at 10:53:35 PM UTC+2, Ji Zhu wrote:
On Wed, Oct 3, 2018 at 8:31 AM <parth....@corecompete.com> wrote:
That makes sense, and I guess the real pain point here is that if I have a large number of mutli-page TIFF/PDFs, there is no way to batch those requests. I'm trying to keep this all >60 seconds in a Cloud function which is why I'm concerned about runtime.


On Wednesday, October 3, 2018 at 1:28:18 AM UTC-4, Ji Zhu wrote:
On Tue, Oct 2, 2018 at 7:03 PM <parth....@corecompete.com> wrote:
I have a multi-frame TIFF image that I sent to the vision API and I was surprised that the request takes ~25 seconds to complete. The image I used had only 2 frames/pages. 

I tested converting the pages of the TIFF to individual PNG and running normal Vision API requests (in serial because, for some reason, "batch" annotate doesn't support batch requests??)  and recombining the output. I was able to do that in ~15-20 seconds. I didn't check the quality of the output response but I'm curious why there is such a huge difference. 

Am I doing something wrong or is this just expected of the Vision API? What are some ways to get this speedy enough to the point where I can safely call it in a Google Cloud Function?

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.

George Du

unread,
Nov 6, 2018, 12:55:30 PM11/6/18
to jerb...@gmail.com, cloud-visi...@googlegroups.com
Jeroen, we hear your feedback. We're working on your use case so stay tuned.

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.

To post to this group, send email to cloud-visi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages