gpt4 book ai didi

java - 为什么 EntityAnnotation 类的 getScore() api 始终返回零?

转载 作者:行者123 更新时间:2023-12-02 09:44:58 25 4
gpt4 key购买 nike

我正在使用谷歌视觉 API 进行图像文本检测,它以 JSON 格式给出响应。所以这个响应属于 com.google.cloud.vision.v1.EntityAnnotation.From EntityAnnotation 对象我试图使用 EntityAnnotation 的 getScore() 获取值。但每次它返回 0 并且我期待一些浮点值而不仅仅是 0。有人遇到过类似的问题吗?要了解google Vision文本检测api,可以通过这个https://cloud.google.com/vision/docs/ocr感谢您的帮助。谢谢。

我尝试使用 google Vision api 提供的 LABEL_DETECTION 标记进行相同的输入。为此,它返回 0 到 1 之间的一些值,而不仅仅是零。但它不适用于具有 TEXT_DETECTION 标记的相同输入。我在 windows-10 上测试过

try (FileInputStream inputStream = new FileInputStream(filePath); ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
final ByteString imageBytes = ByteString.readFrom(inputStream);
final Image image = Image.newBuilder().setContent(imageBytes).build();
final Feature feature = Feature.newBuilder().setType(TEXT_DETECTION).build();
final AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feature).setImage(image)
.build();
requests.add(request);

final BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
final List < AnnotateImageResponse > responseList = response.getResponsesList();

result = responseList.get(0).getTextAnnotationsList();
}

final EntityAnnotation annotation = result.get(0);
final Float score = annotation.getScore();

最佳答案

TEXT_DETECTION 没有得分。尝试展开“响应”以查看为 TEXT_DETECTION 返回的属性示例:https://cloud.google.com/vision/docs/ocr

您可能对 DOCUMENT_TEXT_DETECTION 感兴趣和 full_text_annotation ,其中有 confidence .

关于java - 为什么 EntityAnnotation 类的 getScore() api 始终返回零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56734866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com