Add Image Processor Fast RT-DETR#34354
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
molbap
left a comment
There was a problem hiding this comment.
Thanks! Just a few nits - saw you were removing the kwargs validation as well, can we also do that for detr?
There was a problem hiding this comment.
return_segmentation_masks is unused here, could either reuse the one from detr_fast so we have a # Copied from statement here?
There was a problem hiding this comment.
Yes it's a bit weird, return_segmentation_masks is present in several places, but rt-detr does not support segmentation. I added a copied from here, with an Ignore copy for the segmentation part (as otherwise we would need to import/copy a function that would never be used.
EDIT: actually the Ignore copy makes the CI crash, not sure why, so I left it as is for now...
There was a problem hiding this comment.
# Ignore copy does not work like this 😉 forget about it in this case!
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
cb68014 to
2ccaaa0
Compare
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks for working on this!
A few more nits, overall good, IMO all your graph should be placed in the documentation as well and not just on the PR description!
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
# Ignore copy does not work like this 😉 forget about it in this case!
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
src/transformers/models/rt_detr/image_processing_rt_detr_fast.py
Outdated
Show resolved
Hide resolved
b22bf32 to
2960859
Compare
|
@ArthurZucker Refactored DETR and RT-DETR image processor fast to loop as few times as possible over annotations and images, and added some docs! |
|
Does this improve the perf you saw? 😉 |
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks for iterating with me! 🤗
Thank you!
Hmm hard to tell, maybe very slightly when on GPU, as on CPU the potential gains are overshadowed by the processing time. But at least it's cleaner that way! :) |
* add fast image processor rtdetr * add gpu/cpu test and fix docstring * remove prints * add to doc * nit docstring * avoid iterating over images/annotations several times * change torch typing * Add image processor fast documentation
What does this PR do?
Adds a fast image processor for RT-DETR. Follows issue #33810.
This image processor is a result of this work on comparing different image processing method.
The diffs look bad but this PR is almost exclusively made up of
# Copied frombased on the fast image processor for DETR!Implementation
See #34063
Usage
Except for the fact that it only returns torch tensors, this fast processor is fully compatible with the current one.
It can be instantiated through AutoImageProcessor with use_fast=True, or through the Class directly:
Usage is the same as the current processor, except for the
devicekwarg:If
deviceis not specified:Performance gains
batch_size=1.batch_size=8.Tests
Who can review?
@ArthurZucker Pinging you directly as there is almost no "new" code here.