LunaStev
commited on
Commit
·
cff2458
1
Parent(s):
be83476
GitHub to Huggingface
Browse files- .gitignore +9 -0
- LICENSE +374 -0
- README.md +134 -1
- core/__init__.py +0 -0
- core/model.py +15 -0
- core/predictor.py +17 -0
- core/trainer.py +19 -0
- data/__init__.py +0 -0
- data/example_data.py +13 -0
- main.py +84 -0
- plugins/__init__.py +0 -0
- plugins/example_plugin.py +13 -0
- plugins/sample_plugin.py +13 -0
- requirements.txt +3 -0
- tests/__init__.py +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
target/
|
| 2 |
+
.venv/
|
| 3 |
+
|
| 4 |
+
.DS_Store
|
| 5 |
+
.idea/
|
| 6 |
+
.vscode/
|
| 7 |
+
|
| 8 |
+
*.log
|
| 9 |
+
*.tmp
|
LICENSE
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Mozilla Public License Version 2.0
|
| 2 |
+
==================================
|
| 3 |
+
LunaStev. FlowModel Project
|
| 4 |
+
|
| 5 |
+
1. Definitions
|
| 6 |
+
--------------
|
| 7 |
+
|
| 8 |
+
1.1. "Contributor"
|
| 9 |
+
means each individual or legal entity that creates, contributes to
|
| 10 |
+
the creation of, or owns Covered Software.
|
| 11 |
+
|
| 12 |
+
1.2. "Contributor Version"
|
| 13 |
+
means the combination of the Contributions of others (if any) used
|
| 14 |
+
by a Contributor and that particular Contributor's Contribution.
|
| 15 |
+
|
| 16 |
+
1.3. "Contribution"
|
| 17 |
+
means Covered Software of a particular Contributor.
|
| 18 |
+
|
| 19 |
+
1.4. "Covered Software"
|
| 20 |
+
means Source Code Form to which the initial Contributor has attached
|
| 21 |
+
the notice in Exhibit A, the Executable Form of such Source Code
|
| 22 |
+
Form, and Modifications of such Source Code Form, in each case
|
| 23 |
+
including portions thereof.
|
| 24 |
+
|
| 25 |
+
1.5. "Incompatible With Secondary Licenses"
|
| 26 |
+
means
|
| 27 |
+
|
| 28 |
+
(a) that the initial Contributor has attached the notice described
|
| 29 |
+
in Exhibit B to the Covered Software; or
|
| 30 |
+
|
| 31 |
+
(b) that the Covered Software was made available under the terms of
|
| 32 |
+
version 1.1 or earlier of the License, but not also under the
|
| 33 |
+
terms of a Secondary License.
|
| 34 |
+
|
| 35 |
+
1.6. "Executable Form"
|
| 36 |
+
means any form of the work other than Source Code Form.
|
| 37 |
+
|
| 38 |
+
1.7. "Larger Work"
|
| 39 |
+
means a work that combines Covered Software with other material, in
|
| 40 |
+
a separate file or files, that is not Covered Software.
|
| 41 |
+
|
| 42 |
+
1.8. "License"
|
| 43 |
+
means this document.
|
| 44 |
+
|
| 45 |
+
1.9. "Licensable"
|
| 46 |
+
means having the right to grant, to the maximum extent possible,
|
| 47 |
+
whether at the time of the initial grant or subsequently, any and
|
| 48 |
+
all of the rights conveyed by this License.
|
| 49 |
+
|
| 50 |
+
1.10. "Modifications"
|
| 51 |
+
means any of the following:
|
| 52 |
+
|
| 53 |
+
(a) any file in Source Code Form that results from an addition to,
|
| 54 |
+
deletion from, or modification of the contents of Covered
|
| 55 |
+
Software; or
|
| 56 |
+
|
| 57 |
+
(b) any new file in Source Code Form that contains any Covered
|
| 58 |
+
Software.
|
| 59 |
+
|
| 60 |
+
1.11. "Patent Claims" of a Contributor
|
| 61 |
+
means any patent claim(s), including without limitation, method,
|
| 62 |
+
process, and apparatus claims, in any patent Licensable by such
|
| 63 |
+
Contributor that would be infringed, but for the grant of the
|
| 64 |
+
License, by the making, using, selling, offering for sale, having
|
| 65 |
+
made, import, or transfer of either its Contributions or its
|
| 66 |
+
Contributor Version.
|
| 67 |
+
|
| 68 |
+
1.12. "Secondary License"
|
| 69 |
+
means either the GNU General Public License, Version 2.0, the GNU
|
| 70 |
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
| 71 |
+
Public License, Version 3.0, or any later versions of those
|
| 72 |
+
licenses.
|
| 73 |
+
|
| 74 |
+
1.13. "Source Code Form"
|
| 75 |
+
means the form of the work preferred for making modifications.
|
| 76 |
+
|
| 77 |
+
1.14. "You" (or "Your")
|
| 78 |
+
means an individual or a legal entity exercising rights under this
|
| 79 |
+
License. For legal entities, "You" includes any entity that
|
| 80 |
+
controls, is controlled by, or is under common control with You. For
|
| 81 |
+
purposes of this definition, "control" means (a) the power, direct
|
| 82 |
+
or indirect, to cause the direction or management of such entity,
|
| 83 |
+
whether by contract or otherwise, or (b) ownership of more than
|
| 84 |
+
fifty percent (50%) of the outstanding shares or beneficial
|
| 85 |
+
ownership of such entity.
|
| 86 |
+
|
| 87 |
+
2. License Grants and Conditions
|
| 88 |
+
--------------------------------
|
| 89 |
+
|
| 90 |
+
2.1. Grants
|
| 91 |
+
|
| 92 |
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
| 93 |
+
non-exclusive license:
|
| 94 |
+
|
| 95 |
+
(a) under intellectual property rights (other than patent or trademark)
|
| 96 |
+
Licensable by such Contributor to use, reproduce, make available,
|
| 97 |
+
modify, display, perform, distribute, and otherwise exploit its
|
| 98 |
+
Contributions, either on an unmodified basis, with Modifications, or
|
| 99 |
+
as part of a Larger Work; and
|
| 100 |
+
|
| 101 |
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
| 102 |
+
for sale, have made, import, and otherwise transfer either its
|
| 103 |
+
Contributions or its Contributor Version.
|
| 104 |
+
|
| 105 |
+
2.2. Effective Date
|
| 106 |
+
|
| 107 |
+
The licenses granted in Section 2.1 with respect to any Contribution
|
| 108 |
+
become effective for each Contribution on the date the Contributor first
|
| 109 |
+
distributes such Contribution.
|
| 110 |
+
|
| 111 |
+
2.3. Limitations on Grant Scope
|
| 112 |
+
|
| 113 |
+
The licenses granted in this Section 2 are the only rights granted under
|
| 114 |
+
this License. No additional rights or licenses will be implied from the
|
| 115 |
+
distribution or licensing of Covered Software under this License.
|
| 116 |
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
| 117 |
+
Contributor:
|
| 118 |
+
|
| 119 |
+
(a) for any code that a Contributor has removed from Covered Software;
|
| 120 |
+
or
|
| 121 |
+
|
| 122 |
+
(b) for infringements caused by: (i) Your and any other third party's
|
| 123 |
+
modifications of Covered Software, or (ii) the combination of its
|
| 124 |
+
Contributions with other software (except as part of its Contributor
|
| 125 |
+
Version); or
|
| 126 |
+
|
| 127 |
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
| 128 |
+
its Contributions.
|
| 129 |
+
|
| 130 |
+
This License does not grant any rights in the trademarks, service marks,
|
| 131 |
+
or logos of any Contributor (except as may be necessary to comply with
|
| 132 |
+
the notice requirements in Section 3.4).
|
| 133 |
+
|
| 134 |
+
2.4. Subsequent Licenses
|
| 135 |
+
|
| 136 |
+
No Contributor makes additional grants as a result of Your choice to
|
| 137 |
+
distribute the Covered Software under a subsequent version of this
|
| 138 |
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
| 139 |
+
permitted under the terms of Section 3.3).
|
| 140 |
+
|
| 141 |
+
2.5. Representation
|
| 142 |
+
|
| 143 |
+
Each Contributor represents that the Contributor believes its
|
| 144 |
+
Contributions are its original creation(s) or it has sufficient rights
|
| 145 |
+
to grant the rights to its Contributions conveyed by this License.
|
| 146 |
+
|
| 147 |
+
2.6. Fair Use
|
| 148 |
+
|
| 149 |
+
This License is not intended to limit any rights You have under
|
| 150 |
+
applicable copyright doctrines of fair use, fair dealing, or other
|
| 151 |
+
equivalents.
|
| 152 |
+
|
| 153 |
+
2.7. Conditions
|
| 154 |
+
|
| 155 |
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
| 156 |
+
in Section 2.1.
|
| 157 |
+
|
| 158 |
+
3. Responsibilities
|
| 159 |
+
-------------------
|
| 160 |
+
|
| 161 |
+
3.1. Distribution of Source Form
|
| 162 |
+
|
| 163 |
+
All distribution of Covered Software in Source Code Form, including any
|
| 164 |
+
Modifications that You create or to which You contribute, must be under
|
| 165 |
+
the terms of this License. You must inform recipients that the Source
|
| 166 |
+
Code Form of the Covered Software is governed by the terms of this
|
| 167 |
+
License, and how they can obtain a copy of this License. You may not
|
| 168 |
+
attempt to alter or restrict the recipients' rights in the Source Code
|
| 169 |
+
Form.
|
| 170 |
+
|
| 171 |
+
3.2. Distribution of Executable Form
|
| 172 |
+
|
| 173 |
+
If You distribute Covered Software in Executable Form then:
|
| 174 |
+
|
| 175 |
+
(a) such Covered Software must also be made available in Source Code
|
| 176 |
+
Form, as described in Section 3.1, and You must inform recipients of
|
| 177 |
+
the Executable Form how they can obtain a copy of such Source Code
|
| 178 |
+
Form by reasonable means in a timely manner, at a charge no more
|
| 179 |
+
than the cost of distribution to the recipient; and
|
| 180 |
+
|
| 181 |
+
(b) You may distribute such Executable Form under the terms of this
|
| 182 |
+
License, or sublicense it under different terms, provided that the
|
| 183 |
+
license for the Executable Form does not attempt to limit or alter
|
| 184 |
+
the recipients' rights in the Source Code Form under this License.
|
| 185 |
+
|
| 186 |
+
3.3. Distribution of a Larger Work
|
| 187 |
+
|
| 188 |
+
You may create and distribute a Larger Work under terms of Your choice,
|
| 189 |
+
provided that You also comply with the requirements of this License for
|
| 190 |
+
the Covered Software. If the Larger Work is a combination of Covered
|
| 191 |
+
Software with a work governed by one or more Secondary Licenses, and the
|
| 192 |
+
Covered Software is not Incompatible With Secondary Licenses, this
|
| 193 |
+
License permits You to additionally distribute such Covered Software
|
| 194 |
+
under the terms of such Secondary License(s), so that the recipient of
|
| 195 |
+
the Larger Work may, at their option, further distribute the Covered
|
| 196 |
+
Software under the terms of either this License or such Secondary
|
| 197 |
+
License(s).
|
| 198 |
+
|
| 199 |
+
3.4. Notices
|
| 200 |
+
|
| 201 |
+
You may not remove or alter the substance of any license notices
|
| 202 |
+
(including copyright notices, patent notices, disclaimers of warranty,
|
| 203 |
+
or limitations of liability) contained within the Source Code Form of
|
| 204 |
+
the Covered Software, except that You may alter any license notices to
|
| 205 |
+
the extent required to remedy known factual inaccuracies.
|
| 206 |
+
|
| 207 |
+
3.5. Application of Additional Terms
|
| 208 |
+
|
| 209 |
+
You may choose to offer, and to charge a fee for, warranty, support,
|
| 210 |
+
indemnity or liability obligations to one or more recipients of Covered
|
| 211 |
+
Software. However, You may do so only on Your own behalf, and not on
|
| 212 |
+
behalf of any Contributor. You must make it absolutely clear that any
|
| 213 |
+
such warranty, support, indemnity, or liability obligation is offered by
|
| 214 |
+
You alone, and You hereby agree to indemnify every Contributor for any
|
| 215 |
+
liability incurred by such Contributor as a result of warranty, support,
|
| 216 |
+
indemnity or liability terms You offer. You may include additional
|
| 217 |
+
disclaimers of warranty and limitations of liability specific to any
|
| 218 |
+
jurisdiction.
|
| 219 |
+
|
| 220 |
+
4. Inability to Comply Due to Statute or Regulation
|
| 221 |
+
---------------------------------------------------
|
| 222 |
+
|
| 223 |
+
If it is impossible for You to comply with any of the terms of this
|
| 224 |
+
License with respect to some or all of the Covered Software due to
|
| 225 |
+
statute, judicial order, or regulation then You must: (a) comply with
|
| 226 |
+
the terms of this License to the maximum extent possible; and (b)
|
| 227 |
+
describe the limitations and the code they affect. Such description must
|
| 228 |
+
be placed in a text file included with all distributions of the Covered
|
| 229 |
+
Software under this License. Except to the extent prohibited by statute
|
| 230 |
+
or regulation, such description must be sufficiently detailed for a
|
| 231 |
+
recipient of ordinary skill to be able to understand it.
|
| 232 |
+
|
| 233 |
+
5. Termination
|
| 234 |
+
--------------
|
| 235 |
+
|
| 236 |
+
5.1. The rights granted under this License will terminate automatically
|
| 237 |
+
if You fail to comply with any of its terms. However, if You become
|
| 238 |
+
compliant, then the rights granted under this License from a particular
|
| 239 |
+
Contributor are reinstated (a) provisionally, unless and until such
|
| 240 |
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
| 241 |
+
ongoing basis, if such Contributor fails to notify You of the
|
| 242 |
+
non-compliance by some reasonable means prior to 60 days after You have
|
| 243 |
+
come back into compliance. Moreover, Your grants from a particular
|
| 244 |
+
Contributor are reinstated on an ongoing basis if such Contributor
|
| 245 |
+
notifies You of the non-compliance by some reasonable means, this is the
|
| 246 |
+
first time You have received notice of non-compliance with this License
|
| 247 |
+
from such Contributor, and You become compliant prior to 30 days after
|
| 248 |
+
Your receipt of the notice.
|
| 249 |
+
|
| 250 |
+
5.2. If You initiate litigation against any entity by asserting a patent
|
| 251 |
+
infringement claim (excluding declaratory judgment actions,
|
| 252 |
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
| 253 |
+
directly or indirectly infringes any patent, then the rights granted to
|
| 254 |
+
You by any and all Contributors for the Covered Software under Section
|
| 255 |
+
2.1 of this License shall terminate.
|
| 256 |
+
|
| 257 |
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
| 258 |
+
end user license agreements (excluding distributors and resellers) which
|
| 259 |
+
have been validly granted by You or Your distributors under this License
|
| 260 |
+
prior to termination shall survive termination.
|
| 261 |
+
|
| 262 |
+
************************************************************************
|
| 263 |
+
* *
|
| 264 |
+
* 6. Disclaimer of Warranty *
|
| 265 |
+
* ------------------------- *
|
| 266 |
+
* *
|
| 267 |
+
* Covered Software is provided under this License on an "as is" *
|
| 268 |
+
* basis, without warranty of any kind, either expressed, implied, or *
|
| 269 |
+
* statutory, including, without limitation, warranties that the *
|
| 270 |
+
* Covered Software is free of defects, merchantable, fit for a *
|
| 271 |
+
* particular purpose or non-infringing. The entire risk as to the *
|
| 272 |
+
* quality and performance of the Covered Software is with You. *
|
| 273 |
+
* Should any Covered Software prove defective in any respect, You *
|
| 274 |
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
| 275 |
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
| 276 |
+
* essential part of this License. No use of any Covered Software is *
|
| 277 |
+
* authorized under this License except under this disclaimer. *
|
| 278 |
+
* *
|
| 279 |
+
************************************************************************
|
| 280 |
+
|
| 281 |
+
************************************************************************
|
| 282 |
+
* *
|
| 283 |
+
* 7. Limitation of Liability *
|
| 284 |
+
* -------------------------- *
|
| 285 |
+
* *
|
| 286 |
+
* Under no circumstances and under no legal theory, whether tort *
|
| 287 |
+
* (including negligence), contract, or otherwise, shall any *
|
| 288 |
+
* Contributor, or anyone who distributes Covered Software as *
|
| 289 |
+
* permitted above, be liable to You for any direct, indirect, *
|
| 290 |
+
* special, incidental, or consequential damages of any character *
|
| 291 |
+
* including, without limitation, damages for lost profits, loss of *
|
| 292 |
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
| 293 |
+
* and all other commercial damages or losses, even if such party *
|
| 294 |
+
* shall have been informed of the possibility of such damages. This *
|
| 295 |
+
* limitation of liability shall not apply to liability for death or *
|
| 296 |
+
* personal injury resulting from such party's negligence to the *
|
| 297 |
+
* extent applicable law prohibits such limitation. Some *
|
| 298 |
+
* jurisdictions do not allow the exclusion or limitation of *
|
| 299 |
+
* incidental or consequential damages, so this exclusion and *
|
| 300 |
+
* limitation may not apply to You. *
|
| 301 |
+
* *
|
| 302 |
+
************************************************************************
|
| 303 |
+
|
| 304 |
+
8. Litigation
|
| 305 |
+
-------------
|
| 306 |
+
|
| 307 |
+
Any litigation relating to this License may be brought only in the
|
| 308 |
+
courts of a jurisdiction where the defendant maintains its principal
|
| 309 |
+
place of business and such litigation shall be governed by laws of that
|
| 310 |
+
jurisdiction, without reference to its conflict-of-law provisions.
|
| 311 |
+
Nothing in this Section shall prevent a party's ability to bring
|
| 312 |
+
cross-claims or counter-claims.
|
| 313 |
+
|
| 314 |
+
9. Miscellaneous
|
| 315 |
+
----------------
|
| 316 |
+
|
| 317 |
+
This License represents the complete agreement concerning the subject
|
| 318 |
+
matter hereof. If any provision of this License is held to be
|
| 319 |
+
unenforceable, such provision shall be reformed only to the extent
|
| 320 |
+
necessary to make it enforceable. Any law or regulation which provides
|
| 321 |
+
that the language of a contract shall be construed against the drafter
|
| 322 |
+
shall not be used to construe this License against a Contributor.
|
| 323 |
+
|
| 324 |
+
10. Versions of the License
|
| 325 |
+
---------------------------
|
| 326 |
+
|
| 327 |
+
10.1. New Versions
|
| 328 |
+
|
| 329 |
+
Mozilla Foundation is the license steward. Except as provided in Section
|
| 330 |
+
10.3, no one other than the license steward has the right to modify or
|
| 331 |
+
publish new versions of this License. Each version will be given a
|
| 332 |
+
distinguishing version number.
|
| 333 |
+
|
| 334 |
+
10.2. Effect of New Versions
|
| 335 |
+
|
| 336 |
+
You may distribute the Covered Software under the terms of the version
|
| 337 |
+
of the License under which You originally received the Covered Software,
|
| 338 |
+
or under the terms of any subsequent version published by the license
|
| 339 |
+
steward.
|
| 340 |
+
|
| 341 |
+
10.3. Modified Versions
|
| 342 |
+
|
| 343 |
+
If you create software not governed by this License, and you want to
|
| 344 |
+
create a new license for such software, you may create and use a
|
| 345 |
+
modified version of this License if you rename the license and remove
|
| 346 |
+
any references to the name of the license steward (except to note that
|
| 347 |
+
such modified license differs from this License).
|
| 348 |
+
|
| 349 |
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
| 350 |
+
Licenses
|
| 351 |
+
|
| 352 |
+
If You choose to distribute Source Code Form that is Incompatible With
|
| 353 |
+
Secondary Licenses under the terms of this version of the License, the
|
| 354 |
+
notice described in Exhibit B of this License must be attached.
|
| 355 |
+
|
| 356 |
+
Exhibit A - Source Code Form License Notice
|
| 357 |
+
-------------------------------------------
|
| 358 |
+
|
| 359 |
+
This Source Code Form is subject to the terms of the Mozilla Public
|
| 360 |
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
| 361 |
+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
| 362 |
+
|
| 363 |
+
If it is not possible or desirable to put the notice in a particular
|
| 364 |
+
file, then You may include the notice in a location (such as a LICENSE
|
| 365 |
+
file in a relevant directory) where a recipient would be likely to look
|
| 366 |
+
for such a notice.
|
| 367 |
+
|
| 368 |
+
You may add additional accurate notices of copyright ownership.
|
| 369 |
+
|
| 370 |
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
| 371 |
+
---------------------------------------------------------
|
| 372 |
+
|
| 373 |
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
| 374 |
+
defined by the Mozilla Public License, v. 2.0.
|
README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowModel
|
| 2 |
+
|
| 3 |
+
FlowModel is a lightweight and extensible machine learning framework designed for beginners who want to explore AI development. With its modular plugin-based architecture, users can easily extend its functionality while keeping the core simple and maintainable.
|
| 4 |
+
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
## Table of Contents
|
| 8 |
+
1. [Introduction](#introduction)
|
| 9 |
+
2. [Installation](#installation)
|
| 10 |
+
3. [Directory Structure](#directory-structure)
|
| 11 |
+
4. [Usage](#usage)
|
| 12 |
+
- [Training a Model](#training-a-model)
|
| 13 |
+
- [Adding Plugins](#adding-plugins)
|
| 14 |
+
5. [Creating Plugins](#creating-plugins)
|
| 15 |
+
6. [Command-Line Interface](#command-line-interface)
|
| 16 |
+
7. [Contributing](#contributing)
|
| 17 |
+
8. [License](#license)
|
| 18 |
+
|
| 19 |
---
|
| 20 |
+
|
| 21 |
+
## Introduction
|
| 22 |
+
FlowModel provides a simple entry point for experimenting with AI and machine learning. It allows users to start with a minimal framework and extend it by creating and adding plugins. The framework is designed to focus on simplicity, modularity, and extensibility.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Installation
|
| 27 |
+
|
| 28 |
+
### Prerequisites
|
| 29 |
+
- Python 3.8 or higher
|
| 30 |
+
- `pip` package manager
|
| 31 |
+
|
| 32 |
+
### Steps
|
| 33 |
+
1. Clone the repository:
|
| 34 |
+
```bash
|
| 35 |
+
git clone https://github.com/LunaStev/FlowModel.git
|
| 36 |
+
cd FlowModel
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
2. Create and activate a virtual environment:
|
| 40 |
+
```bash
|
| 41 |
+
python -m venv .venv
|
| 42 |
+
source .venv/bin/activate # For Unix/MacOS
|
| 43 |
+
.venv\Scripts\activate # For Windows
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
3. Install dependencies:
|
| 47 |
+
```bash
|
| 48 |
+
pip install -r requirements.txt
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## Directory Structure
|
| 54 |
+
```plaintext
|
| 55 |
+
FlowModel/
|
| 56 |
+
├── main.py # Entry point for the application
|
| 57 |
+
├── plugins/ # Directory for plugins
|
| 58 |
+
│ ├── __init__.py # Initializes the plugin package
|
| 59 |
+
│ ├── example_plugin.py # Example plugin
|
| 60 |
+
├── data/ # Placeholder for datasets
|
| 61 |
+
├── requirements.txt # Python dependencies
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
### Training a Model
|
| 69 |
+
To train a model using FlowModel, run:
|
| 70 |
+
```bash
|
| 71 |
+
python main.py train
|
| 72 |
+
```
|
| 73 |
+
This will load any available plugins from the `plugins/` directory and apply their logic during the training process.
|
| 74 |
+
|
| 75 |
+
### Adding Plugins
|
| 76 |
+
To add a plugin, place a `.py` file with your plugin class in the `plugins/` directory. FlowModel automatically detects and loads plugins at runtime.
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## Creating Plugins
|
| 81 |
+
Plugins extend the functionality of FlowModel. To create a plugin:
|
| 82 |
+
|
| 83 |
+
1. **Create a new Python file in the `plugins/` directory**:
|
| 84 |
+
```bash
|
| 85 |
+
plugins/my_plugin.py
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
2. **Define your plugin class**:
|
| 89 |
+
```python
|
| 90 |
+
class MyPlugin:
|
| 91 |
+
def __init__(self):
|
| 92 |
+
print("MyPlugin initialized.")
|
| 93 |
+
|
| 94 |
+
def modify_model(self, model):
|
| 95 |
+
print("MyPlugin: Modifying the model.")
|
| 96 |
+
return model
|
| 97 |
+
|
| 98 |
+
def on_train_start(self):
|
| 99 |
+
print("MyPlugin: Training started.")
|
| 100 |
+
|
| 101 |
+
def on_train_end(self):
|
| 102 |
+
print("MyPlugin: Training finished.")
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
3. **Use your plugin during training**:
|
| 106 |
+
When `main.py` runs, it automatically loads your plugin and calls its methods.
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
+
|
| 110 |
+
## Command-Line Interface
|
| 111 |
+
FlowModel includes a simple CLI for interacting with the framework.
|
| 112 |
+
|
| 113 |
+
### Commands
|
| 114 |
+
- **Train**: Start the training process with plugins.
|
| 115 |
+
```bash
|
| 116 |
+
python main.py train
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## Contributing
|
| 122 |
+
Contributions are welcome! To contribute:
|
| 123 |
+
1. Fork the repository.
|
| 124 |
+
2. Create a new branch for your feature.
|
| 125 |
+
3. Commit your changes and push them.
|
| 126 |
+
4. Open a pull request.
|
| 127 |
+
|
| 128 |
+
---
|
| 129 |
+
|
| 130 |
+
## License
|
| 131 |
+
FlowModel is released under the MPL-2.0 License. See [LICENSE](LICENSE) for details.
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
Happy experimenting with FlowModel! 🚀
|
| 136 |
+
|
core/__init__.py
ADDED
|
File without changes
|
core/model.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch.nn as nn
|
| 2 |
+
|
| 3 |
+
class FlowModel:
|
| 4 |
+
def __init__(self):
|
| 5 |
+
self.model = None
|
| 6 |
+
|
| 7 |
+
def build_model(self):
|
| 8 |
+
self.model = nn.Sequential(
|
| 9 |
+
nn.Linear(28*28, 128),
|
| 10 |
+
nn.ReLU(),
|
| 11 |
+
nn.Linear(128, 10)
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
def get_model(self):
|
| 15 |
+
return self.model
|
core/predictor.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
class Predictor:
|
| 4 |
+
def __init__(self, model):
|
| 5 |
+
self.model = model
|
| 6 |
+
|
| 7 |
+
def predict(self, test_loader):
|
| 8 |
+
self.model.eval()
|
| 9 |
+
predictions = []
|
| 10 |
+
|
| 11 |
+
with torch.no_grad():
|
| 12 |
+
for images, _ in test_loader:
|
| 13 |
+
outputs = self.model(images.view(-1, 28 * 28))
|
| 14 |
+
_, predicted = torch.max(outputs, 1)
|
| 15 |
+
predictions.extend(predicted.cpu().numpy())
|
| 16 |
+
|
| 17 |
+
return predictions
|
core/trainer.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch.optim as optim
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
|
| 4 |
+
class Trainer:
|
| 5 |
+
def __init__(self, model):
|
| 6 |
+
self.model = model
|
| 7 |
+
self.criterion = nn.CrossEntropyLoss()
|
| 8 |
+
self.optimizer = optim.SGD(self.model.parameters(), lr=0.01)
|
| 9 |
+
|
| 10 |
+
def train(self, train_loader, epochs=5):
|
| 11 |
+
for epoch in range(epochs):
|
| 12 |
+
for images, labels in train_loader:
|
| 13 |
+
self.optimizer.zero_grad()
|
| 14 |
+
outputs = self.model(images.view(-1, 28*28))
|
| 15 |
+
loss = self.criterion(outputs, labels)
|
| 16 |
+
loss.backward()
|
| 17 |
+
self.optimizer.step()
|
| 18 |
+
|
| 19 |
+
print(f"Epoch [{epoch+1}/{epochs}], Loss: {loss.item():.4f}")
|
data/__init__.py
ADDED
|
File without changes
|
data/example_data.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torchvision import datasets, transforms
|
| 2 |
+
from torch.utils.data import DataLoader
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def load_mnist():
|
| 6 |
+
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])
|
| 7 |
+
train_dataset = datasets.MNIST(root='./data', train=True, download=True, transform=transform)
|
| 8 |
+
test_dataset = datasets.MNIST(root='./data', train=False, download=True, transform=transform)
|
| 9 |
+
|
| 10 |
+
train_loader = DataLoader(train_dataset, batch_size=64, shuffle=True)
|
| 11 |
+
test_loader = DataLoader(test_dataset, batch_size=64, shuffle=False)
|
| 12 |
+
|
| 13 |
+
return {'train': train_loader, 'test': test_loader}
|
main.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import os
|
| 3 |
+
import importlib
|
| 4 |
+
|
| 5 |
+
def check_plugins(loaded_plugins):
|
| 6 |
+
print("Loaded plugins:")
|
| 7 |
+
for plugin in loaded_plugins:
|
| 8 |
+
print(f"- {plugin}")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def train_model(dataset_name, plugins):
|
| 12 |
+
dataset = {'train': []} # Placeholder for training data
|
| 13 |
+
|
| 14 |
+
model = "FlowModel"
|
| 15 |
+
|
| 16 |
+
for plugin in plugins:
|
| 17 |
+
if hasattr(plugin, 'modify_model'):
|
| 18 |
+
model = plugin.modify_model(model)
|
| 19 |
+
|
| 20 |
+
for plugin in plugins:
|
| 21 |
+
if hasattr(plugin, 'on_train_start'):
|
| 22 |
+
plugin.on_train_start()
|
| 23 |
+
|
| 24 |
+
print(f"Training started on dataset: {dataset_name}")
|
| 25 |
+
|
| 26 |
+
for plugin in plugins:
|
| 27 |
+
if hasattr(plugin, 'on_train_end'):
|
| 28 |
+
plugin.on_train_end()
|
| 29 |
+
|
| 30 |
+
print("Training finished.")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def load_plugins():
|
| 34 |
+
plugins_dir = './plugins'
|
| 35 |
+
plugins = []
|
| 36 |
+
|
| 37 |
+
if not os.path.exists(plugins_dir):
|
| 38 |
+
os.makedirs(plugins_dir)
|
| 39 |
+
print(f"Plugins directory created at {plugins_dir}. Add your plugins there!")
|
| 40 |
+
|
| 41 |
+
for filename in os.listdir(plugins_dir):
|
| 42 |
+
if filename.endswith('.py') and filename != '__init__.py':
|
| 43 |
+
plugin_name = filename[:-3]
|
| 44 |
+
try:
|
| 45 |
+
plugin_module = importlib.import_module(f'plugins.{plugin_name}')
|
| 46 |
+
plugin_class = getattr(plugin_module, plugin_name.title().replace('_', ''), None)
|
| 47 |
+
if plugin_class:
|
| 48 |
+
plugins.append(plugin_class())
|
| 49 |
+
print(f"Plugin {plugin_name} loaded.")
|
| 50 |
+
else:
|
| 51 |
+
print(f"No class found in plugin {plugin_name}.")
|
| 52 |
+
except Exception as e:
|
| 53 |
+
print(f"Failed to load plugin {plugin_name}: {e}")
|
| 54 |
+
|
| 55 |
+
return plugins
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def predict_model(plugins):
|
| 59 |
+
print("Prediction started.")
|
| 60 |
+
for plugin in plugins:
|
| 61 |
+
if hasattr(plugin, 'on_predict'):
|
| 62 |
+
plugin.on_predict()
|
| 63 |
+
print("Prediction finished.")
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def main():
|
| 67 |
+
parser = argparse.ArgumentParser(description="FlowModel CLI")
|
| 68 |
+
parser.add_argument('command', choices=['train', 'predict', 'check_plugins'], help="Command to run")
|
| 69 |
+
|
| 70 |
+
args = parser.parse_args()
|
| 71 |
+
|
| 72 |
+
plugins, loaded_plugins = load_plugins()
|
| 73 |
+
|
| 74 |
+
if args.command == 'train':
|
| 75 |
+
plugins = load_plugins()
|
| 76 |
+
train_model("mnist", plugins)
|
| 77 |
+
elif args.command == 'predict':
|
| 78 |
+
predict_model(plugins)
|
| 79 |
+
elif args.command == 'check_plugins':
|
| 80 |
+
check_plugins(loaded_plugins)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
main()
|
plugins/__init__.py
ADDED
|
File without changes
|
plugins/example_plugin.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class ExamplePlugin:
|
| 2 |
+
def __init__(self):
|
| 3 |
+
print("ExamplePlugin initialized.")
|
| 4 |
+
|
| 5 |
+
def modify_model(self, model):
|
| 6 |
+
print("ExamplePlugin: Modifying the model.")
|
| 7 |
+
return f"{model}_modified_by_example"
|
| 8 |
+
|
| 9 |
+
def on_train_start(self):
|
| 10 |
+
print("ExamplePlugin: Training started.")
|
| 11 |
+
|
| 12 |
+
def on_train_end(self):
|
| 13 |
+
print("ExamplePlugin: Training finished.")
|
plugins/sample_plugin.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class SamplePlugin:
|
| 2 |
+
def __init__(self):
|
| 3 |
+
print("SamplePlugin initialized.")
|
| 4 |
+
|
| 5 |
+
def modify_model(self, model):
|
| 6 |
+
print("SamplePlugin: Modifying the model.")
|
| 7 |
+
return model
|
| 8 |
+
|
| 9 |
+
def on_train_start(self):
|
| 10 |
+
print("SamplePlugin: Training started.")
|
| 11 |
+
|
| 12 |
+
def on_train_end(self):
|
| 13 |
+
print("SamplePlugin: Training finished.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch==2.5.1
|
| 2 |
+
numpy==2.2.1
|
| 3 |
+
torchvision==0.20.1
|
tests/__init__.py
ADDED
|
File without changes
|