[SegFormer] TensorFlow port#17910
[SegFormer] TensorFlow port#17910gante merged 37 commits intohuggingface:mainfrom sayakpaul:tf-segformer
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
|
Hey @sayakpaul! The code quality error comes from a new release from |
|
@Rocketknight1 @sgugger this PR is now ready for your review. Some things to note:
|
sgugger
left a comment
There was a problem hiding this comment.
Very clean!
The error you mention is caused by the fact that in test_modeling_segformer.py, the config is only imported under an is_torch_available() (which is a mistake). This test file is used by the TF pipeline test to get the small segformer config, hence the errors. Could you just put that import at the top level of this test file? It should resolve the failure.
sgugger
left a comment
There was a problem hiding this comment.
@Rocketknight1 Could you have a look as well?
|
Yes @Rocketknight1's comments are needed here as well. |
|
Yes, I'm sorry! I went deep on a couple of PRs yesterday and today - one for |
Rocketknight1
left a comment
There was a problem hiding this comment.
I just read through the model code, and I'm going to go through the test notes now! Overall, I think the code is very high-quality, and I didn't see any obvious issues anywhere.
If I have one nitpick, it's that I prefer operators like / and > to functions like tf.divide and tf.greater - I think they read more clearly, and they're computationally identical. Still, this is purely an aesthetic preference - if you prefer tf.greater, feel free to keep it that way!
There was a problem hiding this comment.
(Approving model_doc/segformer.mdx only, as per @sayakpaul review request) 👍
|
Thanks, @gante. There were no changes except that. Those were reviewed and approved by @Rocketknight1 and @ydshieh. |
ydshieh
left a comment
There was a problem hiding this comment.
2 tiny naming issues. Thanks @sayakpaul !
| src/transformers/models/speech_encoder_decoder/modeling_speech_encoder_decoder.py | ||
| src/transformers/models/speech_to_text/modeling_speech_to_text.py | ||
| src/transformers/models/speech_to_text_2/modeling_speech_to_text_2.py | ||
| src/transformers/models/segformer/modeling_tf_segformer.py |
There was a problem hiding this comment.
I see that the doc example for semantic segmentation doesn't actually test anything.
You only test something if you include an expected output. We can include the expected output shape.
There was a problem hiding this comment.
Feel free to update the PyTorch one as well
There was a problem hiding this comment.
Both the semantic segmentation classes don't have the add_code_sample_docstrings decorator. Any suggestion on where to best include the expected output shape?
There was a problem hiding this comment.
It should be added below the code snippet. You can find an example here:
There was a problem hiding this comment.
I don't see anything in SegformerForSemanticSegmentation.
There was a problem hiding this comment.
I did include a comment though:
>>> # logits are of shape (batch_size, num_labels, height, width)
Could you provide an example where the expected shape has been provided in the way you're suggesting?
There was a problem hiding this comment.
Nevermind. Added something. Let me know.
There was a problem hiding this comment.
Yes looks good! Should be added for the PyTorch one as well
There was a problem hiding this comment.
NielsRogge
left a comment
There was a problem hiding this comment.
Very clean implementation, thanks a lot! Left some minor comments.
* add: segformer utils and img. classification. * add: segmentation layer. * feat: working implementation of segformer. * chore: remove unused variable. * add test, remaining modifications. * remove: unnecessary files. * add: rest of the files. Co-authored-by: matt <rocketknight1@gmail.com> * chore: remove ModuleList comment. * chore: apply make style. * chore: apply make fixup-copies. * add to check_repo.py * add decode head to IGNORE_NON_TESTED * chore: run make style. * chore: PR comments. * chore: minor changes to model doc. * tests: reduction across samples. * add a note on the space. * sort importats. * fix: reduction in loss computation. * chore: align loss function with that of NER. * chore: correct utils/documentation_tests.txt Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com> * chore: simplify the interpolation of logits in loss computation. * chore: return transposed logits when return_dict=False. * chore: add link to the tf fine-tuning repo. * address pr comments. * address niels's comments. * remove from_pt=True since tf weights are in. * remove comment from pt model. * address niels's comments. Co-authored-by: matt <rocketknight1@gmail.com> Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com>
This PR adds the SegFormer model in TensorFlow (probably the first Transformer-based segmentation model in TensorFlow for which we have PT weights available).
TODOs
call()methods where relevantThe final two points are unrelated to the merging of this PR.
Cc: @deep-diver