Skip to content

perf(ocr): build Google Vision layouts from one checked response - #4826

Draft
Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/google-vision-single-request-20261121
Draft

Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/google-vision-single-request-20261121

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

get_layout_elements_from_image() sends the same PNG to Google Vision twice: once for regions and once for text. Both are present in one annotation response. The current paths also ignore an error status in that response and can silently report an empty document.

Centralize one checked annotation request and derive both layout inputs from it. Text-only and region-only calls use the same validation, preserving the PNG payload and language hints. A nonzero service status raises a descriptive error before the response is interpreted as OCR output.

Validation

  • A client-call regression measures 2 requests on base versus 1 after the change for one layout extraction, checking PNG bytes and language hints.
  • Three public entry-point regressions verify permission-error responses raise instead of returning empty output.
  • Base revision: 4 failures. Final: 4 passed.
  • Tests use real response protobufs and a mocked client; no service requests or credentials are used.
  • Repository Ruff 0.15.10 lint and format checks pass.

Draft pending the full repository test gate.

Checklist

  • Conventional user-facing title.
  • Maintainer: apply the appropriate category label.
  • Full repository test gate.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant