Skip to content

Adding support for image and table annotation for DocAI #13329

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

bibliofilo
Copy link

Description

Image Annotation is GA in DocAI Layout Parser, these changes were requested internally to update documentation and available code to match and support the offering.

Bugs: b/413675713

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

Copy link

google-cla bot commented Apr 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: documentai Issues related to the Document AI API. labels Apr 29, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @bibliofilo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds support for image and table annotation to the DocAI Layout Parser. The changes include modifications to documentai/snippets/handle_response_sample.py to include example code for enabling image and table annotation, updates to documentai/snippets/handle_response_sample.py to add parameters for enabling image and table annotation, and updates to documentai/snippets/handle_response_sample_test.py to enable image and table annotation in the test case.

Highlights

  • Feature: Adds support for image annotation in DocAI Layout Parser.
  • Feature: Adds support for table annotation in DocAI Layout Parser.
  • Documentation: Updates documentation and code to match and support the new offering.

Changelog

  • documentai/snippets/handle_response_sample.py
    • Added example code for enabling image and table annotation (lines 35-36).
    • Added parameters enable_image_annotation and enable_table_annotation to the process_document_layout_sample function (lines 467-468).
    • Modified process_document_layout_sample to include enable_image_annotation and enable_table_annotation in ProcessOptions (lines 476-477).
  • documentai/snippets/handle_response_sample_test.py
    • Enabled image and table annotation in the test_process_document_layout test case (lines 232-233).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A parser's task, to dissect,
Layouts complex, to inspect.
Images and tables,
Now part of the fables,
Annotations, we now expect.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces support for image and table annotation in DocAI Layout Parser. The changes include updating documentation and code to support this feature. Overall, the changes seem reasonable, but there are a few areas that could be improved for clarity and consistency.

Summary of Findings

  • Inconsistent use of boolean values: The code uses string literals for boolean values in the comments but uses actual boolean values in the function definition. This inconsistency can be confusing.
  • Missing documentation for new parameters: The new parameters enable_image_annotation and enable_table_annotation in the process_document_layout_sample function lack docstrings, which should be added to improve readability and maintainability.

Merge Readiness

The pull request is almost ready for merging. However, the inconsistencies in boolean value usage and the missing documentation for the new parameters should be addressed before merging. Once these issues are resolved, the code should be good to go. I am unable to directly approve the pull request, and users should have others review and approve this code before merging.

bibliofilo and others added 4 commits April 30, 2025 11:51
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: documentai Issues related to the Document AI API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants