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
9a35a7b9
Unverified
Commit
9a35a7b9
authored
Jun 01, 2023
by
fxmarty
Committed by
GitHub
Jun 01, 2023
Browse files
Effectively allow `encoder_outputs` input to be a tuple in pix2struct (#23932)
consistentcy
parent
9603ef89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
src/transformers/models/pix2struct/modeling_pix2struct.py
src/transformers/models/pix2struct/modeling_pix2struct.py
+6
-0
No files found.
src/transformers/models/pix2struct/modeling_pix2struct.py
View file @
9a35a7b9
...
...
@@ -1734,6 +1734,12 @@ class Pix2StructForConditionalGeneration(Pix2StructPreTrainedModel):
output_hidden_states
=
output_hidden_states
,
return_dict
=
return_dict
,
)
elif
return_dict
and
not
isinstance
(
encoder_outputs
,
BaseModelOutput
):
encoder_outputs
=
BaseModelOutput
(
last_hidden_state
=
encoder_outputs
[
0
],
hidden_states
=
encoder_outputs
[
1
]
if
len
(
encoder_outputs
)
>
1
else
None
,
attentions
=
encoder_outputs
[
2
]
if
len
(
encoder_outputs
)
>
2
else
None
,
)
hidden_states
=
encoder_outputs
[
0
]
...
...
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