问题描述:

I cross posted this to the google group for Cloud Vision...

and have added some additional findings.

Here are all of the specifics I believe are relevant:

  • Using VB.NET 2010
  • Using service account authentication
  • Limited to .NET 4.0
  • Using these Google libs: Google.Api v1.10.0, Google.Apis.Auth v1.10.0, Google.Apis.Vision.v1 v1.12.0.45
  • Performing Text and Safe Search Analysis
  • Passing image content in request (not using Google Drive)

When just sending through 4 images or so per request, things work as expected... I get responses, and annotations.

If I up the number of images to 8 files per request, The response back from Execute contains no results.. No errors, no exceptions either.

Just a Google.Apis.Vision.v1.Data.BatchAnnotateImagesResponse object with zero responses. Using a network traffic monitoring tool, I see the connection to google vision - and the service returns a 200 server response. But is otherwise empty.

Further research showed that I'm able to successfully send about a total 1MB of base64 content to the API per overall request Anything more, I get the odd condition described.

According to the API documentation, the following limits apply to Google Cloud Vision API usage.

I'm not seeing any way I could be breaking the documented limits: 8 files per each request, total way less than 8MB, and no file even close to 4MB.

Any thoughts as to what I might be missing? Are the documented limitations below correct?

  • MB per image 4 MB
  • MB per request 8 MB
  • Requests per second 10
  • Requests per feature per day 700,000
  • Requests per feature per month 20,000,000
  • Images per second 8
  • Images per request 16

网友答案:

Turns out, there is a bug in Google's implementation of gzip compression on the request... I'm not sure if the API only applies gzip compression when the request size hits a certain threshold, or if the implementation bugs works for small requests, but not for large ones.

Here is how I solved my problem (Disabling GZIP is the key):

    Private Function GetAnalysisService() As VisionService
        Dim credential As GoogleCredential = Nothing

        credential = GoogleCredential.GetApplicationDefaultAsync().Result

        If credential.IsCreateScopedRequired Then
            credential = credential.CreateScoped(New String()  {VisionService.Scope.CloudPlatform})
        End If

        Dim ServiceInitializer = New VisionService.Initializer With {.ApplicationName = "TF Image Analysis", .HttpClientInitializer = credential}

        ServiceInitializer.GZipEnabled = False

        Return New VisionService(ServiceInitializer)
    End Function
相关阅读:
Top