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
cb630ffa
Unverified
Commit
cb630ffa
authored
Nov 02, 2022
by
Alara Dirik
Committed by
GitHub
Nov 02, 2022
Browse files
Update object detection pipeline to use post_process_object_detection methods(#20004)
parent
79c720c0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
src/transformers/pipelines/object_detection.py
src/transformers/pipelines/object_detection.py
+4
-5
No files found.
src/transformers/pipelines/object_detection.py
View file @
cb630ffa
...
...
@@ -93,12 +93,11 @@ class ObjectDetectionPipeline(Pipeline):
def
postprocess
(
self
,
model_outputs
,
threshold
=
0.9
):
target_size
=
model_outputs
[
"target_size"
]
raw_annotations
=
self
.
feature_extractor
.
post_process
(
model_outputs
,
target_size
)
raw_annotations
=
self
.
feature_extractor
.
post_process
_object_detection
(
model_outputs
,
threshold
,
target_size
)
raw_annotation
=
raw_annotations
[
0
]
keep
=
raw_annotation
[
"scores"
]
>
threshold
scores
=
raw_annotation
[
"scores"
][
keep
]
labels
=
raw_annotation
[
"labels"
][
keep
]
boxes
=
raw_annotation
[
"boxes"
][
keep
]
scores
=
raw_annotation
[
"scores"
]
labels
=
raw_annotation
[
"labels"
]
boxes
=
raw_annotation
[
"boxes"
]
raw_annotation
[
"scores"
]
=
scores
.
tolist
()
raw_annotation
[
"labels"
]
=
[
self
.
model
.
config
.
id2label
[
label
.
item
()]
for
label
in
labels
]
...
...
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