Skip to content
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 segformer reshape last stage #15748

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

NielsRogge
Copy link
Contributor

@NielsRogge NielsRogge commented Feb 21, 2022

What does this PR do?

This PR improves SegFormer by removing the reshape_last_stage attribute of the configuration. In fact, this attribute was not needed at all.

Previously, the reshape_last_stage argument was set to False for SegformerForImageClassification models, however it's perfectly fine to reshape afterwards within this head model.

@sgugger I know you'll warn me about this being a breaking change. Here's why I think this change will not have an impact:

  • reshape_last_stage was set to True by default in the configuration. As this PR only removes the ability to set this to False, the only use case in which this might be a breaking change is in case one defined a SegformerModel with config.reshape_last_stage = False. I am not sure if anyone has done this because there are no use cases for this.

@HuggingFaceDocBuilder
Copy link

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@NielsRogge NielsRogge requested a review from sgugger February 21, 2022 10:04
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed a breaking change, and before doing it we should make sure there are no configurations in the wild with this parameter set to False.

I am not sure if anyone has done this because there are no use cases for this.

It's not sufficient, we need to actually be sure before moving forward with this, cc @LysandreJik

src/transformers/models/segformer/modeling_segformer.py Outdated Show resolved Hide resolved
@NielsRogge NielsRogge force-pushed the fix_segformer_reshape_last_stage branch from 932f4a0 to 982ba0b Compare February 25, 2022 09:00
Comment on lines +134 to +135
if "reshape_last_stage" in kwargs:
warnings.warn(DEPRECATION_WARNING, FutureWarning)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning will be issued for the models in the Hub that contain this in their config. So, those configs should be updated to remove that attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, can I remove it after we have a new version of Transformers?

@NielsRogge NielsRogge added the WIP Label your PR/Issue with WIP for some long outstanding Issues/PRs that are work in progress label Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Label your PR/Issue with WIP for some long outstanding Issues/PRs that are work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants