test-time-adapters 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. test_time_adapters-1.0.0/.gitignore +192 -0
  2. test_time_adapters-1.0.0/LICENSE +201 -0
  3. test_time_adapters-1.0.0/PKG-INFO +265 -0
  4. test_time_adapters-1.0.0/README.md +217 -0
  5. test_time_adapters-1.0.0/pyproject.toml +71 -0
  6. test_time_adapters-1.0.0/ttadapters/datasets/__init__.py +22 -0
  7. test_time_adapters-1.0.0/ttadapters/datasets/acdc.py +391 -0
  8. test_time_adapters-1.0.0/ttadapters/datasets/base.py +88 -0
  9. test_time_adapters-1.0.0/ttadapters/datasets/cityscapes.py +796 -0
  10. test_time_adapters-1.0.0/ttadapters/datasets/coco.py +443 -0
  11. test_time_adapters-1.0.0/ttadapters/datasets/got10k.py +217 -0
  12. test_time_adapters-1.0.0/ttadapters/datasets/imagenet1k/__init__.py +105 -0
  13. test_time_adapters-1.0.0/ttadapters/datasets/imagenet1k/classes.py +1022 -0
  14. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/__init__.py +16 -0
  15. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/base.py +101 -0
  16. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/continual.py +51 -0
  17. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/gradual.py +94 -0
  18. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/standard.py +0 -0
  19. test_time_adapters-1.0.0/ttadapters/datasets/scenarios/universal.py +0 -0
  20. test_time_adapters-1.0.0/ttadapters/datasets/shift.py +507 -0
  21. test_time_adapters-1.0.0/ttadapters/methods/__init__.py +13 -0
  22. test_time_adapters-1.0.0/ttadapters/methods/auto.py +1 -0
  23. test_time_adapters-1.0.0/ttadapters/methods/auxtasks/__init__.py +0 -0
  24. test_time_adapters-1.0.0/ttadapters/methods/auxtasks/ttt/masked_ttt.py +0 -0
  25. test_time_adapters-1.0.0/ttadapters/methods/auxtasks/ttt/ttt.py +0 -0
  26. test_time_adapters-1.0.0/ttadapters/methods/auxtasks/ttt/tttpp.py +0 -0
  27. test_time_adapters-1.0.0/ttadapters/methods/base.py +308 -0
  28. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/__init__.py +2 -0
  29. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/covariate/dua/__init__.py +10 -0
  30. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/covariate/dua/configuration_dua.py +31 -0
  31. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/covariate/dua/modeling_dua.py +187 -0
  32. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/dynamic/norm/__init__.py +10 -0
  33. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/dynamic/norm/configuration_norm.py +28 -0
  34. test_time_adapters-1.0.0/ttadapters/methods/batchnorms/dynamic/norm/modeling_norm.py +255 -0
  35. test_time_adapters-1.0.0/ttadapters/methods/deepsupervisions/__init__.py +1 -0
  36. test_time_adapters-1.0.0/ttadapters/methods/deepsupervisions/full/actmad/__init__.py +10 -0
  37. test_time_adapters-1.0.0/ttadapters/methods/deepsupervisions/full/actmad/configuration_actmad.py +43 -0
  38. test_time_adapters-1.0.0/ttadapters/methods/deepsupervisions/full/actmad/modeling_actmad.py +505 -0
  39. test_time_adapters-1.0.0/ttadapters/methods/deepsupervisions/local/objectnorm/modeling_objectnorm.py +0 -0
  40. test_time_adapters-1.0.0/ttadapters/methods/entropies/__init__.py +0 -0
  41. test_time_adapters-1.0.0/ttadapters/methods/entropies/bn/tent.py +0 -0
  42. test_time_adapters-1.0.0/ttadapters/methods/entropies/bn/tentpp.py +0 -0
  43. test_time_adapters-1.0.0/ttadapters/methods/entropies/sample/deyo.py +0 -0
  44. test_time_adapters-1.0.0/ttadapters/methods/entropies/sample/eata.py +0 -0
  45. test_time_adapters-1.0.0/ttadapters/methods/entropies/sample/memo.py +0 -0
  46. test_time_adapters-1.0.0/ttadapters/methods/pefts/__init__.py +2 -0
  47. test_time_adapters-1.0.0/ttadapters/methods/pefts/low_rank/whw/__init__.py +22 -0
  48. test_time_adapters-1.0.0/ttadapters/methods/pefts/low_rank/whw/configuration_whw.py +78 -0
  49. test_time_adapters-1.0.0/ttadapters/methods/pefts/low_rank/whw/modeling_whw.py +835 -0
  50. test_time_adapters-1.0.0/ttadapters/methods/pefts/pruning/sgp/__init__.py +10 -0
  51. test_time_adapters-1.0.0/ttadapters/methods/pefts/pruning/sgp/configuration_sgp.py +121 -0
  52. test_time_adapters-1.0.0/ttadapters/methods/pefts/pruning/sgp/modeling_sgp.py +1406 -0
  53. test_time_adapters-1.0.0/ttadapters/methods/regularizers/__init__.py +2 -0
  54. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/mean_teacher/__init__.py +10 -0
  55. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/mean_teacher/configuration_mean_teacher.py +45 -0
  56. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/mean_teacher/modeling_mean_teacher.py +445 -0
  57. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/test/__init__.py +10 -0
  58. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/test/configuration_test.py +60 -0
  59. test_time_adapters-1.0.0/ttadapters/methods/regularizers/teacher/test/modeling_test.py +679 -0
  60. test_time_adapters-1.0.0/ttadapters/models/__init__.py +4 -0
  61. test_time_adapters-1.0.0/ttadapters/models/base.py +173 -0
  62. test_time_adapters-1.0.0/ttadapters/models/grounding_dino/AGENTS.md +42 -0
  63. test_time_adapters-1.0.0/ttadapters/models/grounding_dino/__init__.py +6 -0
  64. test_time_adapters-1.0.0/ttadapters/models/grounding_dino/modeling_grounding_dino.py +316 -0
  65. test_time_adapters-1.0.0/ttadapters/models/rcnn/README.md +616 -0
  66. test_time_adapters-1.0.0/ttadapters/models/rcnn/__init__.py +1 -0
  67. test_time_adapters-1.0.0/ttadapters/models/rcnn/hooks.py +47 -0
  68. test_time_adapters-1.0.0/ttadapters/models/rcnn/modeling_rcnn.py +485 -0
  69. test_time_adapters-1.0.0/ttadapters/models/rcnn/transforms.py +113 -0
  70. test_time_adapters-1.0.0/ttadapters/models/resnet/__init__.py +1 -0
  71. test_time_adapters-1.0.0/ttadapters/models/resnet/modeling_resnet.py +71 -0
  72. test_time_adapters-1.0.0/ttadapters/models/rt_detr/README.md +643 -0
  73. test_time_adapters-1.0.0/ttadapters/models/rt_detr/__init__.py +1 -0
  74. test_time_adapters-1.0.0/ttadapters/models/rt_detr/modeling_rt_detr.py +430 -0
  75. test_time_adapters-1.0.0/ttadapters/models/yolo11/README.md +654 -0
  76. test_time_adapters-1.0.0/ttadapters/models/yolo11/__init__.py +6 -0
  77. test_time_adapters-1.0.0/ttadapters/models/yolo11/modeling_yolo11.py +434 -0
  78. test_time_adapters-1.0.0/ttadapters/models/yolo11/wrappers.py +97 -0
  79. test_time_adapters-1.0.0/ttadapters/utils/flops_counter.py +182 -0
  80. test_time_adapters-1.0.0/ttadapters/utils/validator.py +360 -0
  81. test_time_adapters-1.0.0/ttadapters/utils/visualizer.py +309 -0
@@ -0,0 +1,192 @@
1
+ ############################################
2
+ # Python Development
3
+ #
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # UV
102
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ uv.lock
106
+
107
+ # poetry
108
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
109
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
110
+ # commonly ignored for libraries.
111
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
112
+ #poetry.lock
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ #pdm.lock
117
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
118
+ # in version control.
119
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
120
+ .pdm.toml
121
+ .pdm-python
122
+ .pdm-build/
123
+
124
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
125
+ __pypackages__/
126
+
127
+ # Celery stuff
128
+ celerybeat-schedule
129
+ celerybeat.pid
130
+
131
+ # SageMath parsed files
132
+ *.sage.py
133
+
134
+ # Environments
135
+ .env
136
+ .venv
137
+ env/
138
+ venv/
139
+ ENV/
140
+ env.bak/
141
+ venv.bak/
142
+
143
+ # Spyder project settings
144
+ .spyderproject
145
+ .spyproject
146
+
147
+ # Rope project settings
148
+ .ropeproject
149
+
150
+ # mkdocs documentation
151
+ /site
152
+
153
+ # mypy
154
+ .mypy_cache/
155
+ .dmypy.json
156
+ dmypy.json
157
+
158
+ # Pyre type checker
159
+ .pyre/
160
+
161
+ # pytype static type analyzer
162
+ .pytype/
163
+
164
+ # Cython debug symbols
165
+ cython_debug/
166
+
167
+ # PyCharm
168
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
169
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
170
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
171
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
172
+ .idea/
173
+ *.*~
174
+
175
+ # Ruff stuff:
176
+ .ruff_cache/
177
+
178
+ # PyPI configuration file
179
+ .pypirc
180
+
181
+ # PyTorch
182
+ data/
183
+ .data/
184
+ results/
185
+ results-*/
186
+ wandb/
187
+ logs/
188
+ trainer_output/
189
+
190
+ # AI Agent
191
+ .claude
192
+ .omc
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025-2026 BREW, leecausemin
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: test-time-adapters
3
+ Version: 1.0.0
4
+ Summary: Ready-to-Go Test-time Adaptation/Training Implementations
5
+ Project-URL: Homepage, https://github.com/robustaim/test-time-adapters
6
+ Project-URL: Repository, https://github.com/robustaim/test-time-adapters
7
+ Author: robustaim
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: deep-learning,domain-adaptation,pytorch,test-time-adaptation
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: accelerate
18
+ Requires-Dist: cityscapesscripts>=2.2.4
19
+ Requires-Dist: filetype>=1.2.0
20
+ Requires-Dist: gdown>=5.2.0
21
+ Requires-Dist: hf-xet>=1.2.0
22
+ Requires-Dist: imagecorruptions>=1.1.2
23
+ Requires-Dist: ipykernel>=7.0.1
24
+ Requires-Dist: ipywidgets>=8.1.8
25
+ Requires-Dist: muon-optimizer>=0.1.0
26
+ Requires-Dist: numpy>=2.4.1
27
+ Requires-Dist: opencv-python-headless; platform_system == 'Linux'
28
+ Requires-Dist: opencv-python; platform_system != 'Linux'
29
+ Requires-Dist: pycocotools>=2.0.11
30
+ Requires-Dist: supervision>=0.27.0
31
+ Requires-Dist: test-time-adapters-scalabel
32
+ Requires-Dist: test-time-adapters-shift-dev
33
+ Requires-Dist: timm>=1.0.22
34
+ Requires-Dist: torchinfo>=1.8.0
35
+ Requires-Dist: tqdm>=4.67.1
36
+ Requires-Dist: transformers>=4.57.6
37
+ Provides-Extra: detectron2
38
+ Requires-Dist: detectron2; extra == 'detectron2'
39
+ Provides-Extra: torch
40
+ Requires-Dist: torch; extra == 'torch'
41
+ Requires-Dist: torchvision; extra == 'torch'
42
+ Provides-Extra: torch-cu128
43
+ Requires-Dist: torch; extra == 'torch-cu128'
44
+ Requires-Dist: torchvision; extra == 'torch-cu128'
45
+ Provides-Extra: wandb
46
+ Requires-Dist: wandb>=0.23.1; extra == 'wandb'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # test-time-adapters
50
+ A Ready-to-Go Playground for Test-time Learning Methods
51
+
52
+ > Ensures to be easily integrated with vision libraries such as detectron2, ultralytics, transformers.
53
+
54
+
55
+ ## Academic History
56
+ - [1980s~1990s] Continual Learning
57
+
58
+ Continual Learning, also known as Lifelong Learning, was conceptualized as early as the late 1980s, with significant foundational work in the early 1990s. This field addresses the challenge of training a model on a continuous stream of data from different tasks without forgetting previously learned knowledge. The primary goal is to achieve **forward transfer** (leveraging past knowledge to learn new tasks more efficiently) and prevent **catastrophic forgetting** (a sudden drop in performance on previous tasks after learning a new one). Early work focused on neural networks' ability to learn sequentially, a problem that remains a central focus of the field today.
59
+
60
+ - [1990s] Domain Adaptation
61
+
62
+ The concept of Domain Adaptation emerged in the mid-1990s within the machine learning community. It deals with a scenario where a model is trained on a labeled source domain but is expected to perform well on a different, yet related, target domain where labeled data is scarce or unavailable. The core challenge is the **domain shift** or **distributional shift** between the source and target data. The primary objective is to leverage the knowledge from the source domain to build a robust model for the target domain.
63
+
64
+ - [2000s] Unsupervised Domain Adaptation
65
+
66
+ Building upon domain adaptation, Unsupervised Domain Adaptation (UDA) became a distinct and active area of research around the mid-2000s. In the classic UDA setting, the model has access to labeled data from the source domain and **unlabeled** data from the target domain during the training phase. The goal remains the same: to overcome the domain shift. UDA methods often work by trying to align the feature distributions of the source and target domains, making them indistinguishable to the model.
67
+
68
+ - [2010s] Domain Regularization
69
+
70
+ While the general idea of regularization to prevent overfitting is decades old, its specific application to domain-related problems, or Domain Regularization, gained prominence in the early 2010s. This approach involves adding specific regularization terms to the model's objective function during training. These terms are designed to encourage the model **to learn features that are invariant across different domains** (e.g., source and target domains). By penalizing domain-specific features, the model is forced to focus on more general, underlying patterns, thereby improving its ability to generalize to new, unseen domains.
71
+
72
+ - [2019] Source-Free Domain Adaptation
73
+
74
+ A more recent development, Source-Free Domain Adaptation (SFDA), was formally introduced around 2019. This subfield addresses a more challenging and practical scenario where the adaptation to the target domain must be performed **without access to the source data**. The process typically involves taking a pre-trained source model and adapting it using only unlabeled target data. This is particularly useful in situations where the source data is private, proprietary, or too large to transfer.
75
+
76
+ - [2020] Test-time Adaptation (Online)
77
+
78
+ Test-Time Adaptation (TTA), sometimes referred to as Online Adaptation, emerged as a distinct concept around 2020. TTA aims to adapt a pre-trained source model to a target domain "on the fly" during the testing phase. The model updates itself using each incoming batch of test data. Unlike traditional domain adaptation, TTA is typically **source-free** and **online**, meaning it adapts continuously as it encounters new data from the target distribution. The adaptation is often done by updating specific parts of the model, like batch normalization statistics, or by minimizing an unsupervised objective function on the test data.
79
+
80
+ - [2022] Continual Test-time Adaptation
81
+
82
+ The most recent field on this list, Continual Test-Time Adaptation (CTTA), was proposed around 2022. It extends Test-Time Adaptation to a more realistic scenario where the target domain is not static but changes over time. Therefore, the model must **continuously adapt** to a stream of data from non-stationary, ever-changing target distributions. A key challenge in CTTA is to adapt to the current data distribution while avoiding overfitting to transient changes and forgetting what it has learned from previous target distributions.
83
+
84
+
85
+ ## Methods
86
+ - [x] Batch Statistics Replacement
87
+ - [x] Covariate Shift Adaptation (NORM)
88
+ - [x] Dynamic BN Adaptation (DUA)
89
+ - [ ] Entropy Minimization
90
+ - [ ] BatchNorm Entropy Minimization (TENT)
91
+ - [ ] Sample-Efficient Entropy Minimization (EATA)
92
+ - [ ] Marginal Entropy Minimization (MEMO, Sample Data Augmentation)
93
+ - [ ] Auxiliary Task
94
+ - [ ] Rotation Prediction (TTT, Self-Supervised)
95
+ - [ ] Contrastive Learning (TTT++, Self-Supervised)
96
+ - [ ] Masked Pixel Prediction (Masked TTT, Self-Supervised)
97
+ - [x] Sample Selection
98
+ - [ ] De-biasing (DeYO)
99
+ - [ ] Consistency Regularization
100
+ - [x] Temporal EMA (Mean-Teacher, Self-Training/Semi-Supervised)
101
+ - [x] Teacher-Student Augmentation Consistency (TeST, Self-Training/Semi-Supervised)
102
+ - [x] Deep Supervision (Cascaded, Not End-to-End)
103
+ - [x] Layer-wise Deep Supervision (ActMAD, Self-Supervised)
104
+ - [x] Gamma-based Intensity Transformation (GITA, Self-Supervised)
105
+ - [] Cascaded Norm Adaptation (Self-Supervised)
106
+ - [] Flow Adaptation (Self-Supervised)
107
+ - [ ] Parameter-Efficient Adaptation
108
+ - [x] Low-Rank Adaptation (WHW / When, Where, and How to Adapt?)
109
+ - [x] Sensitivity-Guided Pruning (SGP)
110
+
111
+ ### Methods by Adaptation Level
112
+ - Model-Level Adaptation
113
+ - Batch Statistics Replacement
114
+ - Entropy Minimization
115
+ - Parameter-Efficient Adaptation
116
+
117
+ - Feature-Level Adaptation
118
+ - Auxiliary Task
119
+ - Consistency Regularization
120
+
121
+ - Input-Level Adaptation
122
+ - Input Transformation Module (ITM)
123
+ - Learning to Normalize (GITA)
124
+
125
+ - Sample-Level Adaptation
126
+ - Sample Selection
127
+
128
+ ### Cascaded Norm Adaptation (CascadedNorm)
129
+
130
+ > This suggests to adapt the input and features of the model to the target domain.
131
+
132
+ <!-- <img src="./docs/images/apt_structure.svg"> -->
133
+
134
+ ### Performance Metrics
135
+ | Method | Dataset | Metric | Value |
136
+ |--------------|---------|-------------|-------|
137
+ | CascadedNorm | SHIFT | mAP (50-95) | ??? |
138
+
139
+
140
+ ## Datasets
141
+ ### SHIFT
142
+ ```
143
+ INFO: <simple> weather datasets - Normal: 20800, Corrupted: 129200
144
+ INFO: <clear> weather datasets - Daytime: 20800, Night: 9350, Dawn: 9650
145
+ INFO: <rainy> weather datasets - Daytime: 20600, Night: 11500, Dawn: 9600
146
+ INFO: <cloudy> weather datasets - Daytime: 13850, Night: 6000, Dawn: 6750
147
+ INFO: <foggy> weather datasets - Daytime: 12900, Night: 7200, Dawn: 7450
148
+ INFO: <overcast> weather datasets - Daytime: 7850, Night: 3250, Dawn: 3250
149
+ INFO: Splitting val
150
+ INFO: <simple> weather datasets - Normal: 2800, Corrupted: 22200
151
+ INFO: <clear> weather datasets - Daytime: 2800, Night: 1200, Dawn: 1400
152
+ INFO: <rainy> weather datasets - Daytime: 3200, Night: 1950, Dawn: 1400
153
+ INFO: <cloudy> weather datasets - Daytime: 2400, Night: 1200, Dawn: 1250
154
+ INFO: <foggy> weather datasets - Daytime: 2650, Night: 1350, Dawn: 1350
155
+ INFO: <overcast> weather datasets - Daytime: 1600, Night: 700, Dawn: 550
156
+ ```
157
+ ```
158
+ INFO: Processing for 1x
159
+ INFO: Splitting train
160
+ INFO: <daytime_to_night> datasets - Clear: 960, Rainy: 560, Cloudy: 720, Foggy: 480, Overcast: 200, Total: 2920/9040
161
+ INFO: <clear_to_foggy> datasets - Daytime: 1800, Night: 520, Dawn: 560, Total: 2880/9040
162
+ INFO: <clear_to_rainy> datasets - Daytime: 1600, Night: 1000, Dawn: 640, Total: 3240/9040
163
+ INFO: Splitting val
164
+ INFO: <daytime_to_night> datasets - Clear: 160, Rainy: 280, Cloudy: 200, Foggy: 80, Overcast: 160, Total: 880/2280
165
+ INFO: <clear_to_foggy> datasets - Daytime: 240, Night: 200, Dawn: 240, Total: 680/2280
166
+ INFO: <clear_to_rainy> datasets - Daytime: 360, Night: 240, Dawn: 120, Total: 720/2280
167
+ INFO: Processing for 10x
168
+ INFO: Splitting train
169
+ INFO: <daytime_to_night> datasets - Clear: 3200, Rainy: 4000, Cloudy: 2800, Foggy: 2800, Overcast: 1600, Total: 14400/40616
170
+ INFO: <clear_to_foggy> datasets - Daytime: 4800, Night: 2616, Dawn: 4400, Total: 11816/40616
171
+ INFO: <clear_to_rainy> datasets - Daytime: 6800, Night: 3200, Dawn: 4400, Total: 14400/40616
172
+ INFO: Splitting val
173
+ INFO: <daytime_to_night> datasets - Clear: 1012, Rainy: 0, Cloudy: 1457, Foggy: 400, Overcast: 0, Total: 2869/10069
174
+ INFO: <clear_to_foggy> datasets - Daytime: 1600, Night: 400, Dawn: 1200, Total: 3200/10069
175
+ INFO: <clear_to_rainy> datasets - Daytime: 1200, Night: 2000, Dawn: 800, Total: 4000/10069
176
+ INFO: Processing for 100x
177
+ INFO: Splitting train
178
+ INFO: <daytime_to_night> datasets - Clear: 8000, Rainy: 8000, Cloudy: 6322, Foggy: 0, Overcast: 0, Total: 22322/74462
179
+ INFO: <clear_to_foggy> datasets - Daytime: 16000, Night: 7612, Dawn: 4000, Total: 27612/74462
180
+ INFO: <clear_to_rainy> datasets - Daytime: 8528, Night: 4000, Dawn: 12000, Total: 24528/74462
181
+ INFO: Splitting val
182
+ INFO: <daytime_to_night> datasets - Clear: 0, Rainy: 4000, Cloudy: 0, Foggy: 0, Overcast: 0, Total: 4000/20000
183
+ INFO: <clear_to_foggy> datasets - Daytime: 4000, Night: 4000, Dawn: 0, Total: 8000/20000
184
+ INFO: <clear_to_rainy> datasets - Daytime: 0, Night: 8000, Dawn: 0, Total: 8000/20000
185
+ ```
186
+
187
+
188
+ ## Usage
189
+ > [!NOTE]
190
+ > Detectron2 requires to be built in your device since meta does not provide pre-built wheel for recent PyTorch versions.
191
+ > Sometimes, you may encounter an error related to CUDA version mismatch cause uv/pip will choose the system-default CUDA toolkit version.
192
+ > In such cases, you can try the following steps to set the correct CUDA toolkit version in linux:
193
+ ```bash
194
+ # Check current CUDA symlink
195
+ ls -la /usr/local/cuda
196
+
197
+ # Set target CUDA version
198
+ export CUDA_HOME=/usr/local/cuda-12.8
199
+ export PATH=/usr/local/cuda-12.8/bin:$PATH
200
+ export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64:$LD_LIBRARY_PATH
201
+
202
+ # Rebuild
203
+ uv sync --extra torch
204
+ ```
205
+
206
+ ### Installation (Use this repository as a package for your own project)
207
+ ```bash
208
+ uv add torch torchvision # install torch manually
209
+ uv add git+https://github.com/robustaim/test-time-adapters.git
210
+ ```
211
+
212
+ ### Reproduction of Results
213
+ #### Environment Setup
214
+ ```bash
215
+ git clone https://github.com/robustaim/test-time-adapters.git tta
216
+ cd tta
217
+ uv sync --extra torch-cu128 # only windows
218
+ uv sync --extra torch # only linux
219
+ ```
220
+
221
+ #### Run Batch Experiments
222
+ ```bash
223
+ python example.py
224
+ ```
225
+
226
+ #### Apply to Your Own Model
227
+ ```python
228
+ from ttadapters.methods import GITAConfig, GITAPlugin
229
+ ```
230
+
231
+
232
+ ## Citation
233
+ ```
234
+ @InProceedings{shift2022,
235
+ author = {Sun, Tao and Segu, Mattia and Postels, Janis and Wang, Yuxuan and Van Gool, Luc and Schiele, Bernt and Tombari, Federico and Yu, Fisher},
236
+ title = {{SHIFT:} A Synthetic Driving Dataset for Continuous Multi-Task Domain Adaptation},
237
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
238
+ month = {June},
239
+ year = {2022},
240
+ pages = {21371-21382}
241
+ }
242
+ ```
243
+ ```
244
+ @misc{lv2023detrs,
245
+ title={DETRs Beat YOLOs on Real-time Object Detection},
246
+ author={Yian Zhao and Wenyu Lv and Shangliang Xu and Jinman Wei and Guanzhong Wang and Qingqing Dang and Yi Liu and Jie Chen},
247
+ year={2023},
248
+ eprint={2304.08069},
249
+ archivePrefix={arXiv},
250
+ primaryClass={cs.CV}
251
+ }
252
+ ```
253
+ ```
254
+ @inproceedings{wolf-etal-2020-transformers,
255
+ title = "Transformers: State-of-the-Art Natural Language Processing",
256
+ author = "Thomas Wolf and Lysandre Debut and Victor Sanh and Julien Chaumond and Clement Delangue and Anthony Moi and Pierric Cistac and Tim Rault and Rémi Louf and Morgan Funtowicz and Joe Davison and Sam Shleifer and Patrick von Platen and Clara Ma and Yacine Jernite and Julien Plu and Canwen Xu and Teven Le Scao and Sylvain Gugger and Mariama Drame and Quentin Lhoest and Alexander M. Rush",
257
+ booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
258
+ month = oct,
259
+ year = "2020",
260
+ address = "Online",
261
+ publisher = "Association for Computational Linguistics",
262
+ url = "https://www.aclweb.org/anthology/2020.emnlp-demos.6",
263
+ pages = "38--45"
264
+ }
265
+ ```