Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLabelAnnotationsList is returning empty map #2031

Closed
buddhapuneeth opened this issue May 3, 2017 · 5 comments
Closed

getLabelAnnotationsList is returning empty map #2031

buddhapuneeth opened this issue May 3, 2017 · 5 comments
Assignees
Labels
api: vision Issues related to the Cloud Vision API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@buddhapuneeth
Copy link

In which file did you encounter the issue?

java-docs-samples/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java

Did you change the file? If so, how?

no. running on Tomcat 7 in java 1.8

Describe the issue

EntityAnnotation annotation : res.getLabelAnnotationsList()
there are no items in that. It was working fine some time back, now stopped working. I'm using:
com.google.cloud
google-cloud-vision
0.17.1-beta

@shinfan shinfan added api: vision Issues related to the Cloud Vision API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels May 8, 2017
@shinfan
Copy link
Contributor

shinfan commented May 8, 2017

For now gRPC does not support Tomcat well. We should update the doc of supported env #2039

@shinfan shinfan added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label May 8, 2017
@gguuss
Copy link
Contributor

gguuss commented May 8, 2017

I'll see if what I can repro on Tomcat, for my tests, I'm always seeing labels returned from label annotation queries.

@garrettjonesgoogle
Copy link
Member

@gguuss did you get a chance to repro?

@garrettjonesgoogle garrettjonesgoogle added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 31, 2017
@garrettjonesgoogle garrettjonesgoogle changed the title getLabelAnnotationsList is returing empty map getLabelAnnotationsList is returning empty map May 31, 2017
@gguuss
Copy link
Contributor

gguuss commented May 31, 2017

I was actually unable to repro. The following code successfully performs a request from a JSP on tomcat. All you need to do is put a jar containing all the client library dependencies in to the tomcat /lib folder from where you're serving (e.g. mvn compile assembly:single for the cloud-client sample and copy target/vision-google-cloud-samples-1.0.0-jar-with-dependencies.jar into /lib/ for your Tomcat directory. Of note, I'm using Tomcat 8.5.14 installed from homebrew on OSX.

<%@ page import="com.google.cloud.vision.spi.v1.ImageAnnotatorClient, com.google.cloud.vision.spi.v1.ImageAnnotatorSettings, com.google.cloud.vision.v1.AnnotateImageRequest, com.google.cloud.vision.v1.AnnotateImageResponse, com.google.cloud.vision.v1.BatchAnnotateImagesResponse, com.google.cloud.vision.v1.Block, com.google.cloud.vision.v1.ColorInfo, com.google.cloud.vision.v1.CropHint, com.google.cloud.vision.v1.CropHintsAnnotation, com.google.cloud.vision.v1.DominantColorsAnnotation, com.google.cloud.vision.v1.EntityAnnotation, com.google.cloud.vision.v1.FaceAnnotation, com.google.cloud.vision.v1.Feature, com.google.cloud.vision.v1.Feature.Type, com.google.cloud.vision.v1.Image, com.google.cloud.vision.v1.ImageSource, com.google.cloud.vision.v1.LocationInfo, com.google.cloud.vision.v1.Page, com.google.cloud.vision.v1.Paragraph, com.google.cloud.vision.v1.SafeSearchAnnotation, com.google.cloud.vision.v1.Symbol, com.google.cloud.vision.v1.TextAnnotation, com.google.cloud.vision.v1.WebDetection, com.google.cloud.vision.v1.WebDetection.WebEntity, com.google.cloud.vision.v1.WebDetection.WebImage, com.google.cloud.vision.v1.WebDetection.WebPage, com.google.cloud.vision.v1.Word, com.google.protobuf.ByteString, org.threeten.bp.Duration, java.io.FileInputStream, java.io.IOException, java.io.PrintStream, java.util.ArrayList, java.util.List" %>
<% String gcsPath = "gs://cloud-samples-tests/vision/face_no_surprise.jpg"; %>
<html>
  <head>
    <title>
      I know JSP: <%=request.getServletContext().getServerInfo()%>
    </title>
  </head>
  <body>
    <h1>Hello Vision!</h1>
    This is where the action happen.
<hr>
Performing face detection on <%=gcsPath%>
<%
    List<AnnotateImageRequest> reqs = new ArrayList<>();

    ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder =
        ImageAnnotatorSettings.defaultBuilder();
    imageAnnotatorSettingsBuilder
        .batchAnnotateImagesSettings()
        .getRetrySettingsBuilder()
        .setTotalTimeout(Duration.ofSeconds(30));
    ImageAnnotatorSettings settings = imageAnnotatorSettingsBuilder.build();

    ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
    Image img = Image.newBuilder().setSource(imgSource).build();
    Feature feat = Feature.newBuilder().setType(Type.FACE_DETECTION).build();

    AnnotateImageRequest req =
        AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
    reqs.add(req);

    ImageAnnotatorClient client = ImageAnnotatorClient.create(settings);
    BatchAnnotateImagesResponse resp = client.batchAnnotateImages(reqs);
    List<AnnotateImageResponse> responses = resp.getResponsesList();

    for (AnnotateImageResponse res : responses) {
      if (res.hasError()) {
        %>Error!!!! <%=res.getError().getMessage()%><%
        break;
      }

      // For full list of available annotations, see http://g.co/cloud/vision/docs
      for (FaceAnnotation annotation : res.getFaceAnnotationsList()) {
        %><p>Anger: <%=annotation.getAngerLikelihood()%><%
        %><p>Joy: <%=annotation.getSurpriseLikelihood()%><%
        %><p>Poly: <%=annotation.getBoundingPoly()%><%
      }
    }
%>
  </body>
</html>

@garrettjonesgoogle
Copy link
Member

Closing out since we are unable to repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants