TensorFlow MobileViT#18555
TensorFlow MobileViT#18555sgugger merged 26 commits intohuggingface:mainfrom sayakpaul:feat/tf-mobilevit
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
Co-authored-by: Amy <aeroberts4444@gmail.com>
Coo-authored-by: Yih <2521628+ydshieh@users.noreply.github.com>
gante
left a comment
There was a problem hiding this comment.
Thank you for the TF implementation of MobileViT 🙌 The TFLite demo is great, especially because it should be covered by our doctests 🚀
In addition to the comments throughout the code, I have the following notes:
- I will share the instructions to open the Hub PR when this PR is approved by all (everyone has permission to do it now 🎉 )
- The
trainingargument is missing in the layer'scall(and in places like thedropoutcalls)
|
Didn't realize that re-requesting a review from @gante would result in removing @amyeroberts and @sgugger from the reviewer list. Please know that it was completely unintentional. |
|
@sayakpaul no worries :) |
gante
left a comment
There was a problem hiding this comment.
Thank you for the changes 🔥
| patch_width, patch_height = self.patch_width, self.patch_height | ||
| patch_area = tf.cast(patch_width * patch_height, "int32") | ||
|
|
||
| batch_size, orig_height, orig_width, channels = shape_list(features) |
There was a problem hiding this comment.
| batch_size, orig_height, orig_width, channels = shape_list(features) | |
| batch_size, orig_height, orig_width, channels = tf.shape(features) |
There was a problem hiding this comment.
Having it in one line leads to:
OperatorNotAllowedInGraphError: Iterating over a symbolic
tf.Tensoris not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
That's why I separated it.
| def test_attention_outputs(self): | ||
| pass | ||
|
|
||
| @unittest.skip("Test was written for TF 1.x and isn't really relevant here") |
There was a problem hiding this comment.
If this is the case - should it even be in the test suite? cc @gante
There was a problem hiding this comment.
Nope, me and @Rocketknight1 talked about it a few weeks ago. We should remove this test, it's heavy and the only new thing it tests is that we can build a functional TF model with the model class (which it's kinda obvious we can)
There was a problem hiding this comment.
I assume it will be phased out in a separate PR from the main TF testing suite?
There was a problem hiding this comment.
Ofc, as a separate PR 👍 Leave it be as it is in this PR :)
|
Thanks for another great model addition @sayakpaul ! |
|
@sayakpaul assuming it is passing the slow tests, it is ready for the TF weights. The super complex instructions to do it are as follows:
|
|
Super simple (complex?) question: What is the format of |
|
The same as the model name on the hub, e.g. this model would be P.S.: I edited the comment above with a 3rd step :D |
This might be due to the |
Very well! If we need to deal with the inconsistencies between |
|
@gante WDYT? |
|
@sayakpaul regarding the PR, all good on my end, but we still need approval from @sgugger :D As for the |
On it, sir! |
|
Please take note of the changes in 32cfd30. Initially, when I tested TFLite conversion it didn't require any spec for SELECT operations but now they're failing with a specification for the SELECT ops. What is more surprising is that the TFLite interpreter is treating |
sgugger
left a comment
There was a problem hiding this comment.
Thanks a lot for your PR! Left a couple of nits then we can merge this.
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
|
(retriggered failing job, seems like a spurious failure) |
|
Yeah probably nothing related to the PR? |
|
The build doc job failure is not spurious. There seems to be a problem with an example bloc introduced by this PR. |
|
Let me see if removing comments from the example block does the trick. Because when the job wasn't failing the example block didn't have any comments. |
|
No, it didn't help :( Any suggestions to try out? |
| You can use the following code to convert a MobileViT checkpoint (be it image classification or semantic segmentation) to generate a | ||
| TensorFlow Lite model: | ||
|
|
||
| ```py |
There was a problem hiding this comment.
could it be because the example is indented?
There was a problem hiding this comment.
Looks like it, for some reason. The failure seems to disappear locally when I remove it. In any case its place is probably closer to the TF models doc?
There was a problem hiding this comment.
This was the culprit it seems :3
My bad :D read the failure bottom to top, so I didn't notice the |
This PR implements the MobileViT model in TensorFlow.
Interesting points
TODOs
from_ptwherever needed.@amyeroberts @gante @sgugger up for review!