genmodelfit 0.1.0__py3-none-any.whl
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.
- genmodelfit/__init__.py +192 -0
- genmodelfit/__main__.py +7 -0
- genmodelfit/_version.py +7 -0
- genmodelfit/bench.py +980 -0
- genmodelfit/calibrate.py +310 -0
- genmodelfit/cli.py +1255 -0
- genmodelfit/data/__init__.py +3 -0
- genmodelfit/data/calibration.json +257 -0
- genmodelfit/data/db.json +40998 -0
- genmodelfit/data/measurements.json +194 -0
- genmodelfit/data/signing_keys/2026-10.pub +3 -0
- genmodelfit/db.py +195 -0
- genmodelfit/estimate.py +1199 -0
- genmodelfit/families.py +261 -0
- genmodelfit/fetch.py +339 -0
- genmodelfit/gate.py +625 -0
- genmodelfit/groups.py +491 -0
- genmodelfit/hardware.py +1120 -0
- genmodelfit/hf.py +1284 -0
- genmodelfit/models.py +307 -0
- genmodelfit/py.typed +0 -0
- genmodelfit/recommend.py +566 -0
- genmodelfit/remote.py +176 -0
- genmodelfit/safety.py +254 -0
- genmodelfit/signing.py +151 -0
- genmodelfit/status.py +120 -0
- genmodelfit/table.py +394 -0
- genmodelfit/tasks.py +146 -0
- genmodelfit/update.py +1239 -0
- genmodelfit/workflow.py +547 -0
- genmodelfit-0.1.0.dist-info/METADATA +350 -0
- genmodelfit-0.1.0.dist-info/RECORD +36 -0
- genmodelfit-0.1.0.dist-info/WHEEL +4 -0
- genmodelfit-0.1.0.dist-info/entry_points.txt +2 -0
- genmodelfit-0.1.0.dist-info/licenses/LICENSE +373 -0
- genmodelfit-0.1.0.dist-info/licenses/THIRD_PARTY_NOTICES +88 -0
genmodelfit/__init__.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
|
|
5
|
+
"""genmodelfit: 画像・動画・音声・3D の生成モデルが、その PC で動くかを判定する。
|
|
6
|
+
|
|
7
|
+
Python から:
|
|
8
|
+
import genmodelfit as gmf
|
|
9
|
+
info = gmf.system()
|
|
10
|
+
for fit in gmf.recommend(modality="image", limit=5):
|
|
11
|
+
print(fit.model.id, fit.score, fit.auto, fit.estimate.fit, fit.estimate.vram_gb)
|
|
12
|
+
fit.to_dict() # `recommend --json` の models の 1 件と同じ形
|
|
13
|
+
if gmf.data_status().expired: # 同梱・取り込んだ一覧の HEAD の確認が古い(30 日)
|
|
14
|
+
...
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import logging
|
|
20
|
+
from collections.abc import Iterable
|
|
21
|
+
from datetime import datetime
|
|
22
|
+
|
|
23
|
+
from ._version import __version__
|
|
24
|
+
from .db import Database
|
|
25
|
+
from .db import load as load_db
|
|
26
|
+
from .estimate import estimate
|
|
27
|
+
from .hardware import detect
|
|
28
|
+
from .models import (
|
|
29
|
+
CONTENT_LEVELS,
|
|
30
|
+
FIT_LEVELS,
|
|
31
|
+
MODALITIES,
|
|
32
|
+
Estimate,
|
|
33
|
+
Measurement,
|
|
34
|
+
ModelEntry,
|
|
35
|
+
ModelFile,
|
|
36
|
+
Settings,
|
|
37
|
+
SystemInfo,
|
|
38
|
+
)
|
|
39
|
+
from .recommend import Fit, evaluate
|
|
40
|
+
from .status import DataStatus
|
|
41
|
+
|
|
42
|
+
# 途中経過は logging に出す。組み込み側が設定しなければ何も出ない
|
|
43
|
+
logging.getLogger("genmodelfit").addHandler(logging.NullHandler())
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def system(vram_gb: float | None = None, ram_gb: float | None = None) -> SystemInfo:
|
|
47
|
+
"""この PC を調べる。vram_gb / ram_gb で上書きできる。"""
|
|
48
|
+
return detect(vram_gb=vram_gb, ram_gb=ram_gb)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _policy(comfyui_version: str | None):
|
|
52
|
+
from .gate import GatePolicy
|
|
53
|
+
|
|
54
|
+
return GatePolicy(comfyui_version=comfyui_version)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def recommend(
|
|
58
|
+
*,
|
|
59
|
+
modality: str | Iterable[str] | None = None,
|
|
60
|
+
content: str = "sfw",
|
|
61
|
+
min_fit: str = "marginal",
|
|
62
|
+
license: str | Iterable[str] | None = None,
|
|
63
|
+
task: str | Iterable[str] | None = None,
|
|
64
|
+
include_tools: bool = False,
|
|
65
|
+
auto_only: bool = False,
|
|
66
|
+
all_workflows: bool = False,
|
|
67
|
+
limit: int | None = 10,
|
|
68
|
+
per_modality: int | None = None,
|
|
69
|
+
settings: Settings | None = None,
|
|
70
|
+
system_info: SystemInfo | None = None,
|
|
71
|
+
db: Database | None = None,
|
|
72
|
+
comfyui_version: str | None = None,
|
|
73
|
+
) -> list[Fit]:
|
|
74
|
+
"""おすすめ順の一覧(先頭が一番のおすすめ)。CLI の `recommend` と同じ並べ方。
|
|
75
|
+
|
|
76
|
+
1 件 = 1 モデル(同じ重みの系統と大きさ。精度・使い方だけ違うワークフローはまとめ、段階が良く精度が
|
|
77
|
+
高いものを出す。ほかは fit.workflows / fit.variants)。all_workflows=True ならワークフローごと。
|
|
78
|
+
並べ方: 動くもの → 自動でおすすめに出せるもの(fit.auto)→ fit.score の高い順 → ID。
|
|
79
|
+
`fit.to_dict()` は `recommend --json` の models の 1 件と同じ形(docs/schema.md)。
|
|
80
|
+
|
|
81
|
+
modality: "image"、"image,video"、["image", "video"] のどれでもよい。
|
|
82
|
+
task: 用途("edit"、"gen,i2v"、["i2v"]。tasks のコード t2i なども可。一覧は tasks.USES)。
|
|
83
|
+
content の既定は sfw。無検閲のモデルも含めるなら "all"、無検閲だけなら "uncensored"。
|
|
84
|
+
license: "apache-2.0,mit" か ["apache-2.0", "mit"](すべてのファイルのライセンスがこの中にあるものだけ。
|
|
85
|
+
不明は合わない)。
|
|
86
|
+
limit / per_modality: 1 以上か None。per_modality を渡すと種類ごとに上位その数(CLI の既定の節と同じ。
|
|
87
|
+
CLI の `recommend`(-m も --task も無し)は per_modality=3, limit=None)。
|
|
88
|
+
comfyui_version: 使う ComfyUI の版(自動おすすめの判定。アプリは自分の版を渡す)。
|
|
89
|
+
知らない modality / content / min_fit / task、空の license、0 以下の limit は ValueError。
|
|
90
|
+
"""
|
|
91
|
+
from .recommend import recommend as _recommend
|
|
92
|
+
|
|
93
|
+
return _recommend(
|
|
94
|
+
db or load_db(),
|
|
95
|
+
system_info or detect(),
|
|
96
|
+
modality=modality,
|
|
97
|
+
content=content,
|
|
98
|
+
min_fit=min_fit,
|
|
99
|
+
license=license,
|
|
100
|
+
task=task,
|
|
101
|
+
include_tools=include_tools,
|
|
102
|
+
auto_only=auto_only,
|
|
103
|
+
group=not all_workflows,
|
|
104
|
+
limit=limit,
|
|
105
|
+
per_modality=per_modality,
|
|
106
|
+
settings=settings,
|
|
107
|
+
policy=_policy(comfyui_version),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def search(
|
|
112
|
+
query: str,
|
|
113
|
+
*,
|
|
114
|
+
modality: str | Iterable[str] | None = None,
|
|
115
|
+
content: str = "sfw",
|
|
116
|
+
min_fit: str | None = None,
|
|
117
|
+
license: str | Iterable[str] | None = None,
|
|
118
|
+
task: str | Iterable[str] | None = None,
|
|
119
|
+
all_workflows: bool = False,
|
|
120
|
+
limit: int | None = None,
|
|
121
|
+
settings: Settings | None = None,
|
|
122
|
+
system_info: SystemInfo | None = None,
|
|
123
|
+
db: Database | None = None,
|
|
124
|
+
comfyui_version: str | None = None,
|
|
125
|
+
) -> list[Fit]:
|
|
126
|
+
"""ID・名前の一部(大文字小文字を区別しない)で探す。CLI の `search` と同じ。合わなければ空の一覧。
|
|
127
|
+
空の query は ValueError。"""
|
|
128
|
+
from .recommend import select
|
|
129
|
+
|
|
130
|
+
return select(
|
|
131
|
+
db or load_db(),
|
|
132
|
+
system_info or detect(),
|
|
133
|
+
query=query,
|
|
134
|
+
modality=modality,
|
|
135
|
+
content=content,
|
|
136
|
+
min_fit=min_fit,
|
|
137
|
+
license=license,
|
|
138
|
+
task=task,
|
|
139
|
+
group=not all_workflows,
|
|
140
|
+
limit=limit,
|
|
141
|
+
settings=settings,
|
|
142
|
+
policy=_policy(comfyui_version),
|
|
143
|
+
).fits
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def data_status(
|
|
147
|
+
db: Database | None = None,
|
|
148
|
+
*,
|
|
149
|
+
now: datetime | None = None,
|
|
150
|
+
comfyui_version: str | None = None,
|
|
151
|
+
) -> DataStatus:
|
|
152
|
+
"""一覧の出どころと新しさ。`expired` が True なら、HEAD の確認が古いせいで自動のおすすめから
|
|
153
|
+
落ちたモデルがある(30 日。`genmodelfit update --from-release` か `update --heads-only` で取り直す)。
|
|
154
|
+
|
|
155
|
+
判定は自動のおすすめ(gate)と同じ関数で行う。auto_count がいま自動で出せる数、expires_at が次に
|
|
156
|
+
期限が切れる時刻。now は試験用(既定は今の UTC。タイムゾーンが無ければ UTC とみなす)。
|
|
157
|
+
comfyui_version は recommend と同じ(アプリは自分の版を渡す)。ネットには触らない。
|
|
158
|
+
"""
|
|
159
|
+
from .status import compute
|
|
160
|
+
|
|
161
|
+
return compute(db or load_db(), _policy(comfyui_version), now=now)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def info(model_id: str, *, db: Database | None = None) -> ModelEntry | None:
|
|
165
|
+
"""ID がそのまま合うモデル(内容によらず)。一部だけの一致では探さない。無ければ None。"""
|
|
166
|
+
return (db or load_db()).get(model_id)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
__all__ = [
|
|
170
|
+
"CONTENT_LEVELS",
|
|
171
|
+
"FIT_LEVELS",
|
|
172
|
+
"MODALITIES",
|
|
173
|
+
"DataStatus",
|
|
174
|
+
"Database",
|
|
175
|
+
"Estimate",
|
|
176
|
+
"Fit",
|
|
177
|
+
"Measurement",
|
|
178
|
+
"ModelEntry",
|
|
179
|
+
"ModelFile",
|
|
180
|
+
"Settings",
|
|
181
|
+
"SystemInfo",
|
|
182
|
+
"__version__",
|
|
183
|
+
"data_status",
|
|
184
|
+
"detect",
|
|
185
|
+
"estimate",
|
|
186
|
+
"evaluate",
|
|
187
|
+
"info",
|
|
188
|
+
"load_db",
|
|
189
|
+
"recommend",
|
|
190
|
+
"search",
|
|
191
|
+
"system",
|
|
192
|
+
]
|
genmodelfit/__main__.py
ADDED
genmodelfit/_version.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
|
|
5
|
+
"""版の番号(ここだけが正本。pyproject.toml は hatch がここから読む)。"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|