Ankur Goyal commited on
Commit
667af5a
1 Parent(s): 73a21c8

Bug fixes + Copy formatting from transformers repo

Browse files
README.md CHANGED
@@ -13,3 +13,9 @@ This is a fine-tuned version of the multi-modal [LayoutLM](https://aka.ms/layout
13
  The LayoutLM model was developed at Microsoft ([paper](https://arxiv.org/abs/1912.13318)) as a general purpose tool for understanding documents. This model is a fine-tuned checkpoint of [LayoutLM-Base-Cased](https://huggingface.co/microsoft/layoutlm-base-uncased), using both the [SQuAD2.0](https://huggingface.co/datasets/squad_v2) and [DocVQA](https://www.docvqa.org/) datasets.
14
 
15
  ## Getting started with the model
 
 
 
 
 
 
 
13
  The LayoutLM model was developed at Microsoft ([paper](https://arxiv.org/abs/1912.13318)) as a general purpose tool for understanding documents. This model is a fine-tuned checkpoint of [LayoutLM-Base-Cased](https://huggingface.co/microsoft/layoutlm-base-uncased), using both the [SQuAD2.0](https://huggingface.co/datasets/squad_v2) and [DocVQA](https://www.docvqa.org/) datasets.
14
 
15
  ## Getting started with the model
16
+
17
+
18
+
19
+ ## About us
20
+
21
+ This model was created by the team at [Impira](https://www.impira.com/).
pipeline_document_question_answering.py CHANGED
@@ -1,4 +1,4 @@
1
- # NOTE: This code is currently under review for inclusion in the main
2
  # huggingface/transformers repository:
3
  # https://github.com/huggingface/transformers/pull/18414
4
  from typing import List, Optional, Tuple, Union
@@ -189,7 +189,9 @@ class DocumentQuestionAnsweringPipeline(Pipeline):
189
  - **answer** (`str`) -- The answer to the question.
190
  """
191
  if isinstance(question, str):
192
- inputs = {"question": question, "image": image, "word_boxes": word_boxes}
 
 
193
  else:
194
  inputs = image
195
  return super().__call__(inputs, **kwargs)
 
1
+ # NOTE: This code is currently under review for inclusion in the main
2
  # huggingface/transformers repository:
3
  # https://github.com/huggingface/transformers/pull/18414
4
  from typing import List, Optional, Tuple, Union
 
189
  - **answer** (`str`) -- The answer to the question.
190
  """
191
  if isinstance(question, str):
192
+ inputs = {"question": question, "image": image}
193
+ if word_boxes is not None:
194
+ inputs["word_boxes"] = word_boxes
195
  else:
196
  inputs = image
197
  return super().__call__(inputs, **kwargs)
pyproject.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [tool.black]
2
+ line-length = 119
3
+ target-version = ['py35']
qa_helpers.py CHANGED
@@ -1,4 +1,4 @@
1
- # NOTE: This code is currently under review for inclusion in the main
2
  # huggingface/transformers repository:
3
  # https://github.com/huggingface/transformers/pull/18414
4
 
@@ -15,6 +15,7 @@ if is_vision_available():
15
  from PIL import Image
16
 
17
  from transformers.image_utils import load_image
 
18
  VISION_LOADED = True
19
  else:
20
  Image = None
@@ -24,10 +25,12 @@ else:
24
  TESSERACT_LOADED = False
25
  if is_pytesseract_available():
26
  import pytesseract
 
27
  TESSERACT_LOADED = True
28
  else:
29
  pytesseract = None
30
 
 
31
  def decode_spans(
32
  start: np.ndarray, end: np.ndarray, topk: int, max_answer_len: int, undesired_tokens: np.ndarray
33
  ) -> Tuple:
 
1
+ # NOTE: This code is currently under review for inclusion in the main
2
  # huggingface/transformers repository:
3
  # https://github.com/huggingface/transformers/pull/18414
4
 
 
15
  from PIL import Image
16
 
17
  from transformers.image_utils import load_image
18
+
19
  VISION_LOADED = True
20
  else:
21
  Image = None
 
25
  TESSERACT_LOADED = False
26
  if is_pytesseract_available():
27
  import pytesseract
28
+
29
  TESSERACT_LOADED = True
30
  else:
31
  pytesseract = None
32
 
33
+
34
  def decode_spans(
35
  start: np.ndarray, end: np.ndarray, topk: int, max_answer_len: int, undesired_tokens: np.ndarray
36
  ) -> Tuple:
setup.cfg ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [isort]
2
+ default_section = FIRSTPARTY
3
+ ensure_newline_before_comments = True
4
+ force_grid_wrap = 0
5
+ include_trailing_comma = True
6
+ known_first_party = transformers
7
+
8
+ line_length = 119
9
+ lines_after_imports = 2
10
+ multi_line_output = 3
11
+ use_parentheses = True
12
+
13
+ [flake8]
14
+ ignore = E203, E501, E741, W503, W605
15
+ max-line-length = 119
16
+
17
+ [tool:pytest]
18
+ doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS