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
307cf3a2
"vscode:/vscode.git/clone" did not exist on "51ae2032901b0125665a17711dad39cd6542696c"
Unverified
Commit
307cf3a2
authored
Nov 27, 2023
by
yhshin11
Committed by
GitHub
Nov 27, 2023
Browse files
Fix oneformer instance segmentation RuntimeError (#27725)
parent
b09912c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/models/oneformer/image_processing_oneformer.py
...ansformers/models/oneformer/image_processing_oneformer.py
+2
-1
No files found.
src/transformers/models/oneformer/image_processing_oneformer.py
View file @
307cf3a2
...
...
@@ -1167,6 +1167,7 @@ class OneFormerImageProcessor(BaseImageProcessor):
class_queries_logits
=
outputs
.
class_queries_logits
# [batch_size, num_queries, num_classes+1]
masks_queries_logits
=
outputs
.
masks_queries_logits
# [batch_size, num_queries, height, width]
device
=
masks_queries_logits
.
device
batch_size
=
class_queries_logits
.
shape
[
0
]
num_queries
=
class_queries_logits
.
shape
[
1
]
num_classes
=
class_queries_logits
.
shape
[
-
1
]
-
1
...
...
@@ -1177,7 +1178,7 @@ class OneFormerImageProcessor(BaseImageProcessor):
for
i
in
range
(
batch_size
):
# [Q, K]
scores
=
torch
.
nn
.
functional
.
softmax
(
class_queries_logits
[
i
],
dim
=-
1
)[:,
:
-
1
]
labels
=
torch
.
arange
(
num_classes
).
unsqueeze
(
0
).
repeat
(
num_queries
,
1
).
flatten
(
0
,
1
)
labels
=
torch
.
arange
(
num_classes
,
device
=
device
).
unsqueeze
(
0
).
repeat
(
num_queries
,
1
).
flatten
(
0
,
1
)
# scores_per_image, topk_indices = scores.flatten(0, 1).topk(self.num_queries, sorted=False)
scores_per_image
,
topk_indices
=
scores
.
flatten
(
0
,
1
).
topk
(
num_queries
,
sorted
=
False
)
...
...
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