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
00247ea0
"docs/vscode:/vscode.git/clone" did not exist on "b91e65afe0f467e24183928bf57d92b2cef4b69f"
Unverified
Commit
00247ea0
authored
Sep 20, 2023
by
Jinho Park
Committed by
GitHub
Sep 20, 2023
Browse files
add bbox input validation (#26294)
parent
24553206
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
src/transformers/models/bros/modeling_bros.py
src/transformers/models/bros/modeling_bros.py
+8
-7
No files found.
src/transformers/models/bros/modeling_bros.py
View file @
00247ea0
...
@@ -877,6 +877,9 @@ class BrosModel(BrosPreTrainedModel):
...
@@ -877,6 +877,9 @@ class BrosModel(BrosPreTrainedModel):
else
:
else
:
raise
ValueError
(
"You have to specify either input_ids or inputs_embeds"
)
raise
ValueError
(
"You have to specify either input_ids or inputs_embeds"
)
if
bbox
is
None
:
raise
ValueError
(
"You have to specify bbox"
)
batch_size
,
seq_length
=
input_shape
batch_size
,
seq_length
=
input_shape
device
=
input_ids
.
device
if
input_ids
is
not
None
else
inputs_embeds
.
device
device
=
input_ids
.
device
if
input_ids
is
not
None
else
inputs_embeds
.
device
...
@@ -924,8 +927,6 @@ class BrosModel(BrosPreTrainedModel):
...
@@ -924,8 +927,6 @@ class BrosModel(BrosPreTrainedModel):
past_key_values_length
=
past_key_values_length
,
past_key_values_length
=
past_key_values_length
,
)
)
bbox_position_embeddings
=
None
if
bbox
is
not
None
:
# if bbox has 2 points (4 float tensors) per token, convert it to 4 points (8 float tensors) per token
# if bbox has 2 points (4 float tensors) per token, convert it to 4 points (8 float tensors) per token
if
bbox
.
shape
[
-
1
]
==
4
:
if
bbox
.
shape
[
-
1
]
==
4
:
bbox
=
bbox
[:,
:,
[
0
,
1
,
2
,
1
,
2
,
3
,
0
,
3
]]
bbox
=
bbox
[:,
:,
[
0
,
1
,
2
,
1
,
2
,
3
,
0
,
3
]]
...
...
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