From c60dd98e87373e7f0f5af29f3d49411c2e81fb69 Mon Sep 17 00:00:00 2001 From: NielsRogge <48327001+NielsRogge@users.noreply.github.com> Date: Fri, 2 Sep 2022 14:48:19 +0200 Subject: [PATCH] [LayoutLM] Add clarification to docs (#18716) * Add clarification * Add another clarification * Apply suggestion Co-authored-by: Niels Rogge --- docs/source/en/model_doc/layoutlm.mdx | 3 ++- .../models/layoutlmv2/feature_extraction_layoutlmv2.py | 3 ++- .../models/layoutlmv3/feature_extraction_layoutlmv3.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/source/en/model_doc/layoutlm.mdx b/docs/source/en/model_doc/layoutlm.mdx index e463c67d91..257a4600c8 100644 --- a/docs/source/en/model_doc/layoutlm.mdx +++ b/docs/source/en/model_doc/layoutlm.mdx @@ -67,7 +67,8 @@ occurs. Those can be obtained using the Python Image Library (PIL) library for e ```python from PIL import Image -image = Image.open("name_of_your_document - can be a png file, pdf, etc.") +# Document can be a png, jpg, etc. PDFs must be converted to images. +image = Image.open(name_of_your_document).convert("RGB") width, height = image.size ``` diff --git a/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py b/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py index cd05819e47..5ccf4d7842 100644 --- a/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py +++ b/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py @@ -168,7 +168,8 @@ class LayoutLMv2FeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionM >>> from transformers import LayoutLMv2FeatureExtractor >>> from PIL import Image - >>> image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB") + >>> # Document can be a png, jpg, etc. PDFs must be converted to images. + >>> image = Image.open(name_of_your_document).convert("RGB") >>> # option 1: with apply_ocr=True (default) >>> feature_extractor = LayoutLMv2FeatureExtractor() diff --git a/src/transformers/models/layoutlmv3/feature_extraction_layoutlmv3.py b/src/transformers/models/layoutlmv3/feature_extraction_layoutlmv3.py index 2d771a2790..6d0d5d1a26 100644 --- a/src/transformers/models/layoutlmv3/feature_extraction_layoutlmv3.py +++ b/src/transformers/models/layoutlmv3/feature_extraction_layoutlmv3.py @@ -179,7 +179,8 @@ class LayoutLMv3FeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionM >>> from transformers import LayoutLMv3FeatureExtractor >>> from PIL import Image - >>> image = Image.open("name_of_your_document - can be a png file, pdf, etc.").convert("RGB") + >>> # Document can be a png, jpg, etc. PDFs must be converted to images. + >>> image = Image.open(name_of_your_document).convert("RGB") >>> # option 1: with apply_ocr=True (default) >>> feature_extractor = LayoutLMv3FeatureExtractor()