torch-omni-tool 0.1.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.
- torch_omni_tool-0.1.0/.github/workflows/ci.yml +39 -0
- torch_omni_tool-0.1.0/.github/workflows/publish.yml +33 -0
- torch_omni_tool-0.1.0/.gitignore +5 -0
- torch_omni_tool-0.1.0/LICENSE +222 -0
- torch_omni_tool-0.1.0/PKG-INFO +378 -0
- torch_omni_tool-0.1.0/README.md +133 -0
- torch_omni_tool-0.1.0/pyproject.toml +66 -0
- torch_omni_tool-0.1.0/tests/README.md +38 -0
- torch_omni_tool-0.1.0/tests/conftest.py +0 -0
- torch_omni_tool-0.1.0/tests/test_grn.py +218 -0
- torch_omni_tool-0.1.0/torch_omni_tool/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/activations/README.md +40 -0
- torch_omni_tool-0.1.0/torch_omni_tool/activations/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/activations/snake.py +40 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ConvNeXtV2/ConvNeXtV2.py +67 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ConvNeXtV2/GRN.py +40 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ConvNeXtV2/README.md +77 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ConvNeXtV2/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/README.md +42 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RRDB/README.md +63 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RRDB/RRDB_2D.py +80 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RRDB/RRDB_3d.py +80 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RRDB/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RepMoDE/README.md +130 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RepMoDE/RepMoDE_1d.py +423 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RepMoDE/RepMoDE_2d.py +324 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RepMoDE/RepMoDE_3d.py +383 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/RepMoDE/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/SEB/README.md +43 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/SEB/SEB.py +44 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/SEB/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ViT/README.md +59 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ViT/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/ViT/position_embedding_sine.py +85 -0
- torch_omni_tool-0.1.0/torch_omni_tool/blocks/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/config.py +55 -0
- torch_omni_tool-0.1.0/torch_omni_tool/datasets/README.md +80 -0
- torch_omni_tool-0.1.0/torch_omni_tool/datasets/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/datasets/augmentations_3d.py +152 -0
- torch_omni_tool-0.1.0/torch_omni_tool/datasets/cstm_ds.py +103 -0
- torch_omni_tool-0.1.0/torch_omni_tool/loops.py +136 -0
- torch_omni_tool-0.1.0/torch_omni_tool/model.py +38 -0
- torch_omni_tool-0.1.0/torch_omni_tool/normalizations/README.md +43 -0
- torch_omni_tool-0.1.0/torch_omni_tool/normalizations/__init__.py +0 -0
- torch_omni_tool-0.1.0/torch_omni_tool/normalizations/layern_norm_2d.py +67 -0
- torch_omni_tool-0.1.0/torch_omni_tool/training.py +90 -0
- torch_omni_tool-0.1.0/torch_omni_tool/utils.py +172 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
checks:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
cache: pip
|
|
22
|
+
cache-dependency-path: pyproject.toml
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
|
28
|
+
python -m pip install -e ".[dev]"
|
|
29
|
+
|
|
30
|
+
# known-failing: 7.6/10, remove continue-on-error once clean
|
|
31
|
+
- name: Pylint
|
|
32
|
+
continue-on-error: true
|
|
33
|
+
run: pylint torch_omni_tool
|
|
34
|
+
|
|
35
|
+
- name: Mypy
|
|
36
|
+
run: mypy
|
|
37
|
+
|
|
38
|
+
- name: Pytest
|
|
39
|
+
run: pytest
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
# Optional: also allow manual trigger
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-and-publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment:
|
|
13
|
+
name: pypi
|
|
14
|
+
url: https://pypi.org/p/mltools
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # Required for Trusted Publishing
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
|
|
26
|
+
- name: Install build tools
|
|
27
|
+
run: python -m pip install --upgrade build
|
|
28
|
+
|
|
29
|
+
- name: Build package
|
|
30
|
+
run: python -m build
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
MLTools NON-COMMERCIAL SOURCE-AVAILABLE LICENSE v1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mateo Rodriguez
|
|
4
|
+
|
|
5
|
+
DEFINITIONS
|
|
6
|
+
|
|
7
|
+
"Software" means the original software contained in this repository that is
|
|
8
|
+
copyrighted by the Licensor, including source code, documentation, and other
|
|
9
|
+
original materials, but excluding Third-Party Materials.
|
|
10
|
+
|
|
11
|
+
"Licensor" means Mateo Rodriguez, the copyright holder of the Software.
|
|
12
|
+
|
|
13
|
+
"Third-Party Materials" means software, source code, models, data, assets,
|
|
14
|
+
documentation, or other materials included in or distributed with the
|
|
15
|
+
Software that are not owned by the Licensor and are identified as being
|
|
16
|
+
subject to separate license terms.
|
|
17
|
+
|
|
18
|
+
"Commercial Use" means any use of the Software that is primarily intended
|
|
19
|
+
for or directed toward commercial advantage, monetary compensation, revenue
|
|
20
|
+
generation, or the operation or delivery of a commercial product or service.
|
|
21
|
+
|
|
22
|
+
Commercial Use includes, without limitation:
|
|
23
|
+
|
|
24
|
+
incorporating the Software into a product or service that is sold,
|
|
25
|
+
licensed, or otherwise provided for monetary compensation;
|
|
26
|
+
|
|
27
|
+
using the Software to provide a paid service, API, hosted service, SaaS,
|
|
28
|
+
or other revenue-generating service;
|
|
29
|
+
|
|
30
|
+
using the Software as a material component of a commercial production
|
|
31
|
+
system or workflow;
|
|
32
|
+
|
|
33
|
+
using the Software to develop, operate, or deliver products or services
|
|
34
|
+
for which the user or another party receives monetary compensation;
|
|
35
|
+
|
|
36
|
+
distributing the Software, or a derivative work based on it, as part of
|
|
37
|
+
a commercial product or service;
|
|
38
|
+
|
|
39
|
+
using the Software for the primary purpose of obtaining a commercial
|
|
40
|
+
advantage or generating revenue.
|
|
41
|
+
|
|
42
|
+
Commercial Use does not arise solely because the person or organization
|
|
43
|
+
using the Software is a for-profit company, employs paid staff, or otherwise
|
|
44
|
+
engages in commercial activities, provided that the particular use of the
|
|
45
|
+
Software is not itself directed toward commercial advantage, monetary
|
|
46
|
+
compensation, revenue generation, or the operation or delivery of a
|
|
47
|
+
commercial product or service.
|
|
48
|
+
|
|
49
|
+
"Non-Commercial Use" means use of the Software that is not Commercial Use,
|
|
50
|
+
including personal use, hobby projects, education, academic research,
|
|
51
|
+
non-commercial research, experimentation, evaluation, and other activities
|
|
52
|
+
that are not primarily intended for or directed toward commercial advantage
|
|
53
|
+
or monetary compensation.
|
|
54
|
+
|
|
55
|
+
The determination of whether a particular use constitutes Commercial Use
|
|
56
|
+
shall be based on the purpose and circumstances of that use, rather than
|
|
57
|
+
solely on the identity or legal status of the user or organization.
|
|
58
|
+
|
|
59
|
+
LICENSE GRANT
|
|
60
|
+
|
|
61
|
+
Subject to the terms of this License, the Licensor grants you a worldwide,
|
|
62
|
+
non-exclusive, royalty-free, non-transferable license to:
|
|
63
|
+
|
|
64
|
+
use the Software for Non-Commercial Use;
|
|
65
|
+
|
|
66
|
+
copy the Software for Non-Commercial Use;
|
|
67
|
+
|
|
68
|
+
study the Software;
|
|
69
|
+
|
|
70
|
+
modify the Software;
|
|
71
|
+
|
|
72
|
+
create derivative works based on the Software; and
|
|
73
|
+
|
|
74
|
+
distribute original or modified copies of the Software for Non-Commercial
|
|
75
|
+
Use.
|
|
76
|
+
|
|
77
|
+
COMMERCIAL USE
|
|
78
|
+
|
|
79
|
+
Commercial Use of the Software is not permitted under this License.
|
|
80
|
+
|
|
81
|
+
You may engage in Commercial Use only after obtaining a separate commercial
|
|
82
|
+
license or other written permission from the Licensor.
|
|
83
|
+
|
|
84
|
+
The Licensor may grant commercial licenses under separate terms, including
|
|
85
|
+
terms requiring payment of a license fee, subscription, royalty, or other
|
|
86
|
+
compensation.
|
|
87
|
+
|
|
88
|
+
A commercial license may authorize uses that are prohibited by this License,
|
|
89
|
+
including incorporation into commercial products or services, commercial
|
|
90
|
+
distribution, operation of commercial production systems, and provision of
|
|
91
|
+
paid services using the Software.
|
|
92
|
+
|
|
93
|
+
Nothing in this section prohibits Non-Commercial Use merely because the user
|
|
94
|
+
is employed by, affiliated with, or otherwise associated with a commercial
|
|
95
|
+
organization, provided that the particular use qualifies as Non-Commercial
|
|
96
|
+
Use under this License.
|
|
97
|
+
|
|
98
|
+
REDISTRIBUTION
|
|
99
|
+
|
|
100
|
+
You may redistribute the Software, including modified versions, for
|
|
101
|
+
Non-Commercial Use provided that:
|
|
102
|
+
|
|
103
|
+
this License is included with the redistribution;
|
|
104
|
+
|
|
105
|
+
copyright and attribution notices belonging to the Licensor are preserved;
|
|
106
|
+
|
|
107
|
+
you clearly identify modifications that you have made; and
|
|
108
|
+
|
|
109
|
+
you do not represent modified versions as being the original Software.
|
|
110
|
+
|
|
111
|
+
You may not redistribute the Software for Commercial Use without a separate
|
|
112
|
+
commercial license from the Licensor.
|
|
113
|
+
|
|
114
|
+
MODIFICATIONS AND DERIVATIVE WORKS
|
|
115
|
+
|
|
116
|
+
You are permitted to modify the Software and create derivative works for
|
|
117
|
+
Non-Commercial Use.
|
|
118
|
+
|
|
119
|
+
Your modifications and derivative works based on the Software remain subject
|
|
120
|
+
to the restrictions on Commercial Use contained in this License, except where
|
|
121
|
+
a separate license applies to Third-Party Materials.
|
|
122
|
+
|
|
123
|
+
You may publish and distribute your modifications and derivative works for
|
|
124
|
+
Non-Commercial Use, provided that you comply with this License and all
|
|
125
|
+
applicable licenses for Third-Party Materials.
|
|
126
|
+
|
|
127
|
+
THIRD-PARTY MATERIALS
|
|
128
|
+
|
|
129
|
+
This License does not apply to Third-Party Materials.
|
|
130
|
+
|
|
131
|
+
Third-Party Materials remain subject to their respective original licenses,
|
|
132
|
+
copyright notices, and other applicable terms.
|
|
133
|
+
|
|
134
|
+
Nothing in this License is intended to restrict, revoke, or replace rights
|
|
135
|
+
that you receive directly from a third-party copyright holder under a
|
|
136
|
+
separate license.
|
|
137
|
+
|
|
138
|
+
Where Third-Party Materials are distributed under a license that permits
|
|
139
|
+
Commercial Use, this License does not revoke or restrict those permissions
|
|
140
|
+
with respect to those Third-Party Materials.
|
|
141
|
+
|
|
142
|
+
Where Third-Party Materials are subject to additional restrictions, those
|
|
143
|
+
restrictions continue to apply.
|
|
144
|
+
|
|
145
|
+
The Licensor makes no claim of ownership over Third-Party Materials.
|
|
146
|
+
|
|
147
|
+
A list of known Third-Party Materials and their applicable licenses may be
|
|
148
|
+
provided in the THIRD_PARTY_LICENSES directory or accompanying
|
|
149
|
+
documentation.
|
|
150
|
+
|
|
151
|
+
ATTRIBUTION AND COPYRIGHT NOTICES
|
|
152
|
+
|
|
153
|
+
You must retain existing copyright notices and license notices belonging to
|
|
154
|
+
the Licensor or Third-Party Materials.
|
|
155
|
+
|
|
156
|
+
You must not remove or obscure attribution notices required by applicable
|
|
157
|
+
Third-Party Materials licenses.
|
|
158
|
+
|
|
159
|
+
When redistributing the Software or a derivative work for Non-Commercial Use,
|
|
160
|
+
you must retain a copy of this License and clearly identify the original
|
|
161
|
+
Software and any substantial modifications you have made.
|
|
162
|
+
|
|
163
|
+
TRADEMARKS
|
|
164
|
+
|
|
165
|
+
This License does not grant permission to use any trademarks, service marks,
|
|
166
|
+
logos, or names belonging to the Licensor, except as reasonably necessary to
|
|
167
|
+
identify the Software or accurately describe its origin.
|
|
168
|
+
|
|
169
|
+
NO WARRANTY
|
|
170
|
+
|
|
171
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
172
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
173
|
+
FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT.
|
|
174
|
+
|
|
175
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR SHALL NOT BE LIABLE FOR
|
|
176
|
+
ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN
|
|
177
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
178
|
+
|
|
179
|
+
TERMINATION
|
|
180
|
+
|
|
181
|
+
The rights granted under this License terminate automatically if you violate
|
|
182
|
+
any term of this License.
|
|
183
|
+
|
|
184
|
+
Upon termination, you must cease exercising the rights granted by this
|
|
185
|
+
License and, where reasonably practicable, cease distributing or making
|
|
186
|
+
available copies of the Software under this License.
|
|
187
|
+
|
|
188
|
+
Termination does not affect rights that have been independently granted
|
|
189
|
+
under applicable licenses for Third-Party Materials.
|
|
190
|
+
|
|
191
|
+
COMMERCIAL LICENSE
|
|
192
|
+
|
|
193
|
+
Nothing in this License prevents the Licensor from granting separate
|
|
194
|
+
commercial licenses to any person or organization.
|
|
195
|
+
|
|
196
|
+
A commercial license may grant rights that are not available under this
|
|
197
|
+
License, including Commercial Use, commercial distribution, incorporation
|
|
198
|
+
into commercial products or services, and use of the Software in commercial
|
|
199
|
+
production systems.
|
|
200
|
+
|
|
201
|
+
Commercial license terms, including fees and permitted uses, are determined
|
|
202
|
+
separately by the Licensor.
|
|
203
|
+
|
|
204
|
+
RESERVATION OF RIGHTS
|
|
205
|
+
|
|
206
|
+
The Software and all rights not expressly granted under this License remain
|
|
207
|
+
the property of the Licensor or their respective copyright holders.
|
|
208
|
+
|
|
209
|
+
This License does not transfer ownership of the Software to any recipient.
|
|
210
|
+
|
|
211
|
+
SEVERABILITY
|
|
212
|
+
|
|
213
|
+
If any provision of this License is determined to be invalid or
|
|
214
|
+
unenforceable, the remaining provisions shall remain in effect to the
|
|
215
|
+
maximum extent permitted by law.
|
|
216
|
+
|
|
217
|
+
ENTIRE LICENSE
|
|
218
|
+
|
|
219
|
+
This License constitutes the complete license granted by the Licensor for
|
|
220
|
+
the Software and supersedes any conflicting license statement made by the
|
|
221
|
+
Licensor regarding the Software, except for separate written commercial
|
|
222
|
+
licenses and the licenses governing Third-Party Materials.
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: torch-omni-tool
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Collection of pytorch tools and blocks
|
|
5
|
+
Project-URL: Homepage, https://github.com/Mateo-drr/torch-omni-tool
|
|
6
|
+
Project-URL: Repository, https://github.com/Mateo-drr/torch-omni-tool.git
|
|
7
|
+
Author-email: Mateo Rodriguez <mateodrr@gmail.com>
|
|
8
|
+
License: MLTools NON-COMMERCIAL SOURCE-AVAILABLE LICENSE v1.0
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Mateo Rodriguez
|
|
11
|
+
|
|
12
|
+
DEFINITIONS
|
|
13
|
+
|
|
14
|
+
"Software" means the original software contained in this repository that is
|
|
15
|
+
copyrighted by the Licensor, including source code, documentation, and other
|
|
16
|
+
original materials, but excluding Third-Party Materials.
|
|
17
|
+
|
|
18
|
+
"Licensor" means Mateo Rodriguez, the copyright holder of the Software.
|
|
19
|
+
|
|
20
|
+
"Third-Party Materials" means software, source code, models, data, assets,
|
|
21
|
+
documentation, or other materials included in or distributed with the
|
|
22
|
+
Software that are not owned by the Licensor and are identified as being
|
|
23
|
+
subject to separate license terms.
|
|
24
|
+
|
|
25
|
+
"Commercial Use" means any use of the Software that is primarily intended
|
|
26
|
+
for or directed toward commercial advantage, monetary compensation, revenue
|
|
27
|
+
generation, or the operation or delivery of a commercial product or service.
|
|
28
|
+
|
|
29
|
+
Commercial Use includes, without limitation:
|
|
30
|
+
|
|
31
|
+
incorporating the Software into a product or service that is sold,
|
|
32
|
+
licensed, or otherwise provided for monetary compensation;
|
|
33
|
+
|
|
34
|
+
using the Software to provide a paid service, API, hosted service, SaaS,
|
|
35
|
+
or other revenue-generating service;
|
|
36
|
+
|
|
37
|
+
using the Software as a material component of a commercial production
|
|
38
|
+
system or workflow;
|
|
39
|
+
|
|
40
|
+
using the Software to develop, operate, or deliver products or services
|
|
41
|
+
for which the user or another party receives monetary compensation;
|
|
42
|
+
|
|
43
|
+
distributing the Software, or a derivative work based on it, as part of
|
|
44
|
+
a commercial product or service;
|
|
45
|
+
|
|
46
|
+
using the Software for the primary purpose of obtaining a commercial
|
|
47
|
+
advantage or generating revenue.
|
|
48
|
+
|
|
49
|
+
Commercial Use does not arise solely because the person or organization
|
|
50
|
+
using the Software is a for-profit company, employs paid staff, or otherwise
|
|
51
|
+
engages in commercial activities, provided that the particular use of the
|
|
52
|
+
Software is not itself directed toward commercial advantage, monetary
|
|
53
|
+
compensation, revenue generation, or the operation or delivery of a
|
|
54
|
+
commercial product or service.
|
|
55
|
+
|
|
56
|
+
"Non-Commercial Use" means use of the Software that is not Commercial Use,
|
|
57
|
+
including personal use, hobby projects, education, academic research,
|
|
58
|
+
non-commercial research, experimentation, evaluation, and other activities
|
|
59
|
+
that are not primarily intended for or directed toward commercial advantage
|
|
60
|
+
or monetary compensation.
|
|
61
|
+
|
|
62
|
+
The determination of whether a particular use constitutes Commercial Use
|
|
63
|
+
shall be based on the purpose and circumstances of that use, rather than
|
|
64
|
+
solely on the identity or legal status of the user or organization.
|
|
65
|
+
|
|
66
|
+
LICENSE GRANT
|
|
67
|
+
|
|
68
|
+
Subject to the terms of this License, the Licensor grants you a worldwide,
|
|
69
|
+
non-exclusive, royalty-free, non-transferable license to:
|
|
70
|
+
|
|
71
|
+
use the Software for Non-Commercial Use;
|
|
72
|
+
|
|
73
|
+
copy the Software for Non-Commercial Use;
|
|
74
|
+
|
|
75
|
+
study the Software;
|
|
76
|
+
|
|
77
|
+
modify the Software;
|
|
78
|
+
|
|
79
|
+
create derivative works based on the Software; and
|
|
80
|
+
|
|
81
|
+
distribute original or modified copies of the Software for Non-Commercial
|
|
82
|
+
Use.
|
|
83
|
+
|
|
84
|
+
COMMERCIAL USE
|
|
85
|
+
|
|
86
|
+
Commercial Use of the Software is not permitted under this License.
|
|
87
|
+
|
|
88
|
+
You may engage in Commercial Use only after obtaining a separate commercial
|
|
89
|
+
license or other written permission from the Licensor.
|
|
90
|
+
|
|
91
|
+
The Licensor may grant commercial licenses under separate terms, including
|
|
92
|
+
terms requiring payment of a license fee, subscription, royalty, or other
|
|
93
|
+
compensation.
|
|
94
|
+
|
|
95
|
+
A commercial license may authorize uses that are prohibited by this License,
|
|
96
|
+
including incorporation into commercial products or services, commercial
|
|
97
|
+
distribution, operation of commercial production systems, and provision of
|
|
98
|
+
paid services using the Software.
|
|
99
|
+
|
|
100
|
+
Nothing in this section prohibits Non-Commercial Use merely because the user
|
|
101
|
+
is employed by, affiliated with, or otherwise associated with a commercial
|
|
102
|
+
organization, provided that the particular use qualifies as Non-Commercial
|
|
103
|
+
Use under this License.
|
|
104
|
+
|
|
105
|
+
REDISTRIBUTION
|
|
106
|
+
|
|
107
|
+
You may redistribute the Software, including modified versions, for
|
|
108
|
+
Non-Commercial Use provided that:
|
|
109
|
+
|
|
110
|
+
this License is included with the redistribution;
|
|
111
|
+
|
|
112
|
+
copyright and attribution notices belonging to the Licensor are preserved;
|
|
113
|
+
|
|
114
|
+
you clearly identify modifications that you have made; and
|
|
115
|
+
|
|
116
|
+
you do not represent modified versions as being the original Software.
|
|
117
|
+
|
|
118
|
+
You may not redistribute the Software for Commercial Use without a separate
|
|
119
|
+
commercial license from the Licensor.
|
|
120
|
+
|
|
121
|
+
MODIFICATIONS AND DERIVATIVE WORKS
|
|
122
|
+
|
|
123
|
+
You are permitted to modify the Software and create derivative works for
|
|
124
|
+
Non-Commercial Use.
|
|
125
|
+
|
|
126
|
+
Your modifications and derivative works based on the Software remain subject
|
|
127
|
+
to the restrictions on Commercial Use contained in this License, except where
|
|
128
|
+
a separate license applies to Third-Party Materials.
|
|
129
|
+
|
|
130
|
+
You may publish and distribute your modifications and derivative works for
|
|
131
|
+
Non-Commercial Use, provided that you comply with this License and all
|
|
132
|
+
applicable licenses for Third-Party Materials.
|
|
133
|
+
|
|
134
|
+
THIRD-PARTY MATERIALS
|
|
135
|
+
|
|
136
|
+
This License does not apply to Third-Party Materials.
|
|
137
|
+
|
|
138
|
+
Third-Party Materials remain subject to their respective original licenses,
|
|
139
|
+
copyright notices, and other applicable terms.
|
|
140
|
+
|
|
141
|
+
Nothing in this License is intended to restrict, revoke, or replace rights
|
|
142
|
+
that you receive directly from a third-party copyright holder under a
|
|
143
|
+
separate license.
|
|
144
|
+
|
|
145
|
+
Where Third-Party Materials are distributed under a license that permits
|
|
146
|
+
Commercial Use, this License does not revoke or restrict those permissions
|
|
147
|
+
with respect to those Third-Party Materials.
|
|
148
|
+
|
|
149
|
+
Where Third-Party Materials are subject to additional restrictions, those
|
|
150
|
+
restrictions continue to apply.
|
|
151
|
+
|
|
152
|
+
The Licensor makes no claim of ownership over Third-Party Materials.
|
|
153
|
+
|
|
154
|
+
A list of known Third-Party Materials and their applicable licenses may be
|
|
155
|
+
provided in the THIRD_PARTY_LICENSES directory or accompanying
|
|
156
|
+
documentation.
|
|
157
|
+
|
|
158
|
+
ATTRIBUTION AND COPYRIGHT NOTICES
|
|
159
|
+
|
|
160
|
+
You must retain existing copyright notices and license notices belonging to
|
|
161
|
+
the Licensor or Third-Party Materials.
|
|
162
|
+
|
|
163
|
+
You must not remove or obscure attribution notices required by applicable
|
|
164
|
+
Third-Party Materials licenses.
|
|
165
|
+
|
|
166
|
+
When redistributing the Software or a derivative work for Non-Commercial Use,
|
|
167
|
+
you must retain a copy of this License and clearly identify the original
|
|
168
|
+
Software and any substantial modifications you have made.
|
|
169
|
+
|
|
170
|
+
TRADEMARKS
|
|
171
|
+
|
|
172
|
+
This License does not grant permission to use any trademarks, service marks,
|
|
173
|
+
logos, or names belonging to the Licensor, except as reasonably necessary to
|
|
174
|
+
identify the Software or accurately describe its origin.
|
|
175
|
+
|
|
176
|
+
NO WARRANTY
|
|
177
|
+
|
|
178
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
179
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
180
|
+
FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT.
|
|
181
|
+
|
|
182
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR SHALL NOT BE LIABLE FOR
|
|
183
|
+
ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN
|
|
184
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
185
|
+
|
|
186
|
+
TERMINATION
|
|
187
|
+
|
|
188
|
+
The rights granted under this License terminate automatically if you violate
|
|
189
|
+
any term of this License.
|
|
190
|
+
|
|
191
|
+
Upon termination, you must cease exercising the rights granted by this
|
|
192
|
+
License and, where reasonably practicable, cease distributing or making
|
|
193
|
+
available copies of the Software under this License.
|
|
194
|
+
|
|
195
|
+
Termination does not affect rights that have been independently granted
|
|
196
|
+
under applicable licenses for Third-Party Materials.
|
|
197
|
+
|
|
198
|
+
COMMERCIAL LICENSE
|
|
199
|
+
|
|
200
|
+
Nothing in this License prevents the Licensor from granting separate
|
|
201
|
+
commercial licenses to any person or organization.
|
|
202
|
+
|
|
203
|
+
A commercial license may grant rights that are not available under this
|
|
204
|
+
License, including Commercial Use, commercial distribution, incorporation
|
|
205
|
+
into commercial products or services, and use of the Software in commercial
|
|
206
|
+
production systems.
|
|
207
|
+
|
|
208
|
+
Commercial license terms, including fees and permitted uses, are determined
|
|
209
|
+
separately by the Licensor.
|
|
210
|
+
|
|
211
|
+
RESERVATION OF RIGHTS
|
|
212
|
+
|
|
213
|
+
The Software and all rights not expressly granted under this License remain
|
|
214
|
+
the property of the Licensor or their respective copyright holders.
|
|
215
|
+
|
|
216
|
+
This License does not transfer ownership of the Software to any recipient.
|
|
217
|
+
|
|
218
|
+
SEVERABILITY
|
|
219
|
+
|
|
220
|
+
If any provision of this License is determined to be invalid or
|
|
221
|
+
unenforceable, the remaining provisions shall remain in effect to the
|
|
222
|
+
maximum extent permitted by law.
|
|
223
|
+
|
|
224
|
+
ENTIRE LICENSE
|
|
225
|
+
|
|
226
|
+
This License constitutes the complete license granted by the Licensor for
|
|
227
|
+
the Software and supersedes any conflicting license statement made by the
|
|
228
|
+
Licensor regarding the Software, except for separate written commercial
|
|
229
|
+
licenses and the licenses governing Third-Party Materials.
|
|
230
|
+
License-File: LICENSE
|
|
231
|
+
Requires-Python: >=3.12
|
|
232
|
+
Requires-Dist: numpy
|
|
233
|
+
Requires-Dist: pillow
|
|
234
|
+
Requires-Dist: torch
|
|
235
|
+
Requires-Dist: torchvision
|
|
236
|
+
Requires-Dist: tqdm
|
|
237
|
+
Requires-Dist: wandb
|
|
238
|
+
Provides-Extra: dev
|
|
239
|
+
Requires-Dist: black; extra == 'dev'
|
|
240
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
241
|
+
Requires-Dist: pylint; extra == 'dev'
|
|
242
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
243
|
+
Requires-Dist: types-tqdm; extra == 'dev'
|
|
244
|
+
Description-Content-Type: text/markdown
|
|
245
|
+
|
|
246
|
+
# torch-omni-tool
|
|
247
|
+
|
|
248
|
+
A small PyTorch library of reusable network blocks plus a minimal training scaffold
|
|
249
|
+
(config, dataloaders, train/eval loops, logging helpers).
|
|
250
|
+
|
|
251
|
+
Everything is plain `nn.Module` code with type hints and no framework dependencies, so
|
|
252
|
+
blocks can be copied into any project or imported from here.
|
|
253
|
+
|
|
254
|
+
## Installation
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pip install -e ".[dev]" # runtime + pytest / pylint / mypy / black / types-tqdm
|
|
258
|
+
pip install -e ".[wandb]" # adds the optional Weights & Biases logging dependency
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Requires Python >= 3.12. `wandb` is optional and only imported when `Config.wb` is enabled,
|
|
262
|
+
so installing it is not needed to use the blocks.
|
|
263
|
+
|
|
264
|
+
## What is inside
|
|
265
|
+
|
|
266
|
+
| Path | Contents |
|
|
267
|
+
| --- | --- |
|
|
268
|
+
| [`torch_omni_tool`](torch_omni_tool/blocks/README.md) | Network blocks: ConvNeXt V2, GRN, RepMoDE, RRDB, Squeeze-and-Excite, ViT positional embeddings |
|
|
269
|
+
| [`torch_omni_tool`](torch_omni_tool/activations/README.md) | Activation layers: the periodic `Snake` activation |
|
|
270
|
+
| [`torch_omni_tool`](torch_omni_tool/normalizations/README.md) | `LayerNorm` for `[b, c, h, w]` and `[b, h, w, c]` |
|
|
271
|
+
| [`torch_omni_tool`](torch_omni_tool/datasets/README.md) | `Dataset` / `DataLoader` factory and 3D augmentations |
|
|
272
|
+
| `torch_omni_tool` | `Config` dataclass plus a module-level `config` singleton |
|
|
273
|
+
| `torch_omni_tool` | `SampleNet`, a placeholder autoencoder-style model |
|
|
274
|
+
| `torch_omni_tool` | `run_model`, `train_loop`, `eval_loop` |
|
|
275
|
+
| `torch_omni_tool` | Timing, metric formatting and epoch bookkeeping helpers |
|
|
276
|
+
| `torch_omni_tool` | Entry point that wires the pieces together |
|
|
277
|
+
| [`tests/`](tests/README.md) | Pytest suite (currently the GRN block) |
|
|
278
|
+
|
|
279
|
+
Each folder has its own README with the details, tensor shapes and references. Every
|
|
280
|
+
`__init__.py` is empty, so blocks are imported from their leaf module:
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
from torch_omni_tool.blocks.SEB.SEB import SEBlock
|
|
284
|
+
from torch_omni_tool.blocks.ConvNeXtV2.GRN import GRN
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Note the inconsistent casing in the paths (`RRDB_2D.py` vs `RRDB_3d.py`) and the typo in
|
|
288
|
+
`normalizations/layern_norm_2d.py`.
|
|
289
|
+
|
|
290
|
+
## Blocks at a glance
|
|
291
|
+
|
|
292
|
+
| Block | Input | Import |
|
|
293
|
+
| --- | --- | --- |
|
|
294
|
+
| `ConvNeXtBlock` | `[B, C, H, W]` | `torch_omni_tool.blocks.ConvNeXtV2.ConvNeXtV2` |
|
|
295
|
+
| `GRN` | `[B, C, H, W]` | `torch_omni_tool.blocks.ConvNeXtV2.GRN` |
|
|
296
|
+
| `MoDE`, `MoDEConv2D` | `[B, C, H, W]` | `torch_omni_tool.blocks.RepMoDE.RepMoDE_2d` |
|
|
297
|
+
| `MoDEConv`, encoder/decoder blocks | `[B, C, L]` and `[B, C, D, H, W]` | `torch_omni_tool.blocks.RepMoDE.RepMoDE_1d` / `RepMoDE_3d` |
|
|
298
|
+
| `RRDB`, `RRDB_3D` | `[B, C, H, W]`, `[B, C, D, H, W]` | `torch_omni_tool.blocks.RRDB.RRDB_2D` / `RRDB_3d` |
|
|
299
|
+
| `SEBlock` | `[B, C, H, W]` | `torch_omni_tool.blocks.SEB.SEB` |
|
|
300
|
+
| `PositionEmbeddingSine` | `[B, C, H, W]` | `torch_omni_tool.blocks.ViT.position_embedding_sine` |
|
|
301
|
+
| `Snake` | `[B, C, H, W]` | `torch_omni_tool.activations.snake` |
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
import torch
|
|
305
|
+
from torch_omni_tool.blocks.ConvNeXtV2.GRN import GRN
|
|
306
|
+
|
|
307
|
+
y = GRN(64)(torch.randn(2, 64, 56, 56)) # [2, 64, 56, 56]
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Configuration and training
|
|
311
|
+
|
|
312
|
+
`Config` holds every hyperparameter and option of a run; there is no config file or CLI
|
|
313
|
+
parsing, so edit the dataclass defaults or override attributes on the `config` singleton.
|
|
314
|
+
Print the defaults with:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
python -m torch_omni_tool.config
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Run the scaffold:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
python -m torch_omni_tool.training
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
The flow is `training.py` → `make_dl` → `SampleNet` → `loops.train_loop` /
|
|
327
|
+
`loops.eval_loop` → `utils.finish_epoch`, with `torch.amp.autocast` and `GradScaler` when
|
|
328
|
+
`config.half_p` is set. The loss is autoencoder-style (`criterion(samples["data"], output)`),
|
|
329
|
+
so the target is the input. The training body sits inside an `if __name__ == "__main__"`
|
|
330
|
+
guard, so importing the module has no side effects.
|
|
331
|
+
|
|
332
|
+
## Development
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
pytest # tests/ (testpaths set in pyproject.toml)
|
|
336
|
+
mypy # strict mode over torch_omni_tool/
|
|
337
|
+
pylint torch_omni_tool
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
CI (`.github/workflows/ci.yml`) runs Python 3.12 on Ubuntu: install, pylint, mypy and
|
|
341
|
+
pytest. Mypy is clean in strict mode; pylint is marked `continue-on-error` until the
|
|
342
|
+
remaining warnings are fixed.
|
|
343
|
+
|
|
344
|
+
## Known issues
|
|
345
|
+
|
|
346
|
+
- `RepMoDE_1d.one_hot_task_embedding` and `RepMoDE_3d.one_hot_task_embedding` are module
|
|
347
|
+
level functions that take `self: Any` and cannot be called.
|
|
348
|
+
- `MoDEConv(..., causal=True)` in `RepMoDE_1d.py` pads the channel dim instead of the time
|
|
349
|
+
dim.
|
|
350
|
+
- `PositionEmbeddingSine` needs an even `(channels + 1) // 2`; odd channel counts raise
|
|
351
|
+
from `torch.stack`.
|
|
352
|
+
- `augmentations_3d.random_local_rotation` expects a 4D `[b, 1, H, W]` chunk and a 2D
|
|
353
|
+
label; 5D volumes raise `RuntimeError`.
|
|
354
|
+
- `training.py` builds a scheduler but passes `scheduler=None` to `train_loop`, so it never
|
|
355
|
+
steps.
|
|
356
|
+
- In `RepMoDE_3d.MoDEConv` (and `RepMoDE_1d.MoDEConv` outside training), `eval()` mode uses
|
|
357
|
+
only the first task's expert weights for the whole batch.
|
|
358
|
+
- See the folder READMEs for block specific caveats.
|
|
359
|
+
|
|
360
|
+
## References
|
|
361
|
+
|
|
362
|
+
The blocks are re-implementations of published architectures. Original sources:
|
|
363
|
+
|
|
364
|
+
| Block | Source |
|
|
365
|
+
| --- | --- |
|
|
366
|
+
| `ConvNeXtBlock` | [ConvNeXt V2: ConvNet Modality Masking Pretraining](https://arxiv.org/abs/2301.03524) — [repo](https://github.com/facebookresearch/ConvNeXt-V2) |
|
|
367
|
+
| `GRN`, `LayerNorm` | [ConvNeXt: A ConvNet for the 2020s](https://arxiv.org/abs/2201.03597) — [repo](https://github.com/facebookresearch/ConvNeXt) |
|
|
368
|
+
| `MoDE*` (RepMoDE) | [RepMode: Learning to Re-parameterize Diverse Experts for Subcellular Structure Prediction (CVPR 2023)](https://arxiv.org/abs/2212.10066) — [repo](https://github.com/correr-zhou/RepMode) |
|
|
369
|
+
| `RRDB`, `RRDB_3D` | [ESRGAN: Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](https://arxiv.org/abs/1809.00219) — [repo](https://github.com/xinntao/ESRGAN) |
|
|
370
|
+
| `SEBlock` | [Squeeze-and-Excitation Networks (CVPR 2018)](https://arxiv.org/abs/1709.01507) |
|
|
371
|
+
| `PositionEmbeddingSine` | [End-to-End Object Detection with Transformers (DETR)](https://arxiv.org/abs/2005.12872) — [repo](https://github.com/facebookresearch/detr) |
|
|
372
|
+
| `Snake` | [Neural Networks Fail to Learn Periodic Functions and How to Fix It](https://arxiv.org/abs/2006.08195) |
|
|
373
|
+
| `random_local_rotation` | [Local Rotation Augmentation for 3D data](https://www.mdpi.com/2313-433X/9/2/46) |
|
|
374
|
+
| `cutmix` | [CutMix: Regularized Strategy for Mixup on Image Classification](https://arxiv.org/abs/1905.04899) |
|
|
375
|
+
|
|
376
|
+
## License
|
|
377
|
+
|
|
378
|
+
See `LICENSE`.
|