-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Add Relation DETR #34900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Relation DETR #34900
Conversation
7867221
to
1f0465c
Compare
37959ac
to
d114fc7
Compare
Hi @xiuqhou! Congratulations on the paper, awesome work! And thanks for working on transformers implementation! Feel free to ping me when it's ready for review or if you have any questions! |
14308cf
to
ce63725
Compare
Hi @qubvel Thanks for your support! The code is now ready for review—I'd greatly appreciate it if you could take a look and share your feedback. Please let me know if there’s anything that needs improvement. |
src/transformers/models/relation_detr/configuration_relation_detr.py
Outdated
Show resolved
Hide resolved
src/transformers/models/relation_detr/configuration_relation_detr.py
Outdated
Show resolved
Hide resolved
src/transformers/models/relation_detr/image_processing_relation_detr.py
Outdated
Show resolved
Hide resolved
@ArthurZucker @qubvel @stevhliu Sorry for the late reply! Thanks for your detailed review and suggestions. I have pushed commits according to the reviews except #34900 (comment) about the modular style. CI errors seem not related to changes. |
Hey @xiuqhou thanks for working on the PR and opening the issue! I think we can use the following workaround while the issue is not fixed. def get_numpy_to_framework_fn(arr) -> Callable:
"""
Returns a function that converts a numpy array to the framework of the input array.
Args:
arr (`np.ndarray`): The array to convert.
"""
if isinstance(arr, np.ndarray):
return np.array
elif is_torch_available() and is_torch_tensor(arr):
return torch.tensor
else:
raise RuntimeError("...") Let me know if that works for you! |
@qubvel thanks for your suggestion! I tried to overwrite the function in I have a question about whether this function is necessary. I searched all the code of |
Oh, it might be a redundant function that was copied from one model to another 😄 In that case we can open a separate PR to remove it everywhere |
Hi @daniel-bogdoll Sorry for the late reply! As #36208 has been fixed, I have committed code about the modular style for relation-detr. Now I think the PR is fully prepared for review or merge. Please let me know if there are any remaining improvements needed before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work isolating the differences! 🤗
Need a comment from @yonigozlan but good otherwise!
do_resize = self.do_resize if do_resize is None else do_resize | ||
size = self.size if size is None else size | ||
size = get_size_dict(size=size, default_to_square=False) | ||
resample = self.resample if resample is None else resample | ||
do_rescale = self.do_rescale if do_rescale is None else do_rescale | ||
rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor | ||
do_normalize = self.do_normalize if do_normalize is None else do_normalize | ||
image_mean = self.image_mean if image_mean is None else image_mean | ||
image_std = self.image_std if image_std is None else image_std | ||
do_convert_annotations = ( | ||
self.do_convert_annotations if do_convert_annotations is None else do_convert_annotations | ||
) | ||
do_pad = self.do_pad if do_pad is None else do_pad | ||
pad_size = self.pad_size if pad_size is None else pad_size | ||
format = self.format if format is None else format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @yonigozlan we don't need these anymore do we?
What does this PR do?
This PR adds Relation-DETR as introduced in Relation DETR: Exploring Explicit Position Relation Prior for Object Detection. Checkpoint for Relation-DETR (ResNet50) converted from original repo https://github.com/xiuqhou/Relation-DETR has been uploaded to https://huggingface.co/xiuqhou/relation-detr-resnet50
Related issues in original repo:
xiuqhou/Relation-DETR#25
xiuqhou/Relation-DETR#21
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
TODO:
Who can review?
@amyeroberts @qubvel