Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
fca66abe
Unverified
Commit
fca66abe
authored
Dec 15, 2022
by
Nicolas Patry
Committed by
GitHub
Dec 15, 2022
Browse files
Fixing object detection with `layoutlm` (#20776)
* Fixing object detection with layoutlm. * Fixup.
parent
8891193e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
src/transformers/pipelines/__init__.py
src/transformers/pipelines/__init__.py
+6
-1
tests/pipelines/test_pipelines_object_detection.py
tests/pipelines/test_pipelines_object_detection.py
+3
-11
No files found.
src/transformers/pipelines/__init__.py
View file @
fca66abe
...
@@ -378,7 +378,12 @@ NO_TOKENIZER_TASKS = set()
...
@@ -378,7 +378,12 @@ NO_TOKENIZER_TASKS = set()
# any tokenizer/feature_extractor might be use for a given model so we cannot
# any tokenizer/feature_extractor might be use for a given model so we cannot
# use the statically defined TOKENIZER_MAPPING and FEATURE_EXTRACTOR_MAPPING to
# use the statically defined TOKENIZER_MAPPING and FEATURE_EXTRACTOR_MAPPING to
# see if the model defines such objects or not.
# see if the model defines such objects or not.
MULTI_MODEL_CONFIGS
=
{
"SpeechEncoderDecoderConfig"
,
"VisionEncoderDecoderConfig"
,
"VisionTextDualEncoderConfig"
}
MULTI_MODEL_CONFIGS
=
{
"SpeechEncoderDecoderConfig"
,
"VisionEncoderDecoderConfig"
,
"VisionTextDualEncoderConfig"
,
"LayoutLMConfig"
,
}
for
task
,
values
in
SUPPORTED_TASKS
.
items
():
for
task
,
values
in
SUPPORTED_TASKS
.
items
():
if
values
[
"type"
]
==
"text"
:
if
values
[
"type"
]
==
"text"
:
NO_FEATURE_EXTRACTOR_TASKS
.
add
(
task
)
NO_FEATURE_EXTRACTOR_TASKS
.
add
(
task
)
...
...
tests/pipelines/test_pipelines_object_detection.py
View file @
fca66abe
...
@@ -256,17 +256,9 @@ class ObjectDetectionPipelineTests(unittest.TestCase, metaclass=PipelineTestCase
...
@@ -256,17 +256,9 @@ class ObjectDetectionPipelineTests(unittest.TestCase, metaclass=PipelineTestCase
"https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"
"https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"
)
)
self
.
assertEqual
(
self
.
assertEqual
(
nested_simplify
(
outputs
,
decimals
=
4
),
nested_simplify
(
outputs
,
decimals
=
3
),
[
[
{
{
"score"
:
0.998
,
"label"
:
"B-QUESTION"
,
"box"
:
{
"xmin"
:
462
,
"ymin"
:
234
,
"xmax"
:
508
,
"ymax"
:
249
}},
"score"
:
0.9982
,
{
"score"
:
0.999
,
"label"
:
"I-QUESTION"
,
"box"
:
{
"xmin"
:
489
,
"ymin"
:
286
,
"xmax"
:
519
,
"ymax"
:
301
}},
"label"
:
"B-QUESTION"
,
"box"
:
{
"xmin"
:
654
,
"ymin"
:
165
,
"xmax"
:
719
,
"ymax"
:
719
},
},
{
"score"
:
0.9982
,
"label"
:
"I-QUESTION"
,
"box"
:
{
"xmin"
:
691
,
"ymin"
:
202
,
"xmax"
:
735
,
"ymax"
:
735
},
},
],
],
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment