-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Fix BeitFeatureExtractor postprocessing #19119
Conversation
resized = self.resize(image=semantic_segmentation[idx], size=target_sizes[idx]) | ||
resized_maps.append(resized) | ||
|
||
semantic_segmentation = [torch.Tensor(np.array(image)).to(torch.int64) for image in resized_maps] |
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.
semantic_segmentation = [torch.Tensor(np.array(image)).to(torch.int64) for image in resized_maps] | |
semantic_segmentation = [torch.Tensor(np.array(image)).long() for image in resized_maps] |
This should also work :)
None, predictions will not be resized. | ||
Returns: | ||
semantic_segmentation: `List[torch.Tensor]` of length `batch_size`, where each item is a semantic | ||
segmentation map of shape (w, h) corresponding to the target_sizes entry (if `target_sizes` is specified). |
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.
To me it's a bit counterintuitive to output (w, h) if we ask the target_sizes to be (h, w)
=> so I'd use the same format for both
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.
Agreed, just fixed this
semantic_segmentation = semantic_segmentation.numpy() | ||
|
||
for idx in range(len(semantic_segmentation)): | ||
resized = self.resize(image=semantic_segmentation[idx], size=target_sizes[idx]) |
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.
As discussed offline, please use nn.functional.interpolate
here.
resized = nn.functional.interpolate(semantic_segmentation[idx],
size=target_sizes[idx],
mode='bilinear',
align_corners=False)
The documentation is not available anymore as the PR was closed or merged. |
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.
LGTM, although it will require an update when supporting the TF model.
Hey @alaradirik, please also ping a core maintainer for review before merging PRs. |
* return post-processed segmentations as list, add test * use torch to resize logits * fix assertion error if no target_size is specified
What does this PR do?
BeitFeatureExtractor.post_process_semantic_segmentation()
assertion error when notarget_sizes
argument is providedBefore submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.