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
ef28df05
Commit
ef28df05
authored
Mar 22, 2023
by
Sylvain
Browse files
Fix quality due to ruff release
parent
73fdc8c5
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
24 deletions
+10
-24
src/transformers/pipelines/document_question_answering.py
src/transformers/pipelines/document_question_answering.py
+1
-1
src/transformers/utils/generic.py
src/transformers/utils/generic.py
+1
-1
tests/models/mask2former/test_image_processing_mask2former.py
...s/models/mask2former/test_image_processing_mask2former.py
+1
-3
tests/models/maskformer/test_image_processing_maskformer.py
tests/models/maskformer/test_image_processing_maskformer.py
+1
-3
tests/models/oneformer/test_image_processing_oneformer.py
tests/models/oneformer/test_image_processing_oneformer.py
+1
-3
tests/models/oneformer/test_processor_oneformer.py
tests/models/oneformer/test_processor_oneformer.py
+1
-3
tests/pipelines/test_pipelines_automatic_speech_recognition.py
.../pipelines/test_pipelines_automatic_speech_recognition.py
+2
-5
tests/pipelines/test_pipelines_image_segmentation.py
tests/pipelines/test_pipelines_image_segmentation.py
+2
-5
No files found.
src/transformers/pipelines/document_question_answering.py
View file @
ef28df05
...
...
@@ -418,7 +418,7 @@ class DocumentQuestionAnsweringPipeline(ChunkPipeline):
else
:
model_outputs
=
self
.
model
(
**
model_inputs
)
model_outputs
=
{
k
:
v
for
(
k
,
v
)
in
model_outputs
.
items
()
}
model_outputs
=
dict
(
model_outputs
.
items
()
)
model_outputs
[
"p_mask"
]
=
p_mask
model_outputs
[
"word_ids"
]
=
word_ids
model_outputs
[
"words"
]
=
words
...
...
src/transformers/utils/generic.py
View file @
ef28df05
...
...
@@ -282,7 +282,7 @@ class ModelOutput(OrderedDict):
def
__getitem__
(
self
,
k
):
if
isinstance
(
k
,
str
):
inner_dict
=
{
k
:
v
for
(
k
,
v
)
in
self
.
items
()
}
inner_dict
=
dict
(
self
.
items
()
)
return
inner_dict
[
k
]
else
:
return
self
.
to_tuple
()[
k
]
...
...
tests/models/mask2former/test_image_processing_mask2former.py
View file @
ef28df05
...
...
@@ -298,9 +298,7 @@ class Mask2FormerImageProcessingTest(ImageProcessingSavingTestMixin, unittest.Te
high
=
num_labels
if
is_instance_map
:
labels_expanded
=
list
(
range
(
num_labels
))
*
2
instance_id_to_semantic_id
=
{
instance_id
:
label_id
for
instance_id
,
label_id
in
enumerate
(
labels_expanded
)
}
instance_id_to_semantic_id
=
dict
(
enumerate
(
labels_expanded
))
annotations
=
[
np
.
random
.
randint
(
0
,
high
*
2
,
(
img
.
size
[
1
],
img
.
size
[
0
])).
astype
(
np
.
uint8
)
for
img
in
image_inputs
]
...
...
tests/models/maskformer/test_image_processing_maskformer.py
View file @
ef28df05
...
...
@@ -298,9 +298,7 @@ class MaskFormerImageProcessingTest(ImageProcessingSavingTestMixin, unittest.Tes
high
=
num_labels
if
is_instance_map
:
labels_expanded
=
list
(
range
(
num_labels
))
*
2
instance_id_to_semantic_id
=
{
instance_id
:
label_id
for
instance_id
,
label_id
in
enumerate
(
labels_expanded
)
}
instance_id_to_semantic_id
=
dict
(
enumerate
(
labels_expanded
))
annotations
=
[
np
.
random
.
randint
(
0
,
high
*
2
,
(
img
.
size
[
1
],
img
.
size
[
0
])).
astype
(
np
.
uint8
)
for
img
in
image_inputs
]
...
...
tests/models/oneformer/test_image_processing_oneformer.py
View file @
ef28df05
...
...
@@ -329,9 +329,7 @@ class OneFormerImageProcessingTest(ImageProcessingSavingTestMixin, unittest.Test
high
=
num_labels
if
is_instance_map
:
labels_expanded
=
list
(
range
(
num_labels
))
*
2
instance_id_to_semantic_id
=
{
instance_id
:
label_id
for
instance_id
,
label_id
in
enumerate
(
labels_expanded
)
}
instance_id_to_semantic_id
=
dict
(
enumerate
(
labels_expanded
))
annotations
=
[
np
.
random
.
randint
(
0
,
high
*
2
,
(
img
.
size
[
1
],
img
.
size
[
0
])).
astype
(
np
.
uint8
)
for
img
in
image_inputs
]
...
...
tests/models/oneformer/test_processor_oneformer.py
View file @
ef28df05
...
...
@@ -401,9 +401,7 @@ class OneFormerProcessingTest(unittest.TestCase):
high
=
num_labels
if
is_instance_map
:
labels_expanded
=
list
(
range
(
num_labels
))
*
2
instance_id_to_semantic_id
=
{
instance_id
:
label_id
for
instance_id
,
label_id
in
enumerate
(
labels_expanded
)
}
instance_id_to_semantic_id
=
dict
(
enumerate
(
labels_expanded
))
annotations
=
[
np
.
random
.
randint
(
0
,
high
*
2
,
(
img
.
size
[
1
],
img
.
size
[
0
])).
astype
(
np
.
uint8
)
for
img
in
image_inputs
]
...
...
tests/pipelines/test_pipelines_automatic_speech_recognition.py
View file @
ef28df05
...
...
@@ -56,11 +56,8 @@ if is_torch_available():
@
is_pipeline_test
class
AutomaticSpeechRecognitionPipelineTests
(
unittest
.
TestCase
):
model_mapping
=
{
k
:
v
for
k
,
v
in
(
list
(
MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
.
items
())
if
MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
else
[])
+
(
MODEL_FOR_CTC_MAPPING
.
items
()
if
MODEL_FOR_CTC_MAPPING
else
[])
}
model_mapping
=
dict
((
list
(
MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
.
items
())
if
MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
else
[])
+
(
MODEL_FOR_CTC_MAPPING
.
items
()
if
MODEL_FOR_CTC_MAPPING
else
[]))
def
get_test_pipeline
(
self
,
model
,
tokenizer
,
processor
):
if
tokenizer
is
None
:
...
...
tests/pipelines/test_pipelines_image_segmentation.py
View file @
ef28df05
...
...
@@ -80,14 +80,11 @@ def mask_to_test_readable_only_shape(mask: Image) -> Dict:
@
require_timm
@
require_torch
class
ImageSegmentationPipelineTests
(
unittest
.
TestCase
):
model_mapping
=
{
k
:
v
for
k
,
v
in
(
model_mapping
=
dict
((
list
(
MODEL_FOR_IMAGE_SEGMENTATION_MAPPING
.
items
())
if
MODEL_FOR_IMAGE_SEGMENTATION_MAPPING
else
[]
)
+
(
MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING
.
items
()
if
MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING
else
[])
+
(
MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING
.
items
()
if
MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING
else
[])
}
+
(
MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING
.
items
()
if
MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING
else
[]))
def
get_test_pipeline
(
self
,
model
,
tokenizer
,
processor
):
image_segmenter
=
ImageSegmentationPipeline
(
model
=
model
,
image_processor
=
processor
)
...
...
Prev
1
2
Next
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