{"id":15972116,"url":"https://github.com/rishit-dagli/convmixer-torch2tf","last_synced_at":"2025-06-24T22:42:02.746Z","repository":{"id":105750574,"uuid":"420328325","full_name":"Rishit-dagli/ConvMixer-torch2tf","owner":"Rishit-dagli","description":"This repository hosts code for converting the original ConvMixer models (PyTorch) to TensorFlow.","archived":false,"fork":false,"pushed_at":"2022-01-17T06:49:42.000Z","size":542,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T05:25:48.860Z","etag":null,"topics":["convmixer","convolutional-neural-networks","machine-learning","pytorch","tensorflow","tf-hub","vision"],"latest_commit_sha":null,"homepage":"https://tfhub.dev/rishit-dagli/collections/convmixer","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rishit-dagli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-23T06:01:45.000Z","updated_at":"2023-06-09T14:41:47.000Z","dependencies_parsed_at":"2023-06-13T14:30:44.209Z","dependency_job_id":null,"html_url":"https://github.com/Rishit-dagli/ConvMixer-torch2tf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2FConvMixer-torch2tf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2FConvMixer-torch2tf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2FConvMixer-torch2tf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2FConvMixer-torch2tf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rishit-dagli","download_url":"https://codeload.github.com/Rishit-dagli/ConvMixer-torch2tf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243886546,"owners_count":20363751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convmixer","convolutional-neural-networks","machine-learning","pytorch","tensorflow","tf-hub","vision"],"created_at":"2024-10-07T20:42:02.408Z","updated_at":"2025-03-17T22:30:48.459Z","avatar_url":"https://github.com/Rishit-dagli.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConvMixer-torch2tf [![Twitter URL](https://img.shields.io/twitter/url?style=social\u0026url=https%3A%2F%2Fgithub.com%2FRishit-dagli%2FConvMixer-torch2tf)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2FRishit-dagli%2FConvMixer-torch2tf)\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Rishit-dagli/ConvMixer-torch2tf/blob/main/classification.ipynb)\n![GitHub License](https://img.shields.io/github/license/Rishit-dagli/ConvMixer-torch2tf)\n[![GitHub stars](https://img.shields.io/github/stars/Rishit-dagli/ConvMixer-torch2tf?style=social)](https://github.com/Rishit-dagli/ConvMixer-torch2tf/stargazers)\n[![GitHub followers](https://img.shields.io/github/followers/Rishit-dagli?label=Follow\u0026style=social)](https://github.com/Rishit-dagli)\n[![Twitter Follow](https://img.shields.io/twitter/follow/rishit_dagli?style=social)](https://twitter.com/intent/follow?screen_name=rishit_dagli)\n\n[![Open TF Hub](https://img.shields.io/badge/open-TF%20Hub-orange?style=flat\u0026logo=tensorflow)](https://tfhub.dev/rishit-dagli/collections/convmixer)\n\n![](media/example.png)\n\nThis repository hosts code for converting the original ConvMixer [^1] (PyTorch) models to TensorFlow. In this repo we convert these 6 ConvMixer models to TensorFlow SavedModels:\n\n*The models can also be found on [TensorFlow Hub](https://tfhub.dev/rishit-dagli/collections/convmixer)*\n\n| Model Name | Fine-tunable | Resolution | acc@1 | #params | File Size | TensorFlow Model |\n|------------|:---:|:---:|:---:|:---:|----------:|:--------------:|\n| ConvMixer-1536/20 | ❌ | 224x224 | 81.37 | 51.6 x 10^6 | 184MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_1536_20.tar.gz)/[drive](https://drive.google.com/file/d/1qrzap4vi2KFQTHxf9h_AMbWGvtbP5rIA/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_1536_20.tar.gz) |\n| ConvMixer-768/32 | ❌ | 224x224 | 80.16 | 21.1 x 10^6 | 75MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_768_32.tar.gz)/[drive](https://drive.google.com/file/d/1NJgHKjPd3YC8XHypQIs5A05XKd15o0s3/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_768_32.tar.gz) |\n| ConvMixer-1024/20 | ❌ | 224x224 | 76.94 | 24.4 x 10^6 | 87MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_1024_20.tar.gz)/[drive](https://drive.google.com/file/d/1--jRgK0KmLtWCJswYtfxSIfEcjAOrJyv/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_1024_20.tar.gz) |\n| Feature Extractor ConvMixer-1536/20 | ✅ | 224x224 | - | - | 178MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_1536_20_fe.tar.gz)/[drive](https://drive.google.com/file/d/13s6JB0PVi_8QMnOVnsIW4qFYksRvou7C/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_1536_20_fe.tar.gz) |\n| Feature Extractor ConvMixer-768/32 | ✅ | 224x224 | - | - | 75MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_768_32_fe.tar.gz)/[drive](https://drive.google.com/file/d/1n_ebcn50JmZnrfPXuTTSjiabVZeZZO0f/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_768_32_fe.tar.gz) |\n| Feature Extractor ConvMixer-1024/20 | ✅ | 224x224 | - | - | 75MB | [github](https://github.com/Rishit-dagli/ConvMixer-torch2tf/releases/download/v0.1.0/convmixer_1024_20_fe.tar.gz)/[drive](https://drive.google.com/file/d/1Y8LO8U9jpizgHRZfXxdspaKra93usldr/view?usp=sharing)/[bucket](https://storage.googleapis.com/convmixer-hubmodels.appspot.com/convmixer_1024_20_fe.tar.gz) |\n\n\u003e You can use the Feature Extractor models for fine-tuning on your own datasets.\n\nConvMixer is a simple model, proposed in the paper \"Patches Are All You Need?\" [^2] for image classification pre-trained on ImageNet-1K. ConvMixer uses only standard convolutions to achieve the mixing steps. Despite it's simplicity it outperforms ViT and MLP-Mixer. Using the [`conversion.ipynb`](conversion.ipynb) notebook, one should be able to take a model from the pre-trained models and convert that to TensorFlow and use that with TensorFlow Hub and Keras.\n\n![](media/architecture.png)\n\nThe original model classes and weights were converted using the `onnx-tf` tool [^3].\n\n## About the Notebooks\n\n### [`conversion.ipynb`](conversion.ipynb)\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Rishit-dagli/ConvMixer-torch2tf/blob/main/conversion.ipynb)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Rishit-dagli/ConvMixer-torch2tf/HEAD?labpath=conversion.ipynb)\n\nThis notebook demonstrates how the models were converted to TensorFlow SavedModel and uses `onnx-tf` [^3] tool to do so. This notebook loads the ConvMixer model using timm (PyTorch Image Models) [^4] modifying some of the code to allow doing so as shown in the [`timm_convmixer.py`](timm_convmixer.py) file in this repo.\n\n### [`classification.ipynb`](classification.ipynb)\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Rishit-dagli/ConvMixer-torch2tf/blob/main/classification.ipynb)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Rishit-dagli/ConvMixer-torch2tf/HEAD?labpath=classification.ipynb)\n\nThis noteboook demonstrates how to load a ConvMixer Model varaint and run image classification using TensorFlow and TensorFlow Hub [^5]. This notebook will soon be updated to fetch models from tfhub.dev. These models can be used in the exact same manner with TensorFlow Keras too.\n\n## Want to Contribute 🙋‍♂️?\n\nAwesome! If you want to contribute to this project, you're always welcome! See [Contributing Guidelines](CONTRIBUTING.md). You can also take a look at [open issues](https://github.com/Rishit-dagli/ConvMixer-torch2tf/issues) for getting more information about current or upcoming tasks.\n\n## Want to discuss? 💬\n\nHave any questions, doubts or want to present your opinions, views? You're always welcome. You can [start discussions](https://github.com/Rishit-dagli/ConvMixer-torch2tf/discussions).\n\n## License\n\n```\nCopyright 2020 Rishit Dagli\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n## References\n\n[^1]: Official Code Implementation: https://github.com/tmp-iclr/convmixer\n[^2]: Anonymous. Patches Are All You Need? 2021. openreview.net, https://openreview.net/forum?id=TVHS5Y4dNvM.\n[^3]: onnx-tensorflow. Tensorflow Backend for ONNX. https://github.com/onnx/onnx-tensorflow\n[^4]: Ross Wightman, . \"PyTorch Image Models.\" https://github.com/rwightman/pytorch-image-models. (2019).\n[^5]: TensorFlow Hub. https://www.tensorflow.org/hub\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishit-dagli%2Fconvmixer-torch2tf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frishit-dagli%2Fconvmixer-torch2tf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishit-dagli%2Fconvmixer-torch2tf/lists"}