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
6678350c
Unverified
Commit
6678350c
authored
Sep 06, 2022
by
Alara Dirik
Committed by
GitHub
Sep 06, 2022
Browse files
fixes bugs to handle non-dict output (#18897)
parent
998a90bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/transformers/models/owlvit/modeling_owlvit.py
src/transformers/models/owlvit/modeling_owlvit.py
+4
-4
No files found.
src/transformers/models/owlvit/modeling_owlvit.py
View file @
6678350c
...
...
@@ -1277,7 +1277,7 @@ class OwlViTForObjectDetection(OwlViTPreTrainedModel):
)
# Resize class token
image_embeds
=
outputs
.
image_embeds
image_embeds
=
outputs
[
-
3
]
new_size
=
tuple
(
np
.
array
(
image_embeds
.
shape
)
-
np
.
array
((
0
,
1
,
0
)))
class_token_out
=
torch
.
broadcast_to
(
image_embeds
[:,
:
1
,
:],
new_size
)
...
...
@@ -1293,11 +1293,11 @@ class OwlViTForObjectDetection(OwlViTPreTrainedModel):
image_embeds
.
shape
[
-
1
],
)
image_embeds
=
image_embeds
.
reshape
(
new_size
)
text_embeds
=
outputs
.
text_embeds
text_embeds
=
outputs
[
-
4
]
# Last hidden states from text and vision transformers
text_model_last_hidden_state
=
outputs
.
text_model_output
.
last_hidden_state
vision_model_last_hidden_state
=
outputs
.
vision_model_output
.
last_hidden_state
text_model_last_hidden_state
=
outputs
[
-
2
][
0
]
vision_model_last_hidden_state
=
outputs
[
-
1
][
0
]
return
(
text_embeds
,
image_embeds
,
text_model_last_hidden_state
,
vision_model_last_hidden_state
)
...
...
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