diff --git a/.claude/hooks/check_sync.sh b/.claude/hooks/check_sync.sh deleted file mode 100644 index 3d05aa3..0000000 --- a/.claude/hooks/check_sync.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash -# SessionStart hook: ローカルブランチが origin と同期しているかをチェックし, -# JSON で systemMessage (UI 表示) と additionalContext (モデルに注入) を出力する. -# 読み取り専用 (git fetch のみ). 失敗してもセッション開始は阻害しない. -# -# GUIDE_03「直列運用」「main を常に動作可能」を補助する目的で, -# 古い main から作業を始めるミスをセッション開始時に可視化する. - -# JSON 整形は Python に任せる (jq 非依存. 既存 hook も Python を利用). -# python3 / python / py の差は run_python.sh が吸収する (見つからなければ非ブロックで失敗). -emit() { - local msg="$1" - PYTHONIOENCODING=utf-8 bash "$(dirname "$0")/run_python.sh" - "$msg" <<'PY' -import json, sys -msg = sys.argv[1] -print(json.dumps({ - "systemMessage": msg, - "hookSpecificOutput": { - "hookEventName": "SessionStart", - "additionalContext": msg, - }, -}, ensure_ascii=False)) -PY -} - -# git リポジトリ外なら静かに終了 -git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0 - -# origin が未設定なら静かにスキップ (個人 clone・ローカル実験用途) -git remote get-url origin >/dev/null 2>&1 || exit 0 - -# fetch (5 秒で打ち切り). 失敗 = オフライン等. 警告だけ出して継続. -if ! timeout 5 git fetch --quiet origin 2>/dev/null; then - emit "[sync-check] origin への fetch に失敗 — オフラインの可能性" - exit 0 -fi - -BRANCH=$(git branch --show-current) -# detached HEAD は判定できないので静かに終了 -[ -z "$BRANCH" ] && exit 0 - -LOCAL=$(git rev-parse HEAD 2>/dev/null) || exit 0 -REMOTE=$(git rev-parse "@{u}" 2>/dev/null) -if [ -z "$REMOTE" ]; then - emit "[sync-check] $BRANCH は upstream 未設定" - exit 0 -fi -BASE=$(git merge-base HEAD "@{u}") - -DIRTY="" -[ -n "$(git status --porcelain)" ] && DIRTY=" / 未コミット変更あり" - -if [ "$LOCAL" = "$REMOTE" ]; then - emit "[sync-check] ✓ $BRANCH は origin と同期${DIRTY}" -elif [ "$LOCAL" = "$BASE" ]; then - AHEAD=$(git rev-list --count "HEAD..@{u}") - emit "[sync-check] ⚠ $BRANCH は origin より ${AHEAD} コミット遅れ — \`git pull\` 推奨${DIRTY}" -elif [ "$REMOTE" = "$BASE" ]; then - AHEAD=$(git rev-list --count "@{u}..HEAD") - emit "[sync-check] ℹ $BRANCH は origin より ${AHEAD} コミット先行${DIRTY}" -else - AHEAD=$(git rev-list --count "@{u}..HEAD") - BEHIND=$(git rev-list --count "HEAD..@{u}") - emit "[sync-check] ⚠ $BRANCH は origin と分岐 (先行 ${AHEAD} / 遅れ ${BEHIND}) — rebase/merge が必要${DIRTY}" -fi diff --git a/.claude/project-mode b/.claude/project-mode new file mode 100644 index 0000000..ceeec84 --- /dev/null +++ b/.claude/project-mode @@ -0,0 +1 @@ +solo diff --git a/.claude/rules/coding-style.md b/.claude/rules/coding-style.md new file mode 100644 index 0000000..7725fd7 --- /dev/null +++ b/.claude/rules/coding-style.md @@ -0,0 +1,132 @@ +--- +paths: ["src/**", "scripts/**"] +--- + +# コーディング規約 (Coding Standards) + +Python コード(`src/**`・`scripts/**`)を編集するときは本ルールに従うこと.`legacy/` のコードは対象外(書き換えない.`.claude/rules/legacy.md`). + +## 基本方針 (Basic Policy) + +- ruff を唯一の lint / format ツールとして使用する.設定は `pyproject.toml` の `[tool.ruff]` に集約する. +- 標準(PEP 8)から逸脱しない範囲で ruff の自動修正に従う. +- プロジェクト固有のルールは本ファイルに最小限で書く. +- 別ツール(black・isort・mypy 等)は導入しない(ruff で完結させる). + +## 適用 ruff ルール (Ruff Rules) + +`pyproject.toml` の `[tool.ruff.lint]` で `select = ["E", "F", "W", "I", "B", "UP", "N"]` を選択する. + +| ルール | 内容 | +| --- | --- | +| E (pycodestyle) | PEP 8 形式エラー | +| F (pyflakes) | 未使用変数・未定義シンボル等 | +| W (pycodestyle) | 形式警告 | +| I (isort) | import 文の並び順 | +| B (flake8-bugbear) | バグになりやすいパターン検出 | +| UP (pyupgrade) | Python 3.12 の機能で書き換え可能なコードの提案 | +| N (pep8-naming) | クラス・関数・変数の命名 | + +行長は 100 文字とする.実行コマンドは [ENV_04 開発コマンド](../../docs/02_ENV/ENV_04_開発コマンド.md)を参照する. + +## 学習データを扱うコードの規則 (Data Handling Rules) + +本プロジェクトの最重要規則.[PLAN_01 要件定義書](../../docs/03_PLAN/PLAN_01_要件定義書.md)「データの取り扱い」に対応する. + +- **データ・重みのパスをコードに書かない**.場所は設定 YAML と環境変数から受け取る(原本は相対パス・絶対パスを埋め込んでいた.これを繰り返さない) +- **ログ・例外メッセージに画像のファイル名・患者 ID を出さない**.件数・行番号・`subset` で示す(例外処理の詳細は `.claude/rules/error-handling.md`) +- **画像ごとの結果は回収対象外の名前で保存する**(`predictions.csv`・`split.json`).`metrics.json`・`history.csv`・`log.txt`・`figures/` には集計値と図だけを書く([SPEC_01](../../docs/04_SPEC/SPEC_01_アーキテクチャ設計.md)「回収ホワイトリスト」) +- **`figures/` に舌画像・マスク・予測結果の画像を書き出さない** +- `print` ではなく `logging` を使う(サーバ実行のログが `runs/<実験ID>/log.txt` に残るため) + +## 原本の挙動を保つ規則 (Preserving Original Behaviour) + +[SPEC_02](../../docs/04_SPEC/SPEC_02_学習・ONNX書き出し仕様.md) の「原本との対応」に従う. + +- **原本の処理を移すときは,手順(前処理・損失・評価の計算)を変えない**.「直したくなる挙動」(シグモイドの 2 重掛け・検証用データへのデータ拡張等)も既定では原本どおりにする +- 原本と変える場合は,設定で切り替えられるようにし(既定は原本どおり),SPEC_02 の対応表に違いと理由を書いてから実装する +- 原本のどの処理を元にしたかを docstring かコメントに書く(例: `legacy/source/losses.py` の `DiceCE`) +- **画像は `cv2.imread` の BGR のまま扱う**.RGB への並べ替えを足さない(DeepTIAS・TIASJudgeModel の前処理がこれに合わせてある) +- `ResUNet` の層の名前(`state_dict` のキー)を変えない(原本の重みを読み込めなくなる) + +## 機械学習コードの規則 (ML Code Rules) + +- **乱数はグローバル状態に依存しない書き方を優先する**.seed を引数・設定から受け取り,実際に使った値を `config.yaml` に記録する.原本と同じ乱数の固定(`fix_rand` 相当)は学習の入口の 1 か所だけで行う +- **デバイスをハードコードしない**.`cuda:0` を直書きせず設定・引数から受け取る(共用サーバのため GPU 指定が必要) +- **テンソルの形状を docstring に書く**(例: `(B, 2, H, W)`).形状・チャンネルの取り違え(チャンネル 0 が舌)は主要なバグ源である +- 学習のハイパーパラメータは設定 YAML に置き,コードに既定値を散らさない(既定値は `schema.py` の 1 か所) + +## 型ヒント (Type Hints) + +- **公開関数(モジュールから export される関数・クラス)**: 引数と戻り値に型ヒント必須 +- **内部ヘルパ・テストコード**: 任意.書ける所は書く +- `torch.Tensor`・`np.ndarray` は型だけでは情報が足りないため,要素型と形状を docstring で補う + +静的型チェック(mypy / pyright)は当面導入しない.必要が出てから追加する. + +## docstring + +- **公開関数・クラス**: docstring 必須 +- **書式**: Google スタイル(`Args:` / `Returns:` / `Raises:`)に統一 +- **言語**: 日本語可 + +例: + +```python +import torch + + +def dice_loss(pred: torch.Tensor, target: torch.Tensor, smooth: float = 1.0) -> torch.Tensor: + """Dice 損失を計算する(原本: `legacy/source/losses.py` の `dice_loss`). + + Args: + pred: シグモイドを掛けた後の予測(`(B, 2, H, W)`, float32, 値域 0.0〜1.0). + target: 正解(`(B, 2, H, W)`, float32, 0 か 1.チャンネル 0 が舌). + smooth: 分母が 0 になるのを避ける値. + + Returns: + チャンネルごと・画像ごとの損失の平均(スカラー). + """ +``` + +## 命名規則 (Naming) + +ruff `N` ルールでチェックする. + +| 対象 | スタイル | 例 | +| --- | --- | --- | +| モジュール | snake_case | `bundle.py`・`resunet.py` | +| パッケージ | snake_case | `tongue_seg_model` | +| 関数・変数 | snake_case | `load_bundle`・`mean_iou` | +| クラス | PascalCase | `ResUNet`・`TrainConfig` | +| 定数 | UPPER_SNAKE_CASE | `TONGUE_CHANNEL` | +| プライベート | 接頭辞 `_` | `_validate_pairs` | + +※ 原本の名前(`ResNetUNet`・`path_trainSample` 等)は新しいコードに持ち込まない.ただし `state_dict` のキーになる層の属性名(`layer0_1x1`・`conv_up3` 等)は原本のままにする. + +## コメント (Comments) + +- **WHY を書く**: 何をしているかは識別子で表現し,コメントは「なぜこの実装か」「制約」「出典(原本のどこか)」に限定する +- **TODO** は `# TODO(rintoHasegawa): 内容` 形式で記述する + +## import 順序 (Import Order) + +ruff `I` で自動整列する.手動整列は不要. + +1. 標準ライブラリ +2. サードパーティ(`torch`・`cv2`・`numpy` 等) +3. プロジェクト内(`from tongue_seg_model import ...`) + +`from xxx import *` は使わない(原本は多用している).`legacy/` のモジュールを import しない. + +## CLI 引数 (CLI Arguments) + +- 短縮形より長い形を優先する(`--config` を主とする) +- `argparse` 標準を使用する +- ヘルプ文は日本語可 + +## 参考 (References) + +- [PEP 8 — Style Guide for Python Code](https://peps.python.org/pep-0008/) +- [Google Python Style Guide — Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) +- [ruff documentation](https://docs.astral.sh/ruff/) diff --git a/.claude/rules/error-handling.md b/.claude/rules/error-handling.md new file mode 100644 index 0000000..a42cf9f --- /dev/null +++ b/.claude/rules/error-handling.md @@ -0,0 +1,46 @@ +--- +paths: ["src/**", "scripts/**"] +--- + +# エラーハンドリング方針 (Error Handling) + +例外を raise / 捕捉するコード(`src/**`・`scripts/**`)を書くときは本ルールに従うこと.コーディング全般の規約は `.claude/rules/coding-style.md` を参照する. + +## 例外の使い分け (Exception Types) + +| 状況 | 送出する例外 | +| --- | --- | +| ユーザー入力(設定 YAML・バンドル・画像ファイル等)の内容・形式の問題 | `ValueError` に統一して raise | +| 内部論理エラー(到達しないはずの分岐・不変条件違反等) | `RuntimeError` | +| pydantic を使うバリデーション | `pydantic.ValidationError` をそのまま伝播(握りつぶさない) | + +## データ整合性は fail fast (Fail Fast on Data) + +機械学習では**静かな除外・変換が結果を歪める**ため,データの問題は黙って飛ばさず止める. + +- 画像と正解マスクの組が欠けている・読めない・大きさが合わない・設定の大きさと違う場合は raise する(黙って除かない・黙って拡大縮小しない) +- 「とりあえず `try` で囲んで `continue`」は禁止.学習に使う枚数が静かに変わり,結果の解釈を誤る +- 原本は `cv2.imread` の失敗(`None` が返る)を確かめていない.新しいコードは必ず確かめる + +## 個人情報を出さない (No PII in Messages) + +例外メッセージ・ログに画像のファイル名・患者 ID を含めない.位置は manifest の行番号・件数・`subset` で示す. + +```python +raise ValueError(f"manifest の {row_number} 行目: 画像と正解マスクの大きさが一致しない") +``` + +※ バンドルのファイル名は内容のハッシュだが,それも出さない(規則を単純にするため.行番号があればサーバ上で特定できる). + +## 方針 (Policy) + +- **最小限主義**: 独自例外クラスの階層は導入しない.上表の標準例外で表現できる範囲に留め,足りなくなった時点で検討する +- **メッセージは日本語可**: 原因と対処が分かる具体的な内容にする(どの項目・何行目が不正か) +- **握りつぶさない**: `except:` で例外を無言で捨てない.捕捉するなら再送出するか,ログを残した上で明示的に処理する +- **境界で検証する**: 入力の検証は入口(CLI・スキーマ読込・バンドル読込)で行い,学習ループ・損失・IoU の計算は「検証済みの正しい入力が来る」前提で書く(`.claude/rules/project-structure.md` の依存方向・純関数優先と対応する) +- **リモート実行の失敗は原因を残す**: ssh・転送の失敗は終了コードと標準エラー出力の要点をメッセージに含める(どのサーバ・どの段階かが分かるようにする) + +## 参考 (References) + +- [Python 公式ドキュメント — 組み込み例外](https://docs.python.org/3/library/exceptions.html) +- [Pydantic — Error Handling](https://docs.pydantic.dev/latest/errors/errors/) diff --git a/.claude/rules/legacy.md b/.claude/rules/legacy.md new file mode 100644 index 0000000..3b399d8 --- /dev/null +++ b/.claude/rules/legacy.md @@ -0,0 +1,41 @@ +--- +paths: ["legacy/**"] +--- + +# 原本フォルダの取り扱い (Legacy Folder Rules) + +`legacy/` 配下のファイルを読む・触るときは本ルールに従うこと.`legacy/` は OneDrive にあった学習コードの原本フォルダ全体のコピーである([PLAN_01 要件定義書](../../docs/03_PLAN/PLAN_01_要件定義書.md)「管理対象」). + +## 書き換えない (Read-only) + +- **`legacy/` のファイルを編集・整形・移動・削除しない**.原本の記録であり,新しいコードとの違いを追う基準になる(PLAN_01 の R1) +- 原本の誤り・古い書き方を見つけても `legacy/` では直さない.新しいコード(`src/tongue_seg_model/`)で対応し,違いを [SPEC_02](../../docs/04_SPEC/SPEC_02_学習・ONNX書き出し仕様.md)「原本との対応」に書く +- ruff の対象から外してある(`pyproject.toml` の `extend-exclude`).`legacy/` に対して lint・整形を実行しない +- 原本のスクリプトは,埋め込みのパスと古いライブラリを前提にしているため実行しない + +## 読んでよいもの・読まないもの (What to Read) + +| 対象 | 扱い | +| --- | --- | +| `legacy/source/*.py`・`legacy/temp/*.py`・`legacy/source/lightning_logs/*/hparams.yaml` | 読んでよい(Git に入っているコードと実験条件の記録) | +| `legacy/segmentation_models/` | 読んでよい(公開ライブラリ segmentation_models_pytorch 0.2.1 のコピー) | +| `legacy/result/`・`legacy/output/`・`legacy/input/` | **中身・ファイル名を読まない・一覧しない**(`result/` には画像のファイル名を含む csv・txt がある.患者 ID の可能性).例外は下の行の重みだけ | +| 重み(`*.pth`・`*.onnx`) | **新旧のモデルの出力を比べる確認のために読み込んでよい**(2026-11-18 のユーザー判断.PLAN_02 のステップ 1-7).場所は原本のコードに書かれたパス(例: `result/CompareModels/ResUNet/bestModel.pth`)から求める.`legacy/output/` の ONNX は `*.onnx` に絞った検索で探してよい | +| その他の重み(`*.ckpt`・`*.pb`)・`events.out.tfevents.*` | 中身を読まない.件数・サイズの確認は,ファイル名を表示しない方法で行う | + +- 除外されたファイルを列挙するコマンド(`git status --ignored`・`git clean -n`・`legacy/result/` への `ls`・`find`・Glob・Grep 等)を実行しない.重みを探すときも,拡張子を絞らない一覧・`legacy/result/` の中の検索はしない(csv・txt の名前が出るため) +- 件数・サイズ・ハッシュの照合が必要なときは,フォルダ単位の集計値だけを出力する書き方にする + +## Git に入れるもの (What Goes into Git) + +`.gitignore` で `legacy/` を既定で除外し,次だけを許可している.**許可を広げる変更はユーザーの判断が要る**(Claude が自分で広げない). + +- `legacy/source/*.py` +- `legacy/temp/*.py` +- `legacy/source/lightning_logs/*/hparams.yaml` + +`git add -f` で `legacy/` のファイルを追加しない. + +## サーバへ送らない (Not Sent to Servers) + +`legacy/` はリモート実行ツールの送信対象から外す([SPEC_03](../../docs/04_SPEC/SPEC_03_リモート実行仕様.md)).新しいコードは `legacy/` を import しない(`.claude/rules/project-structure.md`). diff --git a/.claude/rules/project-structure.md b/.claude/rules/project-structure.md new file mode 100644 index 0000000..c28296e --- /dev/null +++ b/.claude/rules/project-structure.md @@ -0,0 +1,38 @@ +--- +paths: ["src/**", "tests/**", "scripts/**", "configs/**"] +--- + +# プロジェクト構成ルール (Project Structure) + +ソース・テスト・スクリプト・設定を追加・移動するときは本ルールに従い,責務ごとのサブパッケージ配置を保つこと.設計の背景は [SPEC_01 アーキテクチャ設計](../../docs/04_SPEC/SPEC_01_アーキテクチャ設計.md)を参照する(本ルールは配置規則のみを定める). + +## ディレクトリ構成 (Layout) + +```text +src/tongue_seg_model/ +├── __init__.py +├── schema.py # pydantic 設定スキーマ(既定値はここだけに置く) +├── data/ # バンドルの読み込み・Dataset・分割・前処理・データ拡張 +├── models/ # ResUNet +├── training/ # 学習ループ・損失・学習中の評価 +├── export/ # ONNX の書き出しと確認 +├── remote/ # リモート実行(転送・ジョブ実行・回収) +└── cli/ # CLI エントリポイント + +tests/ # src のサブパッケージ構造をミラーする +scripts/ # 合成データの生成・単発の調査 +configs/ # 学習条件・サーバ設定の YAML(コード外の設定) +legacy/ # 原本(書き換えない..claude/rules/legacy.md) +``` + +## 配置ルール (Placement Rules) + +- **1 モジュール 1 責務**: 新しい機能は責務に合うサブパッケージに置く.該当が無ければ新サブパッケージを作る(既存モジュールを肥大化させない.原本の `main.py` のようにデータ・学習・評価を 1 ファイルに詰めない) +- **依存方向**: `cli` → `training` / `export` → `data` / `models` の一方向を保つ.`data`・`models` から上位(`cli`・`training`)を import しない +- **`remote` は独立させる**: `remote` は `torch`・`cv2` と他のサブパッケージを import しない(手元で GPU 用の依存を読み込まずに動かすため) +- **`tiasdata` を import するのは `data/bundle.py` だけ**とする(TIASDataHub 側の変更の影響を 1 か所に閉じる) +- **`legacy/` を import しない**: 新しいコードは `legacy/` に依存しない(`legacy/` はサーバへ送らない).原本の処理が要るときは `src/` に書き直す +- **純関数を優先**: 副作用(ファイル I/O・ssh・GPU 実行)は `cli`・`remote`・`training` の縁に寄せ,前処理・損失・IoU の計算・回収対象の判定は入力 → 出力の純関数として書く(`.claude/rules/testing.md` の必須テスト対象と対応する) +- **設定・データ**: 学習条件は `configs/*.yaml` に置き,条件・パスをコードに埋め込まない.学習データ・重みはリポジトリに置かない(`data/`・`runs/`・重みの拡張子は `.gitignore` 済み) +- **調査・使い捨てコード**: 恒久的に使わない単発スクリプトは `src/` ではなく `scripts/` に置く +- **テストの配置**: `tests/` は `src/tongue_seg_model/` の構造をミラーする(詳細は `.claude/rules/testing.md`) diff --git a/.claude/rules/testing.md b/.claude/rules/testing.md new file mode 100644 index 0000000..6d3c33d --- /dev/null +++ b/.claude/rules/testing.md @@ -0,0 +1,84 @@ +--- +paths: ["tests/**", "**/test_*.py", "**/conftest.py"] +--- + +# テスト方針 (Test Policy) + +テストコード(`tests/**`・`test_*.py`・`conftest.py`)を追加・編集するときは本ルールに従うこと. + +## 基本方針 (Basic Policy) + +- フレームワーク: **pytest** +- 配置: `tests/` 配下に `src/tongue_seg_model/` の構造をミラーする +- カバレッジ目標: **数値目標なし**.代わりに「下記の必須対象は必ず単体テストを書く」を徹底する +- **実データを使うテストは書かない**.テストは合成データ(小さい画像とマスク・合成のバンドル)のみで完結させる.手元でもサーバでも同じテストが通ること +- **`legacy/` のデータ・重み・結果をテストから読まない**(`legacy/result/` には画像のファイル名を含むファイルがある).原本の重みを使う確認(PLAN_02 のステップ 1-7)は pytest のテストにせず,専用のスクリプトで行う(`.claude/rules/legacy.md`) +- 実行コマンドは [ENV_04 開発コマンド](../../docs/02_ENV/ENV_04_開発コマンド.md)を参照する + +## ファイル・関数命名 (Naming) + +- ファイル: `test_<対象モジュール>.py` +- 関数: `test_<振る舞い>`(例: `test_mask_threshold_is_above_128`) +- クラス(任意): `Test<クラス名>` で振る舞いごとにグループ化してよい + +## 必ずテストを書く対象 (Mandatory) + +1. **回収ホワイトリスト**: 画像・`manifest.csv`・`predictions.csv`・`split.json`・`figures/` 以外の PNG・指定の無い重みが回収対象に入らないこと.**最重要**(破れるとファイル名を含む結果や画像が手元に流れる) +2. **前処理**: 画像が BGR のまま 255 で割られること.正解マスクが「128 を超える」で 2 値化され,チャンネル 0 が舌・チャンネル 1 がその反転になること.大きさが設定と違う入力で止まること +3. **損失**: `bce_input` の 2 つの設定(`sigmoid`=原本どおり・`logits`)が,手計算した期待値と一致すること.原本どおりの既定が変わっていないこと +4. **モデル**: 入力 `(N, 3, 256, 256)` に対して出力が `(N, 2, 256, 256)` になること.`state_dict` のキーが原本の `ResNetUNet` と同じであること(キーの一覧を期待値として固定する) +5. **学習後の評価**: 既知の予測と正解に対して IoU が期待値と一致すること(シグモイド → 255 倍 → 大津の 2 値化の手順を含む) +6. **分割**: 同じ seed で分割が再現すること.患者単位の分割では同じ患者が学習と検証にまたがらないこと +7. **バンドルの検証**: 画像と正解マスクの組が欠けている・大きさが合わない場合に止まること(黙って除かないこと) +8. **設定スキーマ**: 不正な YAML・未知のキーが `ValidationError` になること.既定値が SPEC_02 の表(原本と同じ学習条件)と一致すること +9. **ONNX の書き出し**: 書き出した ONNX の入出力の形が `(1, 3, 256, 256)` → `(1, 2, 256, 256)` であること.onnxruntime の出力が PyTorch の出力とほぼ一致すること + +## テストを必須としない対象 (Optional) + +- **CLI のエントリポイント**: 統合テスト 1 本でカバーする +- **図の生成**: 「ファイルが生成されたか」の smoke テストで十分 + +## モック方針 (Mocking) + +- **ssh・リモート実行はモックする**.テストが実サーバに接続してはならない(コマンドの組み立て・GPU の判定・回収対象の判定など,純粋なロジックを検証する) +- **事前学習の重みのダウンロードをテストでしない**.モデルのテストは事前学習の重みを使わない設定で作る(テストがネットワークに依存しないようにする) +- **ファイル I/O はモックしない**.`tmp_path` フィクスチャで実ファイルを使う +- **モデルの学習はモックしない**が,合成データ・数枚・1〜2 エポックで回す(下記 slow マーカー) +- **乱数を含むテストは必ず seed を固定する** + +## 重いテストの扱い (Slow Tests) + +学習を回すテスト・ONNX を書き出すテストは `@pytest.mark.slow` を付けて区別する. + +```python +import pytest + + +@pytest.mark.slow +def test_train_two_epochs_on_synthetic_bundle(): + ... +``` + +- 通常実行(高速): `uv run pytest -m "not slow"` +- 全テスト実行: `uv run pytest` + +マーカーは `pyproject.toml` の `[tool.pytest.ini_options]` に登録済み. + +## /implement パイプラインでのテスト (Pipeline) + +1. **Phase 1(実装 / coder)**: 機能実装 → 人間が動作確認 +2. **Phase 2(テスト / tester)**: 本方針に従いテストを追加 +3. **Phase 3(リファクタ / refactorer)**: テストを safety net として品質改善 +4. **Phase 4**: ドキュメント更新 + +Phase 2 でテストが書きにくいと感じたら設計が悪いシグナルである.Phase 3 でモジュールを分割するか責務を見直す. + +## テスト失敗時の運用 (On Failure) + +- 仕様変更による失敗: 先に SPEC を更新してからテストを書き直す +- バグ起因の失敗: 修正してから再実行する +- flaky なテスト: seed 固定漏れか,学習の非決定性に依存した期待値を疑う(学習結果の数値を直接期待値にしない) + +## 参考 (References) + +- [pytest documentation](https://docs.pytest.org/) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e4f86f6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,26 @@ +# 依存パッケージの定期更新 PR(Dependabot version updates) +# 脆弱性検出(Dependabot alerts / security updates)はリポジトリ設定で有効化する(本ファイルとは独立に動く) +version: 2 +updates: + - package-ecosystem: "uv" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 5 + commit-message: + prefix: "[update]" + groups: + minor-and-patch: + update-types: + - "minor" + - "patch" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "[update]" + groups: + actions: + patterns: + - "*" diff --git a/.gitignore b/.gitignore index 7f9cbb5..b56597f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,44 @@ # tests/test_hooks.py が一時的に作る作業ディレクトリ(テストが強制終了された場合の取り残し対策) .claude/hooks/tests/_restrict_sandbox_*/ -# -- プロジェクト立ち上げ時に有効化する(.claude/rules/git-conventions.md 参照) -- -# .env -# .env.* -# node_modules/ -# build/ -# dist/ +# -- プロジェクト固有 -- + +# 学習データ・合成データ(絶対にコミットしない) +/data/ + +# 学習結果(指標・図・重み) +runs/ + +# モデルの重み(legacy/ の外に置いた場合も入れない) +*.pt +*.pth +*.ckpt +*.pb +*.onnx + +# Python / uv +.venv/ +*.py[cod] +*.egg-info/ +build/ +dist/ +.ruff_cache/ +.pytest_cache/ + +# 環境変数 +.env +.env.* + +# OS +Thumbs.db +.DS_Store + +# -- legacy/(OneDrive の原本をそのまま置く場所) -- +# 既定で全部除外し,コードと実験条件の記録だけを Git に入れる(docs/03_PLAN/PLAN_01_要件定義書.md「管理対象」). +# 重み(ckpt・pth・pb・onnx)・result/ の csv と txt(画像のファイル名を含む)・TensorBoard のログ・ +# segmentation_models/(pip で置き換える)は入れない. +legacy/** +!legacy/**/ +!legacy/source/*.py +!legacy/temp/*.py +!legacy/source/lightning_logs/*/hparams.yaml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..86eb3cc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/TIASDataHub"] + path = external/TIASDataHub + url = https://github.com/rintoHasegawa/TIASDataHub.git diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/CLAUDE.md b/CLAUDE.md index 49e8e50..9782fbd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,15 +1,26 @@ -# プロジェクト名 +# TongueSegModel - +舌セグメンテーション(ResUNet)の学習コードを Git で管理し,計算サーバで学習を再現できるようにするためのリポジトリ.重み・学習データ・患者情報を含みうる結果ファイルは管理対象外とする. + +- 技術スタック: Python 3.12・uv・PyTorch 2.x(サーバは CUDA 12.6 版)・OpenCV・YAML+pydantic・pytest・ruff.土台は TIASJudgeModel とそろえている(`docs/02_ENV/ENV_01_技術スタック.md`) +- 構成: 原本は `legacy/`(書き換えない),新しいコードは `src/tongue_seg_model/`,データ読み込みはサブモジュール `external/TIASDataHub`(tiasdata) +- 実行環境: 手元(Windows)は合成データでの確認のみ.学習は研究室の GPU サーバ(Newton・Archimedes)で行う ## 開発進捗 -最新: GUIDE_01 に従いプロジェクト立ち上げ中 +最新: プロジェクト立ち上げ完了(GUIDE_01 の全フェーズ).次は PLAN_02 のステップ 1-1(設定と実験の出力) ※ 本欄は**最新ステップ 1 行のみ上書き更新**.詳細な進捗履歴(動機・設計判断・失敗パターン)は [docs/PROGRESS.md](docs/PROGRESS.md) に追記する.運用ルールは `.claude/rules/progress-log.md` を参照(該当ファイル編集時に自動ロードされる). ## 必須ルール(コード実装時) - +### データと原本の取り扱い(最重要) + +- **学習データ(画像・正解マスク)を手元 PC に置かない**.実データに触るコードはサーバでだけ動かし,手元は合成データで確認する +- **Claude はデータの中身・ファイル名を読まない**(TIASDataHub のルールと同じ).`legacy/result/`・`legacy/output/`・`legacy/input/` の中身・ファイル名も読まない・一覧しない(`result/` に画像のファイル名を含む csv がある.例外は新旧のモデルの比較に使う重みだけ.`.claude/rules/legacy.md`) +- **`legacy/` は書き換えない**.新しいコードは `src/tongue_seg_model/` に書き,`legacy/` を import しない.Git に入れる範囲(.py と `hparams.yaml`)を Claude が自分で広げない(`.claude/rules/legacy.md`) +- **重み(ckpt・pth・pb・onnx)・画像ごとの結果を Git に入れない**.ログ・例外メッセージに画像のファイル名・患者 ID を出さない +- **原本の学習手順を既定では変えない**(BGR のまま読む・損失のシグモイドの 2 重掛け等).変えるときは設定で切り替え,SPEC_02 の対応表に理由を書いてから実装する +- コーディング規約等の本体は `.claude/rules/`(coding-style / project-structure / testing / error-handling / legacy)にあり,該当ファイル編集時に自動ロードされる ### Git 運用 @@ -69,19 +80,25 @@ - プロジェクト立ち上げフロー: docs/01_GUIDE/GUIDE_01_プロジェクト立ち上げフロー.md - エージェント運用ルール: docs/01_GUIDE/GUIDE_02_エージェント運用ルール.md - ※ Git 規約・ドキュメント書式・命名規則・進捗記録・テンプレート改変記録・フックのクロスプラットフォーム対応は `.claude/rules/`(git-conventions / markdown-style / docs-naming / progress-log / template-customization / hooks-cross-platform)に定義されている(git-conventions は常時,他は該当ファイル編集時に自動ロード) -- ※ コーディング規約,テスト方針等はプロジェクト立ち上げ時に path-scoped rules(`.claude/rules/`)として作成する(GUIDE_01 参照) +- ※ コーディング規約・プロジェクト構成・テスト方針・エラーハンドリング・原本フォルダの取り扱いは `.claude/rules/`(coding-style / project-structure / testing / error-handling / legacy)に定義されている(該当ファイル編集時に自動ロード) ### 02_ENV(環境) - +- 技術スタック: docs/02_ENV/ENV_01_技術スタック.md +- 環境構築手順: docs/02_ENV/ENV_02_環境構築手順.md +- 管理者用環境構築手順: docs/02_ENV/ENV_03_管理者用環境構築手順.md +- 開発コマンド: docs/02_ENV/ENV_04_開発コマンド.md ### 03_PLAN(計画) - +- 要件定義書: docs/03_PLAN/PLAN_01_要件定義書.md +- 開発ステップ: docs/03_PLAN/PLAN_02_開発ステップ.md ### 04_SPEC(仕様・設計) - +- アーキテクチャ設計: docs/04_SPEC/SPEC_01_アーキテクチャ設計.md +- 学習・ONNX 書き出し仕様: docs/04_SPEC/SPEC_02_学習・ONNX書き出し仕様.md +- リモート実行仕様: docs/04_SPEC/SPEC_03_リモート実行仕様.md ### 05_TECH(技術設計) diff --git a/README.md b/README.md new file mode 100644 index 0000000..44e9b76 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# TongueSegModel + +舌セグメンテーションモデル(ResUNet)の学習コード. + +- 原本(2021 年ごろに書かれた学習コード)は `legacy/` にそのまま置いてある.新しいコードは `src/tongue_seg_model/` に書く +- 重み・学習データ・画像のファイル名を含む結果は Git に入れない +- 文書は `docs/` にある(要件: `docs/03_PLAN/PLAN_01_要件定義書.md`,環境構築: `docs/02_ENV/ENV_02_環境構築手順.md`) + +```bash +git clone --recurse-submodules https://github.com/rintoHasegawa/TongueSegModel.git +cd TongueSegModel +uv sync +uv run pytest +``` diff --git "a/docs/01_GUIDE/GUIDE_03_\343\203\201\343\203\274\343\203\240\351\226\213\347\231\272\343\203\253\343\203\274\343\203\253.md" "b/docs/01_GUIDE/GUIDE_03_\343\203\201\343\203\274\343\203\240\351\226\213\347\231\272\343\203\253\343\203\274\343\203\253.md" deleted file mode 100644 index 8f2c280..0000000 --- "a/docs/01_GUIDE/GUIDE_03_\343\203\201\343\203\274\343\203\240\351\226\213\347\231\272\343\203\253\343\203\274\343\203\253.md" +++ /dev/null @@ -1,164 +0,0 @@ -# チーム開発ルール (Team Development Rules) - -チーム全員が Claude Code を用い,人間が直接コードを書くことはほぼない前提で,並行開発を破綻させずに進めるための協調ルールを定義する. - -> 本ガイドは**チーム開発モード**(`/setup` で team を選択したプロジェクト)でのみ有効.個人開発モード(solo)のプロジェクトには本ファイルは配置されない.なお `/task-create`・`/task-start`・`/task-handoff` は共通層の skill であり,solo でも Issue ベースのタスク管理に使用できる(その場合,本ガイドのチーム協調ルールは適用されない). - -Git の規約は `.claude/rules/git-conventions.md`(push・PR・マージ手順は `.claude/skills/commit/reference.md`),1 タスクの実装パイプラインは [GUIDE_02](GUIDE_02_エージェント運用ルール.md) に従う.本ガイドはそれらの上に立つ「複数人が同時に動くときの調整」を扱う. - -## 基本方針 (Basic Policy) - -- 全員が Claude Code で開発し,実装はエージェントが行う(チーム規模はプロジェクトによる). -- 原則として並行作業を行わず,1 人ずつ直列で開発する.急ぎではないため,スループットより単純さと `main` の整合性を優先する.これは禁止ではなく既定のスタンスであり,状況に応じた判断は妨げない(詳細は「作業の直列化」). -- 人間の本質的な役割は「AI にできない判断と確認」(GUIDE_02 と同じ).加えて「共有設定の番人」を担う. -- 進捗・タスクは GitHub Issues と git 履歴で追う.`CLAUDE.md` には進捗を書かない(この点は solo 既定の進捗記録ルール `.claude/rules/progress-log.md` を**上書き**する). -- `main` は常に動作可能な状態を保つ(`.claude/rules/git-conventions.md`).壊れたら他の作業より優先して直す. - -## タスク管理 (Task Management) - -進捗管理の補助として GitHub Issues を用いる.Projects(ボード)は `.claude/project-board` を置いた場合のみ併用する(「Project ボード」参照).`gh` コマンドでの具体的な操作手順(スコープ・Projects 操作・トラブル対応)は `.claude/skills/task-start/reference.md` を参照. - -### Issue (Issue) - -Issue は**進捗管理の補助**として使う.追跡したい作業に対して立て,PR と紐付けて可視化する(ボードを使う場合はボードにも載せる). - -- 作業 1 単位 = 1 Issue を推奨する.既に Issue がある作業は,新たに作らずそれに従って進める(重複 Issue を作らない). -- **Issue は着手・PR 作成・マージのいずれの段階でも必須としない**.小さい変更(typo・1 行修正等)や試験的・探索的な作業は Issue 無しで進めてよい. -- ただし**追跡する価値のある作業には Issue を立てるのが望ましい**(後追いと進捗可視化のため).特に複数回の `/implement` に跨る作業や,他メンバーに見えていてほしい作業は Issue を作る. -- PR と Issue を紐付ける場合は本文に `Closes #` を記載する.マージ時に Issue が自動クローズされる(ボードを使う場合はカードも `Done` へ移る). -- Issue 本文には少なくとも「やること」を書く.「完了条件(受け入れ基準)」は非自明な作業のみで構わない. -- 担当者は明確にしておくのが望ましい(重複着手を避けるため). -- Issue は最初に書き切らなくてよい.作業途中の進捗・確定事項は `/task-handoff` の進捗メモとして Issue に集約し,完了は PR の `Closes #<番号>` によるマージ時の自動クローズで反映する(`/implement` のフローでは Issue を更新しない). - -### Project ボード (Project Board) - -> ⚠ **既定では使わない**.タスク管理は Issue ベース(`gh issue list`)で運用し,`/task-create`・`/task-start`・`/task-handoff` は Projects に一切触れない(`project` スコープも不要).チームが拡大したり Issue が常時 10 件超になった等の局面でボードが必要になったら,**`.claude/project-board` を置いたときのみ**ボードを使う(手順は「管理者の初期設定」).ボードの有効化は `/set-mode`(solo / team の切替)とは独立しており,team でも必須ではない. - -`.claude/project-board` の書式(対象の Project を番号で明示する.`gh project list` による探索はしない): - -```text -owner=<リポジトリ所有者> -number= -``` - -ボードを使う場合の運用: - -- 列: `Todo` / `In Progress` / `In Review` / `Done`. -- Issue をカードとして配置し,状態を移動して可視化する. -- マージ連動の自動化を設定し,カード移動の手作業を最小化する(設定は管理者作業.「管理者の初期設定」参照). - -### タスクの流れ (Task Flow) - -Issue を立てる場合の標準フロー(小さい変更や探索的作業はこの限りでない). - -```text -1. Issue 起票(完了条件を明記) -2. 自分にアサイン(.claude/project-board がある場合はボードの In Progress へも移動) -3. main から作業ブランチ作成(git-conventions ルール) -4. /implement に Issue の内容を渡して実装(GUIDE_02) -5. PR 作成,本文に "Closes #<番号>" -6. セルフマージ条件を確認 → マージ -7. マージで Issue 自動クローズ(ボード使用時はカード自動 Done) -``` - -- 上記 1 は `/task-create`(事前定義用),2〜4 は `/task-start `(既存 Issue から着手)で半自動化できる(Issue を読んで人間の判断が要らなければ,または数問の質問で解消できればそのまま `/implement` に進む.会話で詰めるべき論点があれば停止する).Issue 無しで進める場合はどちらも不要. -- Claude へのタスク文脈は `CLAUDE.md` ではなく Issue から渡す.`gh issue view ` で取得する. - -## ブランチと PR (Branch & PR) - -`.claude/rules/git-conventions.md` に従う.チーム運用上の追加事項のみ以下に定める. - -- ブランチ命名は git-conventions ルールの基本形式(`[プレフィックス][概要]`)に従う.ブランチ名に Issue 番号は含めなくてよい. -- branch↔Issue の紐付けは PR 本文の `Closes #<番号>` で行う.マージ時に Issue が自動クローズされる.既存 Issue からブランチを作る場合は `gh issue develop` でネイティブにリンクできる(`.claude/skills/task-start/reference.md`). -- PR の `--title` はコミットメッセージと同じ書式(`[タグ] 内容`,`.claude/rules/git-conventions.md`). - -## レビューとマージ (Review & Merge) - -誰も手書きしない体制では,マージ条件が唯一の品質ゲートとなる.本プロジェクトは**条件付きセルフマージ**を採用する.他メンバーの Approve 待ちは原則作らない代わりに,作者自身が満たすべき条件を実質的なゲートとして定める. - -### 通常の機能 PR (Feature PR) - -次を全て満たせば,作者がセルフマージしてよい. - -- CI で全テストが緑である. -- 作者自身が Phase 1 の動作確認(実機・ブラウザ等,AI にできない確認)を済ませている(GUIDE_02). -- `/implement` のパイプラインをスキップせず完走している. -- 対応 Issue がある場合は完了条件を満たしている(Issue 無しの PR は不要). -- 共有設定(`CLAUDE.md` のルール部・`.claude/`)の変更を含まない. - -※ レビューは任意.他メンバーはコメントしてよいが,マージをブロックしない. - -### 共有設定を変更する PR (Shared Config PR) - -`CLAUDE.md` のルール部や `.claude/` を変更する PR は,全員の Claude の挙動を変えるため例外とする. - -- 機能 PR に混ぜず,専用 PR とする(「共有設定の扱い」参照). -- 他メンバー 1 名の Approve を必須とする(セルフマージ不可). - -### Dependabot の依存更新 PR (Dependabot PR) - -Dependabot が作成する依存更新 PR(security updates / version updates)は,人間が書いた PR ではないため上記の「`/implement` 完走」「Phase 1 動作確認」を満たせない.代わりに `/deps-update` のゲートを品質ゲートとする(`.claude/skills/deps-update/SKILL.md`). - -- **`/deps-update` がマージしてよいもの**: メジャー更新でなく,競合が無く,CI 緑(CI 未構築ならローカル検証緑)の PR.`gh pr merge --merge` で取り込む.これは「AI が `main` へマージする」唯一の例外である(GUIDE_02「コミットルール」). -- **人間が判断するもの**: メジャー更新(`0.x` のマイナー更新を含む),CI 赤,修正版の無い alert,Dependabot が PR を作れなかった alert.`/deps-update` が影響分析と推奨(そのままマージ/`/implement` で追従/`@dependabot ignore` で見送り)を PR コメントと完了報告に出すので,それを見て決める. -- 依存更新 PR は共有設定(`CLAUDE.md`・`.claude/`)を変更しないため,他メンバーの Approve は不要.`main` にブランチ保護(必須レビュー)を設定している場合は `/deps-update` はマージできないので,マージ可と判定した一覧を提示するにとどまり,人間がマージする. -- `/deps-update` を実行するのは原則 1 名(管理者またはその週の担当)とし,マージ後はチームに周知して全員が `git pull` する(直列運用のため,他メンバーの作業ブランチは次の rebase で追従する). - -### CI 構築までの暫定ゲート (Interim Gate) - -CI が未構築の間は「CI 緑」を以下で代替する.CI 構築後はこの節を削除する. - -- `/implement` を完走している. -- ローカルで全テストが緑である. -- 作者自身が Phase 1 の動作確認を済ませている. - -## 共有設定の扱い (Shared Configuration) - -`CLAUDE.md` と `.claude/`(agents・skills・rules・hooks・settings.json・template-overrides.md)は全員の Claude の挙動を決める共有インフラである. - -- **git 追跡を継続する**.untrack や `.gitignore` 化はしない(履歴の保全と挙動の統一のため). -- **進捗は `CLAUDE.md` に書かない**.進捗は Issues と git 履歴で追う(「タスク管理」参照). -- **変更は「チームルール変更」カテゴリ**として扱う. - - 機能 PR に混ぜない.専用 PR とする(ブランチは `chore/` または `docs/`). - - 他メンバー 1 名の Approve を必須とする. - - マージ後はチームに周知し,全員が `git pull` して Claude セッションを再起動する. - - ※ Claude はセッション開始時に `CLAUDE.md` を読むため,古いまま動くと文脈がずれる. -- **例外: ドキュメント一覧への追記**は,そのドキュメントを追加する PR と同じ PR で行ってよい.衝突しても両方の行を残せば解決できる. -- **個人・マシン固有の設定**は `.claude/settings.local.json` に置く.これは `.gitignore` 対象とし,共有の `settings.json` を個人都合で汚さない. - -## 作業の直列化 (Serialized Work) - -- 原則として,同時に進行中のコード作業は 1 件とする(進行中の Issue は原則 1 件.`.claude/project-board` でボードを使う場合は `In Progress` 列も同様). -- 次の作業に着手してよいのは,前の作業の PR が `main` にマージされた後とする(マージ条件は「レビューとマージ」参照). -- タスクは小さく保つ.直列運用では,1 単位が小さいほど次の人の待ち時間が短くなる. -- 直列運用により並行コンフリクトと共有設定のドリフトは原理的にほぼ発生しない.例外的に並行が生じてコンフリクトした場合は `.claude/skills/commit/reference.md` の rebase 手順をフォールバックとして用いる. -- `main` を壊した場合は他作業より優先して復旧する.自分で対処できない場合は直ちにチームへ報告する(`.claude/skills/commit/reference.md`「間違えて main にコミットしてしまった場合」). - -## メンバーのオンボーディング (Onboarding) - -新メンバー参加時の手順. - -1. リポジトリへのコラボレーター招待を承認する(GitHub の通知,または `https://github.com///invitations`). -2. リポジトリを clone する. -3. `ENV_02_環境構築手順.md`(GUIDE_01 参照,立ち上げ時に作成)に従い開発環境を構築する. -4. `gh auth login` で GitHub CLI を認証する.`.claude/project-board` があるプロジェクト(ボードを使う場合)のみ,`gh auth refresh -s project` で `project` スコープを追加する(`.claude/skills/task-start/reference.md`「必要なスコープ」). -5. 必要なら `.claude/settings.local.json` を用意する(個人設定.git 追跡されない). -6. 最初に `CLAUDE.md` と `docs/01_GUIDE/` を読む(特に本ガイドと GUIDE_02).Git 規約は `.claude/rules/git-conventions.md` にある. -7. `.gitignore` が整備されていることを確認する(`.claude/rules/git-conventions.md`). - -## 管理者の初期設定 (Admin Setup) - -以下は外部サービス操作を含み,原則として AI には実施できない(`gh` で操作できる設定のみ例外として注記する).ルール確定後に管理者(人間)が一度だけ行う. - -- GitHub リポジトリの作成,メンバー招待. - - リポジトリ作成後,**GitHub リポジトリのセキュリティ設定**(Dependabot alerts / security updates の有効化)は AI が `gh api` で行う(`/setup` の Phase 3・7 で実行.コマンド・検証・トラブル対応は `.claude/skills/setup/reference.md`「GitHub リポジトリのセキュリティ設定」,背景は GUIDE_01「環境構築」).`/setup` 完了後にリポジトリを作成した場合は,同 `reference.md` または `ENV_03_管理者用環境構築手順.md` に転記したコマンドを実行する(管理者が直接実行してもよい). -- (任意.既定では使わない)Project ボードを使い始める場合は以下を行う. - 1. GitHub Project を作成し,列(`Todo` / `In Progress` / `In Review` / `Done`)を定義する.マージ連動の自動化(PR マージ時にカードを `Done` へ移動)も設定する. - 2. `.claude/project-board` を作成し,`owner=<リポジトリ所有者>` と `number=` を書く(番号は `gh project list --owner ` で確認できる.書式は「Project ボード」参照).共有設定の変更として専用 PR で取り込む(「共有設定の扱い」). - 3. マージ後,全員が `git pull` し,`gh auth refresh -s project` で `project` スコープを追加する. - - ボードをやめる場合は `.claude/project-board` を削除する(以後 `/task-*` は Projects に触れない). -- Issue テンプレートの用意(「やること」「完了条件」欄). -- 共有設定変更 PR に他メンバー Approve を求める運用の周知(必要なら `main` のブランチ保護設定). -- CI の構築(全テストを実行し,緑をマージ条件にできる状態にする). - -※ 完了するまでは本ガイドの「CI 構築までの暫定ゲート」を適用する. diff --git "a/docs/02_ENV/ENV_01_\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.md" "b/docs/02_ENV/ENV_01_\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.md" new file mode 100644 index 0000000..c553d22 --- /dev/null +++ "b/docs/02_ENV/ENV_01_\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.md" @@ -0,0 +1,94 @@ +# 技術スタック (Tech Stack) + +## 概要 (Overview) + +舌セグメンテーションモデル(ResUNet)の学習コードを,手元の Windows で実装し,研究室の GPU サーバ(Newton・Archimedes)で学習する.学習データは手元 PC に置かないため,**手元は合成データでの実装確認のみ**とし,実データを触るコードはすべてサーバ上で動かす. + +土台は [TIASJudgeModel](https://github.com/rintoHasegawa/TIASJudgeModel) とそろえる.両サーバに同じ道具(uv・Python 3.12)が入っており,CUDA の版の問題も解決済みで,同じ流儀で行き来できるため. + +原本(`legacy/`)は 2021 年末ごろの PyTorch で書かれておりバージョンの記録が無い.当時の版は再現せず,**今の PyTorch に合わせて新しいコードを書く**.数値が完全に一致する再現は狙わず,同じ手順で同程度の精度が出ることを確かめる. + +## 言語・実行環境 (Language & Runtime) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| 言語 | Python | — | +| Python バージョン | 3.12(`.python-version` で固定) | TIASJudgeModel と同一.サーバにも導入済み | +| パッケージマネージャ | **uv** | `uv.lock` をコミットして再現性を担保する | +| 手元 OS | Windows 11 | 実装・合成データでの動作確認のみ(GPU なし) | +| 学習環境 | 研究室 GPU サーバ(Newton・Archimedes.Ubuntu 22.04・RTX A6000) | uv・Python 3.12 導入済み | + +## 機械学習フレームワーク (ML Framework) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| 学習フレームワーク | **PyTorch 2.x**・torchvision | ResUNet は torchvision の resnet18(ImageNet の事前学習の重み)を土台にしている | +| 学習ループ | 自前で記述 | 原本の `main.py` と同じ(Adam・Dice+BCE 損失・検証損失での早期終了).PyTorch Lightning は使わない | +| データ拡張 | `torchvision.transforms` | 原本と同じ(色のゆらぎ・左右反転) | +| ONNX の書き出し | `torch.onnx`(+ `onnx`) | DeepTIAS 2.7 同梱の `ResUNet.onnx` と同じ入出力の形にする(PLAN_01 の R3).原本は opset 11.今の PyTorch の書き出し方法で同じ形になるかは実装時に確かめる | + +新しいコードに移すのは **ResUNet(`ResNetUNet`)だけ**とする.原本にある他のモデル(UNet・NestedUNet・各 Pruning 版・2 タスク版・Pix2Pix)と比較用のモデル(FPN・PSPNet・DeepLabV3+)は `legacy/` に記録として残し,必要になった時点で追加する. + +## データ処理・評価 (Data Processing & Evaluation) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| 画像 IO | opencv-python-headless | 原本は `cv2.imread` で読んだ **BGR のまま** /255 して学習している.DeepTIAS・TIASJudgeModel の前処理もこれに合わせてあるため,読み込み方を変えない.サーバに GUI が無いので headless 版を使う | +| 数値計算 | NumPy | 学習中の IoU の計算もこれで行う | +| データ読み込み | tiasdata(サブモジュール [TIASDataHub](https://github.com/rintoHasegawa/TIASDataHub).uv の path 依存) | 計算サーバ上のバンドルを読む(PLAN_01 の R5).セグメンテーション用のデータ(画像と正解マスクの組)を TIASDataHub がどう渡すかは未確定(後述) | +| 書き出した ONNX の確認 | onnxruntime | 書き出した ONNX を CPU で推論し,入出力の形と PyTorch の出力との一致を確かめる | +| モデルの評価 | TIASJudgeModel の `tias-seg eval` | 本リポジトリでは作り直さない(PLAN_01 の R4) | +| 図の出力 | matplotlib | 学習曲線を PNG で出力する(サーバ上で描画し,画像ファイルだけ回収する) | + +## 設定と実験記録 (Configuration & Experiment Tracking) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| 設定ファイル | **YAML + pydantic**(スキーマ検証) | `configs/*.yaml` に学習条件を置く.原本でスクリプトに直接書かれていた値(バッチサイズ・学習率・エポック数等)とデータ・出力の場所を外に出す | +| 実験記録 | **軽量自作**(外部サービスを使わない) | `runs/<実験ID>/` に設定・指標・学習曲線・重みを書き出す.構成は仕様設計で決める | +| 手元への回収 | 指標・図・ログのみ | 画像・正解マスク・**ファイル名を含む結果**は回収しない.重み(pth・onnx)は明示的に指定したときだけ回収する([SPEC_01](../04_SPEC/SPEC_01_アーキテクチャ設計.md)「回収ホワイトリスト」) | + +## リモート実行 (Remote Execution) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| リモート実行ツール | **TIASJudgeModel の `tias-remote` を移植** | コード送信・空いている GPU の自動選択・ジョブ実行・結果回収(回収できるファイルを制限する) | +| 転送方式 | tar over ssh | Windows に rsync が無いため | +| 実行 | サーバ上の tmux 内で `uv run` | 接続が切れても学習が続く | +| SSH | Windows 標準 OpenSSH | 学外からは研究室 PC を ProxyJump の踏み台にする | +| データ | サーバ常設(コードのみ毎回転送) | — | +| 認証情報 | サーバに GitHub の認証情報を置かない | コードは常に手元から送る | + +## 開発ツール (Development Tools) + +| 項目 | 採用 | 備考 | +| --- | --- | --- | +| テスト | pytest | 合成データで動くテストのみ(実データに依存するテストは書かない) | +| lint / format | ruff | 規約は規約整備フェーズで定める.`legacy/` は対象から外す(原本を書き換えないため) | +| CI | **使わない**(アプリのコードについて) | ローカルで pytest・ruff を回す.※ テンプレート同梱の `.github/workflows/hooks-ci.yml`(`.claude/hooks/` のテスト)はそのまま残す | +| 依存更新 | Dependabot(`uv`・`github-actions` エコシステム) | 週 1 回.更新 PR はローカル検証で確認する | + +## CPU / GPU の依存差 (CPU / GPU Dependencies) + +TIASJudgeModel と同じ構成にする.**Linux(両サーバ)は PyTorch 公式の CUDA 12.6 版(cu126)**,**Windows(手元)は PyPI の CPU 版**を使い,`pyproject.toml` の `[tool.uv.sources]` で `torch`・`torchvision` の取得元を `sys_platform == 'linux'` のときだけ cu126 インデックスに向ける. + +- Archimedes はドライバ 535(CUDA 12.2 まで)のため,PyPI の既定(CUDA 13 版)では GPU が使えない.cu126 版は両サーバで動く(TIASJudgeModel の ENV_01 に経緯の記録がある) +- 両サーバで同じ torch ビルドになるため,どちらで学習しても条件がそろう + +## 採用しなかった選択肢 (Rejected Alternatives) + +| 候補 | 却下理由 | +| --- | --- | +| 2021 年当時の版(torch 1.10 前後・Python 3.8〜3.9)の再現 | 当時の版の記録が無く完全一致の保証が無い.今のサーバ(RTX A6000・現行ドライバ)で動くかも検証が要る | +| segmentation_models_pytorch(smp) | ResUNet は使っていない(比較用の FPN・PSPNet・DeepLabV3+ だけが使う).原本のコピーは公式 0.2.1 と実質同じなので,比較モデルが必要になったら pip で入れる | +| PyTorch Lightning | 原本でも `Pix2Pix.py` だけが使っている.ResUNet の学習ループは小さく,自前で足りる | +| scipy・scikit-image | 原本の境界損失(`BDLoss` 等)だけが使う.ResUNet の学習に使う Dice+BCE 損失には不要 | +| scikit-learn | 原本は IoU の計算に混同行列を使っているが,NumPy で足りる | +| Weights & Biases・MLflow | 外部送信や運用の手間が実験の規模に見合わない(TIASJudgeModel と同じ判断) | +| 配布用 ONNX の Git LFS 管理 | 今回は入れない(PLAN_01).必要になったら検討する | + +## 未確定事項 (Open Items) + +- TIASDataHub がセグメンテーション用のデータ(画像と正解マスクの組・学習用とテスト用の分け方)をバンドルでどう渡すか.学習データの入口はバンドルだけとし,フォルダを直接読む経路は作らない(2026-11-18 のユーザー判断).本リポジトリが必要とする内容は [SPEC_01](../04_SPEC/SPEC_01_アーキテクチャ設計.md)「データ契約」に書き,TIASDataHub 側の設計で確定する +- 今の `torch.onnx` で opset 11・同じ入出力名の ONNX を書き出せるか(実装時に確認) +- resnet18 の事前学習の重みの入手方法(サーバからダウンロードできるか.できなければ事前に配置する) diff --git "a/docs/02_ENV/ENV_02_\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" "b/docs/02_ENV/ENV_02_\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" new file mode 100644 index 0000000..d636164 --- /dev/null +++ "b/docs/02_ENV/ENV_02_\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" @@ -0,0 +1,74 @@ +# 環境構築手順 (Environment Setup) + +メンバーの参加時や環境の再構築時に使う手順.2026-11-18 に手元 PC(Windows 11)で実行して確かめた. + +## 前提ツール (Prerequisites) + +| ツール | 用途 | 確認したバージョン | 備考 | +| --- | --- | --- | --- | +| git | バージョン管理 | 2.54.0 | 運用は `.claude/rules/git-conventions.md` | +| gh | GitHub CLI | 2.93.0 | PR 作成・リポジトリ設定.`gh auth login` 済みであること | +| uv | Python・依存管理 | 0.12.5 | `winget install astral-sh.uv`.Python 3.12 は uv が用意する | +| Python 3.7 以上 + bash | `.claude/hooks/` の実行 | Python 3.12.10 | Windows は Git for Windows 付属の bash.※ Python が見つからないとアクセス制限フックが全ツールをブロックする | +| OpenSSH | サーバ接続 | — | Windows 11 標準(`C:\Windows\System32\OpenSSH\ssh.exe`) | + +## 手元 PC のセットアップ (Local Setup) + +```bash +git clone --recurse-submodules https://github.com/rintoHasegawa/TongueSegModel.git +cd TongueSegModel +uv sync +uv run pytest +``` + +- データ読み込みライブラリ `tiasdata` はサブモジュール `external/TIASDataHub` から入る.`--recurse-submodules` を付けずに clone したときは `git submodule update --init` を実行する(無いと `uv sync` が失敗する).TIASDataHub は非公開リポジトリのため,読み取り権限のある GitHub アカウントが要る +- 手元には **CPU 版の PyTorch** が入る([ENV_01「CPU / GPU の依存差」](ENV_01_技術スタック.md)).学習は回さず,実装と合成データでの動作確認に使う +- `uv run pytest` で,パッケージと主要な依存(torch・cv2・onnx・onnxruntime・tiasdata 等)が読み込めることを確かめる + +※ 手元(Windows)と Linux(サーバ)で入る torch の版が少し違う(2026-11-18 時点の `uv.lock` で,Windows は PyPI の 2.15.0,Linux は cu126 インデックスの 2.14.1).cu126 インデックスの最新が PyPI より遅れるため.学習はサーバだけで行うので実害は無い. + +## 原本(legacy/)の取り扱い (Legacy Folder) + +`legacy/` には OneDrive にあった原本のフォルダ全体を置いている([PLAN_01「管理対象」](../03_PLAN/PLAN_01_要件定義書.md)). + +- Git に入っているのはコード(.py)と実験条件の記録(`hparams.yaml`)だけ.**clone しても重み・結果は手に入らない** +- 重み(ckpt・pth・pb・onnx)と `result/`(約 4 GB)は,開発者本人の手元 PC の `legacy/` にだけある(OneDrive 側は 2026-11-18 に削除した) +- `legacy/` のコードは書き換えない(ruff の対象からも外している).新しいコードは `src/tongue_seg_model/` に書く +- `legacy/result/` には画像のファイル名を含む csv がある.Claude はこのフォルダの中身・ファイル名を読まない + +## 学習データの取り扱い (Training Data Handling) + +**手元 PC に学習データ(画像・正解マスク)を置かない.** これは手順ではなく守るべき制約である. + +- 原本は研究室 PC にある.学習用のコピーは Newton・Archimedes に置く(置き場所は [ENV_03](ENV_03_管理者用環境構築手順.md)) +- 手元へ回収するのは指標・学習曲線・ログのみ.画像・正解マスク・**画像のファイル名を含む結果**は回収しない +- `data/`・`runs/`・重みの拡張子(`*.pt`・`*.pth`・`*.ckpt`・`*.pb`・`*.onnx`)は `.gitignore` 済み + +## 研究室サーバの利用 (Lab Server) + +| Host 名 | アドレス | 用途 | +| --- | --- | --- | +| `Newton` | `192.168.23.14`(研究室 LAN 内) | 学習の実行.RTX A6000×3・Ubuntu 22.04・uv | +| `Archimedes` | `192.168.23.15`(研究室 LAN 内) | 学習の実行.RTX A6000×2・Ubuntu 22.04・uv.`/home` の空きが少ない | +| 踏み台 `labpc` | 研究室 PC(Tailscale 経由) | 学外から接続する場合は `-J labpc` を付ける | + +- SSH の鍵と `~/.ssh/config` は **SmTIAS-LightSim・TIASJudgeModel で構築済みのものを流用する**(設定手順は SmTIAS-LightSim の `docs/02_ENV/ENV_02_環境構築手順.md`「研究室サーバ編」) +- **サーバ上では編集しない**.コードは常に手元から送る +- サーバに GitHub の認証情報を置かない +- リモート実行ツール(TIASJudgeModel の `tias-remote` の移植)は実装フェーズで作る.※ 未検証(まだ無いため,サーバでの `uv sync` と GPU の確認は行っていない.[ENV_03](ENV_03_管理者用環境構築手順.md)「サーバ側の初期設定」) + +## 環境再現性のルール (Reproducibility Rules) + +- 依存の追加は `uv add`.`uv.lock` はコミットする +- 絶対パスをコードにハードコードしない(設定 YAML と環境変数で渡す) +- 乱数シードを設定ファイルで固定し,実際に使った設定を学習結果と一緒に保存する + +## トラブルシューティング (Troubleshooting) + +| 症状 | 原因 | 対処 | +| --- | --- | --- | +| `uv sync` が `external/TIASDataHub` が無いと言って失敗する | サブモジュールを取得していない | `git submodule update --init` | +| サーバで `torch.cuda.is_available()` が `False` | CPU 版 wheel が入った | ENV_01「CPU / GPU の依存差」に従い `[tool.uv.sources]` の cu126 インデックスの指定を確かめる | +| ファイル操作系のツールが全てブロックされる | フック用の Python が見つからない | `python3` / `python` / `py` のいずれかが起動できるようにする | +| サーバで `uv: command not found` | 非対話 ssh の PATH に `~/.local/bin` が入らない | `~/.local/bin/uv` を絶対パスで呼ぶ | +| `git add` で「CRLF will be replaced by LF」の警告 | `.gitattributes` が改行コードを LF にそろえている | 問題ない(`legacy/` の .py も Git の中では LF になる.手元のファイルは CRLF のまま) | diff --git "a/docs/02_ENV/ENV_03_\347\256\241\347\220\206\350\200\205\347\224\250\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" "b/docs/02_ENV/ENV_03_\347\256\241\347\220\206\350\200\205\347\224\250\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" new file mode 100644 index 0000000..6730c79 --- /dev/null +++ "b/docs/02_ENV/ENV_03_\347\256\241\347\220\206\350\200\205\347\224\250\347\222\260\345\242\203\346\247\213\347\257\211\346\211\213\351\240\206.md" @@ -0,0 +1,85 @@ +# 管理者用環境構築手順 (Administrator Setup) + +プロジェクト作成時に **一度だけ** 行う初期設定. + +## GitHub リポジトリの作成 (Repository Creation) + +private リポジトリとして作成する(学習データ・重みは含めないが,研究途中のコードを公開しないため). + +```bash +gh repo create rintoHasegawa/TongueSegModel --private --source=. --remote=origin \ + --description "舌セグメンテーションモデル(ResUNet)の学習コード" +``` + +2026-11-18 に実施済み(private.`origin` を設定しただけで,この時点ではコードを送っていない). + +## リポジトリのセキュリティ設定 (Repository Security Settings) + +Dependabot alerts(脆弱性検出)と Dependabot security updates は**リポジトリごとに既定で OFF** なので,作成直後に有効化する(冪等なので再実行してよい). + +```bash +gh api -X PUT repos/rintoHasegawa/TongueSegModel/vulnerability-alerts +gh api -X PUT repos/rintoHasegawa/TongueSegModel/automated-security-fixes +``` + +検証: + +```bash +gh api repos/rintoHasegawa/TongueSegModel/vulnerability-alerts # 204 なら有効(404 なら無効) +gh api repos/rintoHasegawa/TongueSegModel/automated-security-fixes # {"enabled":true,...} なら有効 +``` + +2026-11-18 に実施済み(有効化の 2 つとも 204,検証は 204 と `{"enabled":true,"paused":false}`). + +※ 依存バージョンの定期更新は `.github/dependabot.yml` で設定済み(別物.リポジトリ設定とは独立に動く). + +## サブモジュールの追加 (Submodule) + +データ読み込みライブラリ `tiasdata` を使うため,TIASDataHub をサブモジュールとして追加した(2026-11-18 に実施済み). + +```bash +git submodule add https://github.com/rintoHasegawa/TIASDataHub.git external/TIASDataHub +``` + +TIASDataHub を新しい版に上げるときは,`external/TIASDataHub` で `git pull` してから親リポジトリで `uv sync` し,サブモジュールの参照先の変更をコミットする. + +## サーバ側の初期設定 (Server Setup) + +Newton・Archimedes の両方で行う.※ 未検証(リモート実行ツールの移植後に実施する). + +```bash +mkdir -p ~/work/TongueSegModel # コード置き場(手元から送ったコードで上書きされる) +``` + +コードを初回送信したあと,サーバ上で以下を確認する. + +```bash +cd ~/work/TongueSegModel +~/.local/bin/uv sync +~/.local/bin/uv run python -c "import torch; print(torch.cuda.is_available(), torch.cuda.device_count())" +``` + +`True` と GPU 台数が出ることを確認する.`False` の場合は [ENV_01「CPU / GPU の依存差」](ENV_01_技術スタック.md)に従う. + +> ⚠ Archimedes の `/home` は共用ディスクの空きが少ない.Python 環境(CUDA 版 PyTorch)が 6〜8 GB を使う.重みを溜め込まないこと. + +## 学習データとモデルの置き場所 (Data and Model Locations) + +| もの | 置き場所 | 備考 | +| --- | --- | --- | +| 学習データの原本(画像・正解マスク) | 研究室 PC の `E:\clinical-data\TongueSegmentation\`(2390 ファイル.うち `input/` が 1804) | OneDrive の同期フォルダの外 | +| 学習データの作業用コピー | Newton・Archimedes の `~/data/TongueSegmentation/input/`(1804 ファイル.`drwx------`) | TIASJudgeModel の作業で 2026-09-28 に配置済み(同リポジトリの ENV_03「セグメンテーション用データの配置」).原本と同じフォルダ構成 | +| 配布している `ResUNet.onnx` | Newton・Archimedes の `~/models/TongueSegmentation/` | 同上.DeepTIAS 2.7 同梱のものとハッシュが一致 | +| 原本の重み・結果(約 4 GB) | 開発者本人の手元 PC の `legacy/`・研究室の共有フォルダ | Git に入らない.共有フォルダがバックアップになる | + +- 今後は TIASDataHub に取り込み,バンドルで計算サーバに渡す予定.バンドルの置き場所の既定は `~/data/tiasdata/`(TIASJudgeModel と同じ) +- 新たにデータを運ぶ必要が出たときは,TIASJudgeModel の ENV_03 と同じく**研究室 PC からサーバへ直送**し,手元 PC を経由させない + +## 人間が確認すべき事項 (Human Checklist) + +Claude は実施できない. + +- **`legacy/` の重み・結果のバックアップ**: 研究室の共有フォルダに同じものがある(2026-11-18 にユーザーが確認).OneDrive 側は削除したので,手元 PC の `legacy/` と共有フォルダの 2 か所にある +- `legacy/result/` は当面 Git に入れない(2026-11-18 のユーザー判断).入れたくなったときは,先に csv・txt の中身を確認する(`Log_detail.csv` の 1 列目が画像のファイル名で,患者 ID を含む可能性がある) +- 原本のコードの作者とライセンスの確認(リポジトリを他の人に共有する前に) +- 学習データの倫理審査・データ利用許諾の範囲(モデルの再学習が含まれるか) diff --git "a/docs/02_ENV/ENV_04_\351\226\213\347\231\272\343\202\263\343\203\236\343\203\263\343\203\211.md" "b/docs/02_ENV/ENV_04_\351\226\213\347\231\272\343\202\263\343\203\236\343\203\263\343\203\211.md" new file mode 100644 index 0000000..3690abb --- /dev/null +++ "b/docs/02_ENV/ENV_04_\351\226\213\347\231\272\343\202\263\343\203\236\343\203\263\343\203\211.md" @@ -0,0 +1,32 @@ +# 開発コマンド (Development Commands) + +日常の開発で使うコマンドの一覧.**コマンドを推測せず必ず本ファイルを参照する**(新しく確定・変更された時は本ファイルに反映する). + +※ Git Bash ではログの日本語が文字化けすることがある.先頭に `PYTHONIOENCODING=utf-8` を付けると正しく表示される. + +## 環境 (Environment) + +| 目的 | コマンド | 備考 | +| --- | --- | --- | +| サブモジュールの取得 | `git submodule update --init` | 初回のみ(`tiasdata` は `external/TIASDataHub` から入る.無いと `uv sync` が失敗する) | +| 依存の同期 | `uv sync` | 初回・`pyproject.toml` 変更後.手元には CPU 版 PyTorch が入る | +| 依存の追加 | `uv add <パッケージ>` | `uv.lock` が更新されるのでコミットする | +| 開発用依存の追加 | `uv add --dev <パッケージ>` | pytest・ruff 等 | +| Python の実行 | `uv run python <スクリプト>` | 仮想環境を明示的に有効化しなくてよい | + +## テスト・lint (Test & Lint) + +| 目的 | コマンド | 備考 | +| --- | --- | --- | +| テスト | `uv run pytest` | `tests/` だけが対象.時間のかかるテストを除くときは `-m "not slow"` | +| lint | `uv run ruff check .` | `.claude/`・`external/`・`legacy/` は対象外 | +| lint の自動修正 | `uv run ruff check . --fix` | — | +| 整形 | `uv run ruff format .` | — | +| 整形の確認だけ | `uv run ruff format --check .` | — | + +## 学習・ONNX の書き出し・リモート実行 (Training, Export & Remote) + +未定(実装フェーズでコマンドが確定した時点で追記する). + +- 原本(`legacy/`)のスクリプトは,埋め込みのパスと古いライブラリを前提にしているため,このままでは実行しない +- 学習したモデルの評価は TIASJudgeModel の `tias-seg eval` を使う(同リポジトリの ENV_04) diff --git "a/docs/03_PLAN/PLAN_01_\350\246\201\344\273\266\345\256\232\347\276\251\346\233\270.md" "b/docs/03_PLAN/PLAN_01_\350\246\201\344\273\266\345\256\232\347\276\251\346\233\270.md" new file mode 100644 index 0000000..1b306f8 --- /dev/null +++ "b/docs/03_PLAN/PLAN_01_\350\246\201\344\273\266\345\256\232\347\276\251\346\233\270.md" @@ -0,0 +1,133 @@ +# 要件定義書 (Requirements) + +## プロジェクトの目的 (Purpose) + +舌セグメンテーションモデル(ResUNet)の学習コードを Git で管理し,計算サーバで学習を再現できる状態にする. + +- 学習コードの原本は OneDrive(`OneDrive - 千葉大学\ドキュメント\TongueSegmentation\`)にしか無く,変更履歴が残っていなかった +- 原本のフォルダ全体を本リポジトリの `legacy/` にコピーした(全 331 ファイルのハッシュが原本と一致することを確認済み).以降は `legacy/` を原本とし,OneDrive 側は削除する +- まず原本のコードを**そのまま** Git に入れて出発点を記録し,その上で計算サーバでの再現・TIASDataHub との連携・コード整理を段階的に進める +- 精度の改善(新しいモデルの開発)は本プロジェクトの主目的ではない.再現できる学習基盤を作ることを優先する + +## 対象ユーザー (Target Users) + +- **直接**: 開発者本人(研究用途) +- **間接**: 研究室で舌セグメンテーションを使う人(DeepTIAS・推論サーバーに載せるモデルを再学習する人,後任) + +## 関連するリポジトリ・システム (Related Systems) + +| 名前 | 役割 | 本プロジェクトとの関係 | +| --- | --- | --- | +| OneDrive の原本(`TongueSegmentation\`) | 学習コードの原本(Git 管理なし) | 取り込み元.`legacy/` にコピー済みで,以降は本リポジトリを正とする | +| TIASJudgeModel(`src/tias_judge_model/segmentation/`) | DeepTIAS 2.7 の前処理・後処理の Python 再現と評価(`tias-seg eval`) | 学習したモデルの評価に使う.評価の仕組みは本リポジトリで作り直さない | +| GitBucket `nakaguchi/TongueSegmentation`(中口先生作) | 推論サーバー | 学習したモデル(ONNX)の利用先.本リポジトリでは変更しない | +| DeepTIAS 2.7 | `ResUNet.onnx` を同梱するアプリ | 書き出す ONNX の入出力の形を合わせる相手 | +| TIASDataHub | 臨床データの取り込みとバンドルの作成 | 学習データの受け取り元(今後) | +| 計算サーバ(Newton・Archimedes) | 学習の実行環境 | 学習を再現する場所 | + +## 原本の構成と調査結果 (Survey of the Original) + +原本のコード(.py)と設定(yaml)を読んで分かったこと.データ・重み・`result/` の中身とファイル名は見ていない. +以下のパスは原本のフォルダの中での位置で,本リポジトリでは `legacy/` の下にある(例: `source/main.py` → `legacy/source/main.py`). + +| 場所 | 中身 | 調査結果 | +| --- | --- | --- | +| `source/*.py`(9 個) | 学習・評価・変換のスクリプト | 下表 | +| `source/lightning_logs/version_*/`(43 個) | PyTorch Lightning の実行ログ.`hparams.yaml`・`events.out.tfevents.*`・`checkpoints/`(ckpt) | yaml 43 個は**設定ファイルではなく `Pix2Pix.py` の実行ごとのハイパーパラメータの記録**(`display_step`・`lambda_recon`・`learning_rate` 等).ckpt 20 個もここにある | +| `source/colabs/` | 空 | — | +| `temp/main.py` | `source/main.py` の古い版(PSPNet で学習) | — | +| `segmentation_models/` | segmentation_models_pytorch(smp)0.2.1 のコピー | 公式の 0.2.1 との差分は 2 か所だけ(活性化関数 `clamp` の追加,FPN の `name` を `"FPN-..."` に変更).どちらも本プロジェクトのコードからは使われていないため,**pip の `segmentation-models-pytorch==0.2.1` で置き換えられる** | +| `input/` | 空(0 ファイル) | 学習データは原本のフォルダに無い(研究室 PC にある) | +| `result/`・`output/` | 重み・評価結果・ONNX | 中身は見ていない | + +`source/` の .py の役割: + +| ファイル | 役割 | +| --- | --- | +| `main.py` | 学習と評価を 1 本で行うスクリプト(現状 `UNet_Pruning` を学習.Dice+BCE 損失・Adam・早期終了・テストセットで IoU を計算) | +| `models.py` | モデル定義.`ResNetUNet`(= ResUNet.torchvision の resnet18 を使う),`UNet`・`NestedUNet`・各 `_Pruning` 版・2 タスク版 | +| `losses.py` | 損失関数(Dice・BCE・境界損失の組み合わせ) | +| `utils.py` | 乱数の固定・小領域除去 | +| `evaluation.py` | 学習済みモデルの評価(FPN 等の比較モデル) | +| `pytorchToOnnx.py` | `ResNetUNet` の重みを ONNX(入力 `1×3×256×256`・opset 11)に書き出す | +| `MTL.py` | 2 タスク(セグメンテーション+再構成)の学習・評価 | +| `Pix2Pix.py` | Pix2Pix(PyTorch Lightning)によるセグメンテーション | +| `test.py` | 試し書き(`pandas` の動作確認.このままでは動かない) | + +コードの特徴(計算サーバでの再現・整理で直す対象): + +- データの場所が `..\input\train\{sample,label}`・`..\input\test_extra\cropped\{sample,label}` と相対パス(Windows の区切り文字)で埋め込まれている +- 学習済みの重みの場所が `D:\...\result\CompareModels\<モデル名>\bestModel.pth` と絶対パスで埋め込まれている +- 設定値(バッチサイズ・学習率・エポック数・モデルの種類等)がスクリプトの中に直接書かれている +- `from source.xxx import *` で読み込むため,リポジトリのルートを `sys.path` に入れて実行する前提(PyCharm 等の実行構成) +- 評価結果の `Log_detail.csv` には**画像のファイル名**が 1 行ずつ書かれる(`result/` の csv にファイル名が含まれることをコードで確認した) +- 依存ライブラリのバージョンの記録が無い(smp 0.2.1 が 2021 年 11 月版なので,2021 年末ごろの PyTorch で書かれたと推測) + +## スコープ (Scope) + +### やること (In Scope) + +段階的に進める.各段階の詳細な分割は開発計画(`PLAN_02_開発ステップ.md`)で決める. + +1. **原本の取り込み**: 原本のフォルダを `legacy/` に置き,コードを手を加えずに Git に入れて出発点として記録する(Git に入れる範囲は「管理対象」の表).新しいコードは `legacy/` の外に書き,`legacy/` のコードは書き換えない +2. **計算サーバでの再現**: Newton・Archimedes で学習を再現できるようにする + - 依存ライブラリと Python のバージョンを固定する + - データ・出力・重みの場所を設定ファイルまたは引数で渡せるようにする(埋め込みのパスを無くす) + - `segmentation_models/` のコピーを pip パッケージに置き換える +3. **TIASDataHub との連携**: TIASDataHub が作るバンドルを学習データとして読めるようにする +4. **コード整理**: 学習・評価・ONNX 書き出しを整理し,テストを付ける(挙動は変えない.変える場合は理由を記録する) + +### やらないこと (Out of Scope) + +- 推論サーバー(GitBucket `nakaguchi/TongueSegmentation`)・DeepTIAS の変更 +- DeepTIAS 2.7 の前処理・後処理の再現と評価の作り直し(TIASJudgeModel の `tias-seg eval` を使う) +- 学習データ・正解マスクの管理(研究室 PC と TIASDataHub で管理する) +- 学習済みの重みの管理・配布(研究室 PC・計算サーバに置く) +- 新しいモデル構造の研究開発(必要になったら別途計画する) +- 学習データ・重みを手元 PC に置くこと + +## 管理対象 (What Goes into Git) + +原本のフォルダ全体(重み・結果を含む約 4GB)を `legacy/` に置くが,Git に入れるのは下表の「入れる」だけとする.`.gitignore` で `legacy/` を既定で除外し,入れるものだけを個別に許可している.「入れない」ものは手元 PC の `legacy/` にだけあり,バックアップは別途必要になる. + +| 対象(`legacy/` の下) | 扱い | 理由 | +| --- | --- | --- | +| `source/*.py`(9 個,`test.py` を含む) | 入れる | 学習コードの本体 | +| `temp/main.py` | 入れる | 原本をそのまま残すため(整理の段階で残すか決める) | +| `source/lightning_logs/*/hparams.yaml`(43 個) | 入れる(※ 要確認) | `Pix2Pix.py` の実験条件の記録.ハイパーパラメータの値だけでファイル名・患者情報を含まない | +| `source/lightning_logs/*/events.out.tfevents.*` | 入れない | TensorBoard の実行ログ(バイナリ).ファイル名に実行した PC 名を含む | +| ckpt・pth・pb・onnx(重み) | 入れない | 研究室 PC・計算サーバに置く.配布用の `ResUNet.onnx` も今回は入れない(必要になったら Git LFS を検討する) | +| `result/` の csv・txt | 入れない(当面.2026-11-18 のユーザー判断) | `Log_detail.csv` が画像のファイル名(患者 ID の可能性)を含む.入れるときは先に中身を確認する | +| `segmentation_models/` | 入れない | pip の `segmentation-models-pytorch==0.2.1` で置き換える(差分は使われていない 2 か所のみ) | +| `input/`・`output/` | 入れない | 空のフォルダ・出力(ONNX) | +| `__pycache__/`・`source/colabs/`(空) | 入れない | 生成物・空フォルダ | + +## データの取り扱い (Data Handling) + +- 学習データ(画像・正解マスク)は研究室 PC の `E:\clinical-data\TongueSegmentation\` にある(2390 ファイル.うち `input/` が 1804).**手元 PC には置かない** +- 計算サーバへの受け渡しは,今後 TIASDataHub に取り込んでバンドルで行う(TIASJudgeModel の記録では,同じデータが両サーバの `~/data/TongueSegmentation/input/` に既に置かれているが,本プロジェクトの学習はバンドルだけを読む.2026-11-18 のユーザー判断) +- Claude はデータの中身・ファイル名を読まない(TIASDataHub のルールと同じ).学習の結果のうちファイル名を含むもの(`Log_detail.csv` 等)も読まない +- 学習で出る結果のファイル(重み・評価結果)はリポジトリの外に出力し,Git に入れない + +## 要件 (Requirements) + +### 機能要件 (Functional Requirements) + +- **R1 原本の記録**: `legacy/` のコードは原本と同じ内容のまま Git に入れる(改行コード以外は変えない).新しいコードは `legacy/` の外に書き,原本のどこを元にしたかを追えるようにする +- **R2 学習の再現**: 計算サーバで,1 つのコマンドと設定ファイルで ResUNet の学習を実行できること(データの場所・出力先・ハイパーパラメータを外から渡す) +- **R3 ONNX の互換性**: 書き出す ONNX が DeepTIAS 2.7 同梱の `ResUNet.onnx` と同じ入出力の形であること(入力 `(1, 3, 256, 256)`・BGR を /255 した値,出力 `(1, 2, 256, 256)`・チャンネル 0 が舌).推論サーバー・DeepTIAS・TIASJudgeModel がそのまま使えるようにするため +- **R4 評価**: 学習したモデルを TIASJudgeModel の `tias-seg eval` で評価できること(本リポジトリでは評価を作り直さない) +- **R5 TIASDataHub の入力**: TIASDataHub のバンドルを学習データとして読めること + +### 非機能要件 (Non-functional Requirements) + +- **再現性**: 乱数の種・依存ライブラリのバージョン・設定ファイルで,同じ条件の学習をやり直せること +- **データの保護**: 学習データ・重み・ファイル名を含む結果がリポジトリに入らないこと(`.gitignore` で防ぐ) +- **挙動の保存**: コード整理で学習の手順(前処理・損失・評価の計算)を変えないこと.変える場合は理由と影響を記録する + +## 未決事項 (Open Questions) + +- `lightning_logs/` の `hparams.yaml` を入れるか(上表では「入れる」とした.Pix2Pix の実験条件の記録としてしか役に立たないため,入れなくてもよい) +- 原作者とライセンス: 原本のコードの作者(埋め込みのパスに前任者の名前がある)と,リポジトリを公開・共有するときの扱い +- 原本で最後に配布用 `ResUNet.onnx` を作ったときの学習条件(`main.py` は現状 `UNet_Pruning` を学習する設定になっており,ResUNet の学習条件はコードから確定できない) +- `MTL.py`・`Pix2Pix.py` 等,ResUNet 以外の実験コードを整理の段階で残すか diff --git "a/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" "b/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" new file mode 100644 index 0000000..1668cbf --- /dev/null +++ "b/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" @@ -0,0 +1,65 @@ +# 開発ステップ (Development Steps) + +[PLAN_01 要件定義書](PLAN_01_要件定義書.md)のスコープを,実装の順に分けたもの.各ステップは `/implement <タスク>` 1 回で扱える大きさにしている.仕様は [SPEC_01](../04_SPEC/SPEC_01_アーキテクチャ設計.md)〜[SPEC_03](../04_SPEC/SPEC_03_リモート実行仕様.md). + +## 進め方の方針 (Approach) + +- **マイルストーン 1 は手元の合成データだけで完結させる**.TIASDataHub がセグメンテーション用データに対応するまで実データの学習は回せないため,その間に学習・ONNX の書き出し・リモート実行の実装と確認を済ませる +- **部品(純関数)を先に作り,学習ループは後にする**.モデル・前処理・損失・IoU を原本と突き合わせて固めてから組み上げる +- **原本との一致は,配布している重みで確かめる**(ステップ 1-7).学習をやり直さなくても,モデルの移植と ONNX の書き出しが正しいかを確かめられる +- 実データが要るステップ(マイルストーン 2)は,TIASDataHub 側の作業(別リポジトリ)が前提になる.**着手の時期は Claude が提案する**(2026-11-18 のユーザー判断): ステップ 1-4 が済んだ時点(本リポジトリが manifest に求める内容が,動くコードとして固まった時点)で,ステップ 2-1 の着手を提案する.マイルストーン 1 の残り(1-5〜1-8)と並行して進められる +- **ステップは表の順(1-1 → 1-8)に進める**(2026-11-18 のユーザー判断で順番は Claude に任された).リモート実行(1-8)を最後にするのは,サーバで確かめたい学習(1-5)と ONNX の書き出し(1-6)がそろってから移植すれば,1 回の確認で両方をサーバの GPU で試せるため + +## マイルストーン 1: 合成データで一通り動かす (M1: End-to-end on Synthetic Data) + +| ステップ | 内容 | 完了の条件 | +| --- | --- | --- | +| 1-1 設定と実験の出力 | 設定スキーマ(`schema.py`.既定値は SPEC_02 の原本と同じ学習条件),`configs/synthetic.yaml`・`configs/resunet.yaml`,実験 ID と `runs/<実験ID>/` の作成,`config.yaml`・`log.txt` の書き出し | 不正な設定で止まる.既定値が SPEC_02 の表と一致する(テスト) | +| 1-2 モデル | ResUNet(原本の `ResNetUNet`)を `models/` に移す | 出力の形が `(N, 2, H, W)`.`state_dict` のキーが原本と同じ(テスト) | +| 1-3 前処理・損失・IoU | 画像とマスクの前処理,Dice+BCE 損失(`bce_input` の切り替え),学習後の評価の IoU を純関数で作る | 手計算した期待値と一致する(テスト) | +| 1-4 合成データとデータの読み込み | バンドルの形の合成データを作るスクリプト,バンドルの読み込み(`data/bundle.py`),Dataset,データ拡張,分割 | 合成のバンドルを読める.組の欠け・大きさの違いで止まる.分割が seed で再現する(テスト).※ manifest の列名は仮(ステップ 2-2 で確定) | +| 1-5 学習 | 学習ループ・早期終了・最良の重みの保存・学習後の評価・`history.csv`・`metrics.json`・学習曲線(コマンド `tsm-train`) | 手元の合成データで数エポック回り,`runs/<実験ID>/` に SPEC_01 の出力がそろう | +| 1-6 ONNX の書き出し | `best.pth` から ONNX を書き出し,onnxruntime で形と PyTorch との一致を確かめる(コマンド `tsm-export`) | 合成データで学習した重みから書き出せ,入出力の形が `(1, 3, 256, 256)` → `(1, 2, 256, 256)` | +| 1-7 原本の重みでの確認 | 原本の ResUNet の重み(`legacy/result/` にある `bestModel.pth`)を新しいモデルに読み込み,ONNX を書き出して,配布している `ResUNet.onnx`(`legacy/output/`)と同じ入力に対する出力を比べる | 出力の差が十分小さい(差の大きさを記録する).Claude が単独で実行してよい(2026-11-18 のユーザー判断).重みの場所は原本のコードに書かれたパスと,`legacy/output/` の `*.onnx` に絞った検索で求める(`.claude/rules/legacy.md`.csv・txt は読まない・一覧しない) | +| 1-8 リモート実行 | TIASJudgeModel の `tias-remote` を移植する(コマンド `tsm-remote`.`legacy/` を送らない・回収ホワイトリスト).サーバ側の初期設定(ENV_03) | 単体テストが通る.Newton・Archimedes で合成データの学習が GPU で回り,結果を回収できる(実サーバの確認まで行う) | + +- ステップ 1-7 は 1-2・1-6 が済めば実行できる.モデルの移植の正しさを学習なしで確かめられるので,1-6 の直後に行う +- ステップ 1-8 のうち実サーバでの確認(接続・送信・起動・回収)は,Claude が実行して結果を報告する.共用サーバで他の人の GPU を使わないこと(空き判定)と,回収されたファイルがホワイトリストどおりであることを報告に含める + +## マイルストーン 2: 実データで学習を再現する (M2: Reproduce on Real Data) + +| ステップ | 内容 | 完了の条件 | +| --- | --- | --- | +| 2-1 TIASDataHub の対応(**別リポジトリ**) | TIASDataHub でセグメンテーション用データ(研究室 PC の `E:\clinical-data\TongueSegmentation\`)の取り込みとデータセットの定義を作り,バンドルを両サーバに配置する | 両サーバの `~/data/tiasdata/` にバンドルがある.本リポジトリが要る情報(SPEC_01「データ契約」)が manifest にある | +| 2-2 データ契約の確定 | 2-1 で決まった列名・種類名に合わせて SPEC_01「データ契約」と `data/bundle.py`・合成データを直す.サブモジュールを更新する | 実データのバンドルを読め,組の数・大きさの確認を通る(サーバ上.集計値だけを見る) | +| 2-3 学習の再現 | `configs/resunet.yaml`(原本と同じ条件)でサーバで学習する | 学習が最後まで回り,テスト用データの IoU の集計値が得られる | +| 2-4 配布中のモデルとの比較 | 学習したモデルの ONNX を TIASJudgeModel の `tias-seg eval` で評価し,配布している `ResUNet.onnx` の結果と比べる | 同程度の精度であることを確かめ,結果を `docs/06_TEST/` に記録する | + +- 2-1 は TIASDataHub の開発計画(マイルストーン 2 以降)に入っている作業で,本リポジトリのステップではない.ステップ 1-4 が済んだ時点で Claude が着手を提案し,TIASDataHub のリポジトリで作業する +- 2-3 の結果が配布中のモデルと大きく違う場合は,仮定した学習条件(SPEC_02「再現の前提」)を見直す + +## マイルストーン 3: 整理と引き継ぎ (M3: Cleanup & Handover) + +必要になった時点で行う.順序は決めない. + +| ステップ | 内容 | +| --- | --- | +| 3-1 原本の挙動の見直し | 「直したくなる挙動」(SPEC_02)を設定で直した場合の影響を実データで比べ,既定を変えるかを決める | +| 3-2 患者単位の分割 | バンドルに患者の ID がある場合に,患者単位の分割で学習して結果を比べる | +| 3-3 未決事項の解消 | 原本のコードの作者とライセンスの確認,`legacy/result/` の csv・txt の扱い,`legacy/` の重みのバックアップ(PLAN_01「未決事項」・ENV_03「人間が確認すべき事項」) | +| 3-4 比較用のモデル | 必要になったら,原本の他のモデル(UNet・FPN 等)を移す | + +## 依存関係 (Dependencies) + +```text +1-1 ─┬─ 1-2 ─┬─ 1-5 ── 1-6 ── 1-7 + ├─ 1-3 ─┤ + ├─ 1-4 ─┘ + └─ 1-8 ───────────────┐ + ├─ 2-3 ── 2-4 +2-1(TIASDataHub)── 2-2 ──┘ +``` + +## 最初の実装ステップ (First Step) + +**ステップ 1-1(設定と実験の出力)**から始める.`/implement ステップ 1-1 設定スキーマと実験の出力の土台を作る` で開始できる. diff --git "a/docs/04_SPEC/SPEC_01_\343\202\242\343\203\274\343\202\255\343\203\206\343\202\257\343\203\201\343\203\243\350\250\255\350\250\210.md" "b/docs/04_SPEC/SPEC_01_\343\202\242\343\203\274\343\202\255\343\203\206\343\202\257\343\203\201\343\203\243\350\250\255\350\250\210.md" new file mode 100644 index 0000000..7eb20e5 --- /dev/null +++ "b/docs/04_SPEC/SPEC_01_\343\202\242\343\203\274\343\202\255\343\203\206\343\202\257\343\203\201\343\203\243\350\250\255\350\250\210.md" @@ -0,0 +1,133 @@ +# アーキテクチャ設計 (Architecture) + +## 基本方針 (Principles) + +1. **原本(`legacy/`)は書き換えない**.新しいコードは `src/tongue_seg_model/` に書き,原本のどの処理を元にしたかを [SPEC_02](SPEC_02_学習・ONNX書き出し仕様.md) の対応表で追えるようにする +2. **実データに触るコードはサーバでしか動かさない**.手元では合成データで同じコードパスを流す +3. **学習データの入口は TIASDataHub のバンドルだけ**とする(フォルダを直接読む経路は作らない.2026-11-18 のユーザー判断).手元の合成データもバンドルと同じ形で作り,読み込みのコードを 1 本にする +4. **手元への回収はホワイトリスト方式**.回収対象を明示的に列挙し,列挙外(画像・manifest・画像のファイル名を含む結果)は持ち帰れないようにする +5. 設定は YAML に集約し,pydantic で検証する.コードに絶対パス・学習条件を書かない +6. 実験は `runs/<実験ID>/` に閉じる.同じ設定と seed で同じ手順をやり直せるようにする + +## ディレクトリ構成 (Directory Layout) + +```text +TongueSegModel/ +├── configs/ # 学習条件・サーバ設定の YAML +├── external/TIASDataHub/ # サブモジュール(データ読み込みライブラリ tiasdata) +├── legacy/ # 原本(書き換えない.Git に入るのは .py と hparams.yaml だけ) +├── src/tongue_seg_model/ +│ ├── schema.py # pydantic 設定スキーマ +│ ├── data/ # バンドルの読み込み・Dataset・分割・前処理・データ拡張 +│ ├── models/ # ResUNet(原本の ResNetUNet) +│ ├── training/ # 学習ループ・損失・学習中の評価 +│ ├── export/ # ONNX の書き出しと確認 +│ ├── remote/ # リモート実行(tar over ssh・tmux・回収) +│ └── cli/ # エントリポイント +├── scripts/ # 合成データ(バンドルの形)の生成 +├── tests/ +├── data/ # .gitignore(合成データ.実データは置かない) +└── runs/ # .gitignore(実験結果) +``` + +依存方向は `cli` → `training` / `export` → `data` / `models` の一方向とする.`data` と `models` は CLI・学習ループを import しない.`remote` は他のどれにも依存しない(torch を import しない). + +## データ契約 (Data Contract) + +学習データの原本は研究室 PC で管理し,[TIASDataHub](https://github.com/rintoHasegawa/TIASDataHub) のバンドルとして各計算サーバへ配布する.学習はサーバ上のコピーを `tiasdata.load` で読む.バンドルの場所は環境変数 `TIASDATA_BUNDLES`(既定 `~/data/tiasdata`)で決まる.`tiasdata` を import するのは `data/bundle.py` だけとする. + +> ⚠ **TIASDataHub はまだセグメンテーション用データの取り込みに対応していない**(同リポジトリの開発計画でマイルストーン 2 以降).以下は本リポジトリが**必要とする内容**であり,列名・種類名は TIASDataHub 側の設計で確定してから本節を更新する.それまでは合成データのバンドルで実装と確認を進め,実データでの学習は TIASDataHub の対応を待つ. + +バンドルの基本の形は既存のもの(TIASDataHub の SPEC_03)と同じ. + +```text +~/data/tiasdata/<データセット名>/v<版>/ +├── dataset.json +├── manifest.csv # 学習が読む唯一の入口(患者・ファイルの情報を含むので回収しない) +├── SHA256SUMS +└── files/. # ファイル名は内容のハッシュ +``` + +本リポジトリが manifest から読み取れる必要があるもの: + +| 必要な情報 | 用途 | 原本での対応 | +| --- | --- | --- | +| 画像と正解マスクの**組** | 学習・評価の 1 サンプル | `sample/` と `label/` の同名ファイル | +| 用途の区分(学習用/テスト用) | 学習・検証に使うものと,学習後の評価に使うものを分ける | `input/train/` と `input/test_extra/cropped/` | +| 患者の ID(あれば) | 患者単位の分割(任意の機能.SPEC_02「分割」) | 原本には無い(画像単位で分割している) | + +読み込んだ行は次の形(`SegRecord`)に変換して使う. + +| 項目 | 内容 | +| --- | --- | +| `image_path` | 画像ファイルの場所(バンドルの `files/` の中) | +| `mask_path` | 正解マスクのファイルの場所(同上) | +| `subset` | `train`(学習・検証用)または `test`(学習後の評価用) | +| `subject_id` | 患者の ID.無ければ空 | + +- 画像と正解マスクは同じ大きさであること.組が欠けている行・大きさが合わない組があれば学習を始めずに止める(黙って除かない) +- **実験の記録**: バンドルの指紋(`name`・`version`・`manifest_sha256`)を実験の出力に残す.患者 ID・ファイル名を含まないので回収してよい +- バンドルのファイル名は内容のハッシュなので,元の画像のファイル名(患者 ID の可能性)は学習側に現れない.それでも画像ごとの結果は回収しない(「回収ホワイトリスト」) + +### 合成データ (Synthetic Data) + +手元で学習のコードを流すため,`scripts/` のスクリプトで**バンドルと同じ形**の合成データを `data/synthetic/` に作る(単色の背景に楕円を描いた画像と,その楕円のマスク).目的は「落ちずに数エポック回り,指標と ONNX が書き出される」ことの確認で,精度は意味を持たない.実データの誤削除を防ぐため,作り直しは合成データの目印ファイルがある出力先だけに行う. + +## 設定ファイル (Configuration) + +`configs/*.yaml` に学習条件を置き,`schema.py` の pydantic モデルで検証する(未知のキーは拒否).項目の詳細は [SPEC_02](SPEC_02_学習・ONNX書き出し仕様.md)「設定項目」. + +| ファイル | 用途 | +| --- | --- | +| `configs/synthetic.yaml` | 手元の合成データで流すための設定(エポック数を小さくする) | +| `configs/resunet.yaml` | サーバの実データで ResUNet を学習する設定(原本と同じ学習条件) | +| `configs/remote.yaml` | リモート実行ツールのサーバ設定([SPEC_03](SPEC_03_リモート実行仕様.md)) | + +## 実験の出力 (Run Artifacts) + +```text +runs/<実験ID>/ +├── config.yaml # 解決済みの設定 + git コミットハッシュ + seed + バンドルの指紋 +├── history.csv # エポックごとの学習損失・検証損失 +├── metrics.json # 最良エポック・最良の検証損失・テスト用データでの IoU の集計値(平均・中央値・最小等)+ バンドルの指紋 +├── log.txt +├── figures/ # 図専用(学習曲線).舌画像・マスク・予測の画像は書き込まない +│ └── loss.png +├── split.json # 分割結果(どのファイルが学習・検証に入ったか.回収しない) +├── predictions.csv # テスト用データの画像ごとの IoU(回収しない) +└── checkpoints/ + ├── best.pth # 検証損失が最良のエポックの重み + └── ResUNet.onnx # ONNX の書き出しを実行したとき +``` + +実験 ID の書式: `YYYYmmdd-HHMMSS_<設定ファイル名>_` + +- サーバには `.git` を送らないため,git のハッシュは手元で求めてリモート実行ツールが環境変数で渡す([SPEC_03](SPEC_03_リモート実行仕様.md)).未コミットの変更があるときは末尾に `-dirty` が付く.環境変数が無い場合(手元での直接実行等)は `nogit` とする +- 原本は最良を更新するたびに `epoch.pth` を残していたが,新しいコードは `best.pth` を上書きする(サーバのディスクを使い過ぎないため) +- **`figures/` には図だけを置き,舌画像・マスク・予測結果の画像を書き込まない**.回収ホワイトリストが `figures/*.png` を回収対象にしているため +- 画像ごとの結果(`predictions.csv`)・分割結果(`split.json`)は回収対象外の名前で保存する + +## 回収ホワイトリスト (Pull Whitelist) + +手元へ回収できるのは以下の**名前が一致するファイルのみ**.列挙外のファイルは回収しない(拡張子や中身での判断はしない).リモート実行ツール([SPEC_03](SPEC_03_リモート実行仕様.md))がこの制約を実装する. + +| 回収する(`runs/<実験ID>/` 配下) | 回収しない | +| --- | --- | +| `config.yaml`・`history.csv`・`metrics.json`・`log.txt` | 上記以外のすべて(`split.json`・`predictions.csv`・画像・manifest 等) | +| `figures/*.png` | `figures/` 以外にある `*.png` | +| `checkpoints/best.pth`・`checkpoints/ResUNet.onnx`(**明示的に指定したときのみ**) | 指定が無いときの `checkpoints/` | + +- データディレクトリ(`~/data/tiasdata/`)からは何も回収しない +- 画像ごとの結果が必要な分析はサーバ上で行い,集計結果だけを上記の名前で書き出して持ち帰る +- 回収した重みは手元の `runs/` に置かれる(`.gitignore` 済み.重みの拡張子はリポジトリ全体でも除外している) + +## CLI (Entry Points) + +| コマンド(仮) | 役割 | 実行場所 | +| --- | --- | --- | +| `tsm-train --config PATH` | 設定に従って学習し,学習後にテスト用データで IoU を集計して `runs/<実験ID>/` に書き出す.最後に実験 ID を出力する | サーバ(GPU).合成データなら手元 | +| `tsm-export --run <実験ID>` | その実験の `best.pth` から ONNX を書き出し,onnxruntime で入出力の形と PyTorch の出力との一致を確かめる | サーバ.合成データなら手元 | +| `tsm-remote ` | コード送信・ジョブ実行・結果回収・GPU の空き確認([SPEC_03](SPEC_03_リモート実行仕様.md)) | 手元 | +| `uv run python scripts/make_synthetic_bundle.py` | 合成データ(バンドルの形)を `data/synthetic/` に作る | 手元 | + +コマンド名は実装時に確定し,[ENV_04 開発コマンド](../02_ENV/ENV_04_開発コマンド.md)に記載する.学習したモデルの DeepTIAS 2.7 の手順での評価は,TIASJudgeModel の `tias-seg eval` に書き出した ONNX を渡して行う(本リポジトリでは作らない). diff --git "a/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273ONNX\346\233\270\343\201\215\345\207\272\343\201\227\344\273\225\346\247\230.md" "b/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273ONNX\346\233\270\343\201\215\345\207\272\343\201\227\344\273\225\346\247\230.md" new file mode 100644 index 0000000..0c8a407 --- /dev/null +++ "b/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273ONNX\346\233\270\343\201\215\345\207\272\343\201\227\344\273\225\346\247\230.md" @@ -0,0 +1,139 @@ +# 学習・ONNX 書き出し仕様 (Training & ONNX Export) + +ResUNet の学習と ONNX の書き出しの仕様.**原本(`legacy/source/`)の手順をそのまま再現する**ことを既定とし,原本から変える点は理由と一緒に明記する.データの形・出力先は [SPEC_01](SPEC_01_アーキテクチャ設計.md). + +## 再現の前提 (Assumptions) + +- 配布している `ResUNet.onnx` は,`legacy/source/pytorchToOnnx.py` が `ResNetUNet(n_class=2)` の重みから書き出したものである +- その重みを学習したときの条件はコードから確定できない(今の `legacy/source/main.py` は `UNet_Pruning` を学習する設定になっている).**モデルだけを `ResNetUNet` に替え,他は今の `main.py` と同じ条件だった**と仮定する +- ライブラリの版が違うため,数値が完全に一致する再現は狙わない.同じ手順で同程度の精度(テスト用データでの IoU と,`tias-seg eval` の結果)が出ることを確かめる + +## 原本との対応 (Mapping to the Original) + +| 処理 | 原本(`legacy/source/`) | 新しいコード | 原本との違い | +| --- | --- | --- | --- | +| モデル | `models.py` の `ResNetUNet` | `models/` | 事前学習の重みの指定を今の torchvision の書き方にする(`pretrained=True` → `weights=ResNet18_Weights.IMAGENET1K_V1`.同じ重み) | +| 損失 | `losses.py` の `DiceCE`・`dice_loss` | `training/` | 既定は原本どおり.直した版を設定で選べる(「損失」) | +| データの読み込み | `main.py` の `TongueSegDataset` | `data/` | フォルダではなくバンドルから読む.大きさの確認を足す | +| データ拡張 | `main.py` | `data/` | 同じ | +| 分割 | `main.py`(`random_split`) | `data/` | 同じ(画像単位).患者単位を設定で選べる | +| 学習ループ | `main.py` | `training/` | 同じ.重みは最良の 1 本だけ残す | +| 学習後の評価 | `main.py` の後半 | `training/` | IoU の計算は同じ.集計値だけを回収対象にする | +| 乱数の固定 | `utils.py` の `fix_rand` | `training/` | 同じ | +| ONNX の書き出し | `pytorchToOnnx.py` | `export/` | 書き出した後の確認を足す | +| 小領域除去 | `utils.py` の `RemoveSmallRegion` | 移さない | 原本でも学習・評価から呼ばれていない.DeepTIAS の後処理は TIASJudgeModel にある | + +## モデル (Model) + +原本の `ResNetUNet(n_class=2)` と同じ構造にする. + +- 土台は torchvision の resnet18(ImageNet の事前学習の重み).エンコーダの 5 段の出力をそれぞれ 1×1 の畳み込みに通し,デコーダで順に拡大(2 倍・双線形・`align_corners=True`)しながら連結する.元の解像度の枝(3×3 の畳み込み 2 つ)を最後に連結する +- 入力 `(N, 3, H, W)`,出力 `(N, 2, H, W)`(活性化関数を掛ける前の値).**チャンネル 0 が舌,チャンネル 1 が舌以外** +- 層の名前(`state_dict` のキー)を原本と同じにする.原本の `bestModel.pth` を新しいコードで読み込めるようにするため(`legacy/result/` にある重みを使った確認ができる) +- 事前学習の重みはサーバで初回にダウンロードされる.ダウンロードできない環境では,設定で重みファイルの場所を渡せるようにする + +## 入力の前処理 (Preprocessing) + +| 対象 | 処理 | +| --- | --- | +| 画像 | `cv2.imread`(カラー)で読んだ **BGR のまま** 255 で割り,`(3, H, W)` の float にする.色の並べ替え・平均と分散での正規化はしない | +| 正解マスク | `cv2.imread`(カラー)で読み,**128 を超える**画素を 1,それ以外を 0 にする.チャンネル 0 を舌,`1 − 舌` を舌以外として `(2, H, W)` にする | + +- BGR のまま学習するのは原本の挙動で,DeepTIAS 2.7 と TIASJudgeModel の前処理もこれに合わせてある.**変えない** +- 原本は画像の大きさを変えていない(学習データが最初から同じ大きさにそろっている前提).新しいコードは,画像とマスクが設定の大きさ(既定 256×256)であることを確かめ,**違うものがあれば学習を始めずに止める**(黙って拡大・縮小しない.実データの大きさは最初の実行で確かめ,必要なら方針を決め直す) + +## データ拡張 (Augmentation) + +学習・検証用のデータに掛ける(原本は分割の前にデータセット全体へ設定しているため,**検証用にも掛かる**.これも原本どおりにする).テスト用データには掛けない. + +| 対象 | 処理 | +| --- | --- | +| 画像だけ | 色のゆらぎ(`ColorJitter`.明るさ・コントラスト・彩度・色相をそれぞれ 0.5) | +| 画像とマスクの両方 | 確率 0.5 で左右反転(同じ判定を両方に適用する) | + +※ `ColorJitter` は入力を RGB の順と見なすが,実際は BGR の順で渡している.色相を大きく振っているので実質的な差は小さいと考えられるが,原本どおりにしておく. + +## 分割 (Split) + +- `subset` が `train` の組を,学習用と検証用に分ける.既定は原本と同じ**画像単位のランダム分割**(学習 2/3・検証 1/3.端数は検証側) +- `subset` が `test` の組は,学習後の評価だけに使う +- 設定で**患者単位の分割**を選べるようにする(同じ患者の画像が学習と検証にまたがらない).バンドルに患者の ID がある場合だけ使える.既定にはしない(原本の再現が先のため) +- 分割結果は `split.json` に保存する(回収しない) + +## 損失 (Loss) + +原本の `DiceCE(bce_weight=0.5)`: `損失 = 0.5 × BCE + 0.5 × Dice` + +- Dice: モデルの出力にシグモイドを掛けた値と正解から,チャンネルごと・画像ごとに `1 − (2 × 積の和 + 1) / (予測の和 + 正解の和 + 1)` を計算して平均する +- BCE: 設定 `loss.bce_input` で切り替える + +| `loss.bce_input` | BCE に渡す値 | 位置づけ | +| --- | --- | --- | +| `sigmoid`(**既定**) | シグモイドを掛けた後の値を,シグモイド込みの BCE(`binary_cross_entropy_with_logits`)に渡す | **原本どおり**.シグモイドが 2 重に掛かる(おそらく意図しない書き方).配布中の `ResUNet.onnx` はこの損失で学習されたと考えられ,DeepTIAS の後処理(シグモイド → 大津の 2 値化)もその出力を前提にしている | +| `logits` | モデルの出力をそのまま同じ BCE に渡す | 直した版.出力の値の分布が変わるので,使うときは `tias-seg eval` で DeepTIAS の後処理との相性を確かめる | + +## 学習 (Training) + +| 項目 | 既定(原本と同じ) | +| --- | --- | +| 最適化 | Adam.学習率 `1e-4`.学習率の調整(スケジューラ)は使わない | +| バッチサイズ | 16(学習・検証とも.どちらも毎エポック並べ替える) | +| エポック数 | 最大 300 | +| 早期終了 | 検証損失が 30 エポック続けて最良を更新しなければ止める | +| 重みの保存 | 検証損失が最良を更新したエポックの重みを `checkpoints/best.pth` に上書きする | +| 乱数の種 | 2021(データの分割の前と,モデルを作る前に固定する) | +| 乱数の固定の範囲 | Python・NumPy・PyTorch(CPU・GPU)の種と,cuDNN の決定的な動作の指定.`torch.use_deterministic_algorithms` は有効にしない(原本と同じ) | + +- エポックごとに学習損失・検証損失を `history.csv` に書き,学習後に学習曲線を `figures/loss.png` に出す +- 原本は検証のときもデータ拡張が掛かり,並べ替えも行う.検証損失はエポックごとに少し揺れる + +## 学習後の評価 (Post-training Evaluation) + +学習が終わったら,最良の重みでテスト用データ(`subset` が `test`)を 1 枚ずつ推論し,原本と同じ手順で IoU を計算する. + +1. 出力のチャンネル 0 にシグモイドを掛け,255 倍して 8 ビットにする +2. 大津の方法で 2 値化する +3. 正解マスクのチャンネル 0 との IoU(`重なり / (予測 ∪ 正解)`)を計算する + +- `metrics.json` には集計値(枚数・平均・中央値・最小・最大・標準偏差)だけを書く.画像ごとの値は `predictions.csv`(回収しない)に書く +- これは学習の成否を見るための簡易な評価である.DeepTIAS 2.7 の手順(枠の切り出し・小領域除去を含む)での評価は TIASJudgeModel の `tias-seg eval` で行う + +## ONNX の書き出し (ONNX Export) + +原本の `pytorchToOnnx.py` と同じ条件で書き出す. + +| 項目 | 内容 | +| --- | --- | +| 入力 | `(1, 3, 256, 256)` の float32(BGR を 255 で割った値).大きさは固定 | +| 出力 | `(1, 2, 256, 256)` の float32(活性化関数を掛ける前の値.チャンネル 0 が舌) | +| モデルの状態 | 推論モード(`eval`) | +| opset | 11(原本と同じ).今の PyTorch で 11 を書き出せない場合は,動く最小の版にして記録する | + +書き出した後に次を確かめ,結果を `metrics.json`(または書き出しの記録)に残す. + +- onnxruntime(CPU)で読み込めること.入出力の形と型が上の表のとおりであること +- 同じ入力に対する PyTorch の出力との差が小さいこと(最大の絶対差を記録する) +- 入出力の名前を記録する.配布中の `ResUNet.onnx`(サーバの `~/models/TongueSegmentation/`)と違っていても,DeepTIAS・推論サーバー・TIASJudgeModel が名前に依存しているかを確かめるまでは合わせ込みをしない(確かめた結果で決める) + +## 設定項目 (Configuration Keys) + +`configs/*.yaml` の項目(名前は実装時に確定する).既定値は上の各節のとおり. + +| 区分 | 項目 | +| --- | --- | +| `data` | バンドルの名前と版,画像の大きさ,分割の方法(`random` / `subject`)と学習用の割合 | +| `augment` | 色のゆらぎの強さ,左右反転の確率 | +| `model` | 事前学習の重みを使うか,重みファイルの場所(任意) | +| `loss` | `bce_weight`,`bce_input`(`sigmoid` / `logits`) | +| `train` | バッチサイズ,学習率,最大エポック数,早期終了の待ち数,乱数の種,データを読む並列数 | +| `export` | opset | +| `run` | 出力先(既定 `runs/`) | + +## 原本の挙動のうち注意が要るもの (Notable Behaviours) + +原本を読んで分かった,直したくなるが**既定では直さない**点.直すときは設定で切り替えられるようにし,結果への影響を記録する. + +- 損失のシグモイドが 2 重(「損失」) +- 検証用データにもデータ拡張が掛かる(「データ拡張」) +- 色のゆらぎが BGR の並びのまま掛かる(「データ拡張」) +- 分割が画像単位で,同じ患者の画像が学習と検証にまたがりうる(「分割」) diff --git "a/docs/04_SPEC/SPEC_03_\343\203\252\343\203\242\343\203\274\343\203\210\345\256\237\350\241\214\344\273\225\346\247\230.md" "b/docs/04_SPEC/SPEC_03_\343\203\252\343\203\242\343\203\274\343\203\210\345\256\237\350\241\214\344\273\225\346\247\230.md" new file mode 100644 index 0000000..7f99c4f --- /dev/null +++ "b/docs/04_SPEC/SPEC_03_\343\203\252\343\203\242\343\203\274\343\203\210\345\256\237\350\241\214\344\273\225\346\247\230.md" @@ -0,0 +1,74 @@ +# リモート実行仕様 (Remote Execution) + +手元からコードを送り,研究室の GPU サーバ(Newton・Archimedes)のうち**空いている GPU を自動で選んで**ジョブを実行し,結果を[回収ホワイトリスト](SPEC_01_アーキテクチャ設計.md)に従って持ち帰るツール(仮の名前 `tsm-remote`)の仕様. + +**TIASJudgeModel の `tias-remote` を移植する**.動作の詳細(GPU の空き判定・選択・各コマンド・誤実行の防止・テスト方針)は TIASJudgeModel の `docs/04_SPEC/SPEC_03_リモート実行仕様.md` と同じとし,本ファイルには前提と,移植で変える点だけを書く.移植の時点で TIASJudgeModel 側の仕様と食い違いが出たら,本ファイルに全文を持つ形に改める. + +## 前提と制約 (Constraints) + +- **学習データを転送しない**.ツールが扱うのはコードの送信と結果の回収のみ.データは各サーバに事前配置する([ENV_03](../02_ENV/ENV_03_管理者用環境構築手順.md)) +- サーバに GitHub の認証情報を置かない(コードは常に手元から送る) +- **非対話で動く**(ssh は `BatchMode=yes`.パスワード入力を求めない) +- 共用サーバのため,他のユーザーが使用中の GPU を勝手に使わない +- **`legacy/` はサーバへ送らない**(約 4 GB の重みと,画像のファイル名を含む結果があるため.新しいコードは `legacy/` に依存しない) + +## 移植で変える点 (Differences from tias-remote) + +| 項目 | TIASJudgeModel | 本リポジトリ | +| --- | --- | --- | +| コマンド名 | `tias-remote` | `tsm-remote`(仮) | +| サーバ上のコード置き場(`remote_dir`) | `~/work/TIASJudgeModel` | `~/work/TongueSegModel` | +| データの置き場 | `~/data/TIASJudgeModel`・バンドル | バンドルだけ(`TIASDATA_BUNDLES`.既定 `~/data/tiasdata`) | +| 環境変数の接頭辞 | `TIAS_REMOTE_*`・`TIAS_GIT_COMMIT` | `TSM_REMOTE_*`・`TSM_GIT_COMMIT`(仮) | +| 送らないもの | `.git`・`.venv`・`data/`・`runs/` 等 | 左に加えて **`legacy/`** | +| 回収ホワイトリスト | TIASJudgeModel の SPEC_01 | 本リポジトリの [SPEC_01](SPEC_01_アーキテクチャ設計.md)「回収ホワイトリスト」 | +| 重みの回収(明示したときだけ) | `checkpoints/*.pt` | `checkpoints/best.pth`・`checkpoints/ResUNet.onnx` | + +## サーバ設定 (Server Configuration) + +`configs/remote.yaml` に置き,pydantic で検証する(未知のキーは拒否).形は TIASJudgeModel と同じ. + +```yaml +jump_host: labpc # 踏み台.null なら直接接続 +connect_timeout_sec: 15 +gpu_free: + max_memory_used_mib: 1024 # 使用中メモリがこれ未満 + max_utilization_percent: 10 # かつ使用率がこれ未満なら「空き」 + observe_sec: 10 # この秒数だけ観測してから判定する(0 なら瞬間値のみ) + sample_interval_ms: 500 # 観測の間隔 +servers: + - name: Newton + address: 192.168.23.14 + user: hasegawa + priority: 1 # 小さいほど優先 + remote_dir: ~/work/TongueSegModel + uv: ~/.local/bin/uv + data_ready: false # 学習データのバンドルが配置済みか + - name: Archimedes + address: 192.168.23.15 + user: hasegawa + priority: 2 + remote_dir: ~/work/TongueSegModel + uv: ~/.local/bin/uv + data_ready: false +``` + +`data_ready` は,TIASDataHub のバンドルがそのサーバに配置されるまで `false` とする.`false` のサーバでは実データを使うジョブを起動しない(合成データのジョブや GPU の確認は実行できる). + +## コマンド (Commands) + +TIASJudgeModel と同じ構成にする. + +| コマンド | 役割 | +| --- | --- | +| `gpus` | 各サーバの GPU の空き状況を表示する | +| `push` | コードをサーバへ送る(tar over ssh) | +| `run --name <ジョブ名> -- <コマンド>` | 空いている GPU を選び,コードを送ってから tmux の中で `uv run <コマンド>` を起動する.git のハッシュを環境変数で渡す | +| `logs <ジョブ名>` | ジョブのログを表示する | +| `pull <実験ID>` | 回収ホワイトリストに一致するファイルだけを手元の `runs/` に持ち帰る.重みは `--checkpoints` を付けたときだけ | + +## テスト方針 (Testing) + +- ssh を実際には呼ばず,コマンドの組み立て・GPU の判定・ホワイトリストの判定を単体テストで確かめる(TIASJudgeModel と同じ) +- 回収ホワイトリストは,回収してはならない名前(`predictions.csv`・`split.json`・`figures/` 以外の画像・指定の無い重み)が弾かれることをテストで固定する +- 実サーバでの動作確認(接続・送信・起動・回収)は Claude が実行し,使った GPU と回収されたファイルの一覧を報告する(2026-11-18 のユーザー判断) diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 68e9e62..d44a067 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -9,3 +9,21 @@ - 書式・運用ルールは .claude/rules/progress-log.md を参照 (本ファイルの編集時に自動ロードされる) --> + +- [x] **立ち上げフェーズ 1(方針決定)**: 要件定義書を作成.スコープは原本の取り込み → 計算サーバでの再現 → TIASDataHub 連携 → コード整理の段階式とした.原本のフォルダ全体(約 4GB)は `legacy/` にコピーし(全ファイルのハッシュ一致を確認),Git にはコードと hparams だけを入れる + - 原本の調査: yaml 43 個は設定ではなく `Pix2Pix.py` の lightning_logs の hparams.同梱の smp 0.2.1 は公式との差分が未使用の 2 か所だけで pip に置き換え可能 +- [x] **立ち上げフェーズ 2(技術選定)**: 土台を TIASJudgeModel とそろえた(Python 3.12・uv・PyTorch 2.x の cu126・YAML+pydantic・pytest・ruff・tias-remote の移植) + - 2021 年当時の版は再現せず今の PyTorch で書き直す(当時の版の記録が無く完全一致を保証できないため).新しいコードに移すのは ResUNet だけで,smp・Lightning・scipy・scikit-image は入れない +- [x] **立ち上げフェーズ 3(環境構築)**: uv のプロジェクトを作り(`src/tongue_seg_model/`・TIASDataHub のサブモジュール・dependabot.yml),手元で `uv sync`・pytest・ruff が通ることを確かめて手順書(ENV_02〜04)に反映 + - GitHub リポジトリ(private)の作成と Dependabot のセキュリティ設定は 2026-11-18 に実施.未実施: サーバ側の初期設定(リモート実行ツールの移植後) +- [x] **立ち上げフェーズ 4(仕様設計)**: SPEC_01〜03 を作成.原本の学習手順をそのまま再現するのを既定とし,原本から変える点を対応表にした + - 損失のシグモイドが 2 重になっている原本の書き方は既定で残す(配布中の ONNX と DeepTIAS の後処理がその出力を前提にしているため).直した版は設定で選ぶ + - 学習データの入口は TIASDataHub のバンドルだけにする(フォルダ直読みは作らない).TIASDataHub がセグメンテーション用データに未対応のため,実データでの学習はその対応待ちになる +- [x] **立ち上げフェーズ 5(規約整備)**: coding-style・project-structure・testing・error-handling を TIASJudgeModel の規約を土台に作成し,原本フォルダ用の legacy を追加 + - legacy の rule を別に作った理由: `legacy/` を触るときにだけ読まれる場所に「書き換えない・`result/` を読まない・Git に入れる範囲を広げない」を置くため +- [x] **立ち上げフェーズ 6(開発計画)**: 開発ステップを 3 つのマイルストーンに分けた(合成データで一通り動かす → 実データで学習を再現 → 整理) + - 実データの学習は TIASDataHub のセグメンテーション用データへの対応(別リポジトリ)待ちになるため,先に合成データで実装を済ませる.モデルの移植の正しさは,原本の重みを読み込んで配布中の ONNX と出力を比べて確かめる(学習のやり直しが要らない) + - ユーザー判断(2026-11-18): マイルストーン 2 の着手は Claude がステップ 1-4 の後に提案する.原本の重みでの確認(1-7)と実サーバの確認(1-8)は Claude が単独で実行する.そのため legacy の rule に「比較に使う重み(pth・onnx)は読み込んでよい」の例外を足した +- [x] **立ち上げフェーズ 7(実装開始)**: CLAUDE.md を立ち上げ完了の状態に更新(概要に技術スタック・構成・実行環境の要約を追加).Dependabot のセキュリティ設定が有効なことを再確認 + - 次: PLAN_02 のステップ 1-1(設定と実験の出力).ステップ 1-4 が済んだら TIASDataHub 側の作業(2-1)の着手を提案する + - `legacy/` の重み・結果のバックアップは研究室の共有フォルダにある(ユーザーが確認).`legacy/result/` は当面 Git に入れない(ユーザー判断).人間の確認待ち: 原本のコードの作者とライセンス(ENV_03「人間が確認すべき事項」) diff --git a/external/TIASDataHub b/external/TIASDataHub new file mode 160000 index 0000000..b363079 --- /dev/null +++ b/external/TIASDataHub @@ -0,0 +1 @@ +Subproject commit b3630797d5b07ab009ba2933d618257bed9507e9 diff --git a/legacy/source/MTL.py b/legacy/source/MTL.py new file mode 100644 index 0000000..505fe20 --- /dev/null +++ b/legacy/source/MTL.py @@ -0,0 +1,359 @@ +import copy +import datetime +import glob +import os +import time +import cv2 +import matplotlib.pyplot as plt +import torchvision.transforms.functional as TF +import torch +import numpy as np +import pandas as pd +from sklearn.metrics import confusion_matrix +from torch.optim import lr_scheduler +from torch.utils.data import DataLoader +from torchvision import transforms +from tqdm.notebook import tqdm +from source.losses import * +from source.utils import * +from source.models import TwoTaskUNet, TwoTaskResUNet + +class TongueSegAndReconDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label_seg = [] + for path_sample in self.paths_sample: + self.paths_label_seg.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Segmentation label + path_label_seg = self.paths_label_seg[index] + label_seg = torch.from_numpy(cv2.imread(path_label_seg, cv2.IMREAD_COLOR)) + label_seg[label_seg <= 128] = 0.0 + label_seg[label_seg > 128] = 1.0 + label_seg = label_seg.permute(2, 0, 1).float() + if self.transform_label: + label_seg = self.transform_label(label_seg) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label_seg = tf(label_seg) + + label_pos = label_seg[0, :, :] + label_neg = torch.ones(label_pos.shape) - label_seg[0, :, :] + label_pos = label_pos.unsqueeze(0) + label_neg = label_neg.unsqueeze(0) + label_seg = torch.cat([label_pos, label_neg], axis=0) + + # Reconstruction label + label_recon = torch.clone(sample) + + return sample, label_seg, label_recon + + def __len__(self): + return len(self.paths_sample) + +def train(): + # Configs + path_outputDir = os.path.join("..\output", datetime.datetime.now().strftime('%m%d-%H%M%S')) + os.makedirs(path_outputDir) + + # load data train + path_trainSample = os.path.join("..\input", "train", "sample") + path_trainLabel = os.path.join("..\input", "train", "label") + path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") + path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + + # Params + fix_rand(2021) + batch_size = 16 + train_ratio = 2 / 3 + transform_sample = transforms.Compose([transforms.ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)]) + transform_label = transforms.Compose([]) + transform_both = [(TF.hflip, 0.5)] + dataset = TongueSegAndReconDataset(path_trainSample, path_trainLabel, transform_sample=transform_sample, + transform_label=transform_label, transform_both=transform_both) + + train_dataset, val_dataset = torch.utils.data.random_split(dataset, + [int(len(dataset) * train_ratio), len(dataset) - int(len(dataset) * train_ratio)]) + data_loader_train = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=0) + data_loader_val = DataLoader(val_dataset, batch_size=batch_size, shuffle=True, num_workers=0) + print("train:", len(train_dataset), " validation:", len(val_dataset)) + + # show + for epoch in range(0, 1): + for inputs, labels_seg, labels_recon in data_loader_train: + input = inputs[0, :, :, :] + label_seg = labels_seg[0, :, :, :] + label_recon = labels_recon[0, :, :, :] + img_input = np.array(input.permute(1, 2, 0)) + plt.imshow(img_input) + plt.show() + img_label_seg = np.array(label_seg[0]) / 255.0 + plt.imshow(img_label_seg) + plt.show() + img_label_recon = np.array(label_recon.permute(1, 2, 0)) + plt.imshow(img_label_recon) + plt.show() + break + + device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') + learning_rate = 1e-4 + num_epochs = 500 + num_epochsEarlyStop = 30 + + seg_weight = 0.5 + criterion1 = DiceCE(bce_weight=0.5) + criterion2 = nn.MSELoss() + + # create model + fix_rand(2021) + model = TwoTaskResUNet(n_class=2) + model = model.to(device) + optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate) + # scheduler = lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.1) # is not used + # パラメータカウント + params = 0 + for p in model.parameters(): + if p.requires_grad: + params += p.numel() + print("params: ", params) + + since = time.time() + best_model_wts = copy.deepcopy(model.state_dict()) + best_model_epochs = 0 + best_loss = 1e5 + losses_train = [] + losses_val = [] + for epoch in tqdm(range(num_epochs)): + print('Epoch {}/{}'.format(epoch + 1, num_epochs)) + print('-' * 10) + + # Each epoch has a training and validation phase + for phase in ['train', 'val']: + + if phase == 'train': + model.train() # Set model to training mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels_seg, labels_recon in data_loader_train: + inputs = inputs.to(device) + labels_seg = labels_seg.to(device) + labels_recon = labels_recon.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss1 = criterion1(outputs[0], labels_seg) + loss2 = criterion2(outputs[1], labels_recon) + loss = (seg_weight * loss1) + ((1.0 - seg_weight) * loss2) + + loss.backward() + optimizer.step() + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_train) + losses_train.append(epoch_loss) + + else: + model.eval() # Set model to evaluate mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels_seg, labels_recon in data_loader_val: + inputs = inputs.to(device) + labels_seg = labels_seg.to(device) + labels_recon = labels_recon.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss1 = criterion1(outputs[0], labels_seg) + loss2 = criterion2(outputs[1], labels_recon) + loss = (seg_weight * loss1) + ((1.0 - seg_weight) * loss2) + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_val) + losses_val.append(epoch_loss) + # scheduler.step() + + print('{} Loss: {:.4f}'.format(phase, epoch_loss)) + + # Todo: early stopping, and metrics + # deep copy the model + if phase == 'val' and epoch_loss < best_loss: + best_loss = epoch_loss + best_model_wts = copy.deepcopy(model.state_dict()) + # torch.save(model.state_dict(), path_outputDir + r"/epoch" + str(epoch) + ".pth") + best_model_epochs = epoch + print("best model saved") + + if (epoch - best_model_epochs) >= num_epochsEarlyStop: + break + + time_elapsed = time.time() - since + print('Training complete in {:.0f}m {:.0f}s'.format( + time_elapsed // 60, time_elapsed % 60)) + print('Best val Loss: {:4f}'.format(best_loss)) + + # load best model weights + model.load_state_dict(best_model_wts) + torch.save(model.state_dict(), path_outputDir + r"/bestModel.pth") + + # lossの可視化 + plt.plot(losses_train, label='training loss') + plt.plot(losses_val, label='validation loss') + plt.ylabel("loss") + plt.xlabel("epoch time") + # plt.ylim(0, 0.35) + plt.savefig(path_outputDir + "/loss.png") + plt.legend() + plt.show() + + # Evaluation + dataset_test = TongueSegAndReconDataset(path_testSample, path_testLabel) + data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + + model.eval() + shouldShow = True + ious = [] + for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels_seg = data[1] + labels_recon = data[2] + outputs_seg, outputs_recon = model(inputs) + + input = inputs[0].permute(1, 2, 0).cpu().detach().numpy() + label_seg = labels_seg[0].permute(1, 2, 0).detach().numpy() + label_recon = labels_recon[0].permute(1, 2, 0).detach().numpy() + output_seg = outputs_seg[0].sigmoid().permute(1, 2, 0).cpu().detach().numpy() + output_recon = outputs_recon[0].permute(1, 2, 0).cpu().detach().numpy() + if shouldShow and i == 0: + plt.imshow(input) + plt.title("input") + plt.show() + + plt.imshow(label_seg[:, :, 0]) + plt.title("segmentation label") + plt.show() + plt.imshow(output_seg[:, :, 0]) + plt.title("segmentation output") + plt.show() + + plt.imshow(label_recon) + plt.title("reconstruction label") + plt.show() + plt.imshow(output_recon) + plt.title("reconstruction label") + plt.show() + break + +def evaluate(): + fix_rand(2021) + + # load data train + path_model = r"D:\Noguchi\Solution\TongueSegmentation\result\CompareModels\TwoTaskUNet\bestModel.pth" + path_outputDir = os.path.dirname(path_model) + path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") + path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + + # Evaluation + dataset_test = TongueSegAndReconDataset(path_testSample, path_testLabel) + data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + + device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') + model = TwoTaskUNet(n_class=2) + model.load_state_dict(torch.load(path_model)) + model = model.to(device) + model.eval() + + shouldShow = True + df = pd.DataFrame() + for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels_seg = data[1] + labels_recon = data[2] + outputs_seg, outputs_recon = model(inputs) + + input = inputs[0].permute(1, 2, 0).cpu().detach().numpy() + label_seg = labels_seg[0].permute(1, 2, 0).detach().numpy()[:, :, 0] + label_recon = labels_recon[0].permute(1, 2, 0).detach().numpy() + output_seg = outputs_seg[0].sigmoid().permute(1, 2, 0).cpu().detach().numpy()[:, :, 0] + output_recon = outputs_recon[0].permute(1, 2, 0).cpu().detach().numpy() + + img_pred = (output_seg * 255).astype(np.uint8) + ret, img_pred = cv2.threshold(img_pred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + + # スコア計算 + y_pred = (img_pred / 255).flatten() + y_true = label_seg.flatten() + tn, fp, fn, tp = confusion_matrix(y_pred, y_true).ravel() + iou_tp = tp / (tp + fp + fn) + r = pd.DataFrame([name, tn, fp, fn, tp, iou_tp]).T + df = pd.concat([df, r], axis=0) + + if shouldShow and i == 153: + plt.imshow(input) + plt.title("input") + plt.show() + + plt.imshow(label_seg) + plt.title("segmentation label") + plt.show() + plt.imshow(output_seg) + plt.title("segmentation output") + plt.show() + + plt.imshow(label_recon) + plt.title("reconstruction label") + plt.show() + + plt.imshow(output_recon) + plt.title("reconstruction output") + plt.show() + + df.columns = ["name", "tn", "fp", "fn", "tp", "iou_tp"] + mean = pd.DataFrame(df.mean(axis=0)).T + df = pd.concat([df, mean]) + + df.to_csv(path_outputDir + r'/Log_detail.csv', index=False) + + print("全体平均:", df["iou_tp"].to_numpy()[-1]) +if __name__ == '__main__': + # train() + evaluate() + diff --git a/legacy/source/Pix2Pix.py b/legacy/source/Pix2Pix.py new file mode 100644 index 0000000..bcc1c9a --- /dev/null +++ b/legacy/source/Pix2Pix.py @@ -0,0 +1,353 @@ +import copy +import datetime +import glob +import os +import time +import cv2 +import matplotlib.pyplot as plt +import torchvision.transforms.functional as TF +import torch +import numpy as np +from sklearn.metrics import confusion_matrix +from torch.optim import lr_scheduler +from torch.utils.data import DataLoader +from torchvision import transforms +from tqdm.notebook import tqdm +from source.losses import * +from source.models import * +from source.utils import * +import pytorch_lightning as pl +from pytorch_lightning.callbacks.early_stopping import EarlyStopping +from pytorch_lightning.callbacks.model_checkpoint import ModelCheckpoint +from source.losses import * +import pandas as pd + +class DownSampleConv(nn.Module): + + def __init__(self, in_channels, out_channels, kernel=4, strides=2, padding=1, activation=True, batchnorm=True): + """ + Paper details: + - C64-C128-C256-C512-C512-C512-C512-C512 + - All convolutions are 4×4 spatial filters applied with stride 2 + - Convolutions in the encoder downsample by a factor of 2 + """ + super().__init__() + self.activation = activation + self.batchnorm = batchnorm + + self.conv = nn.Conv2d(in_channels, out_channels, kernel, strides, padding) + + if batchnorm: + self.bn = nn.BatchNorm2d(out_channels) + + if activation: + self.act = nn.LeakyReLU(0.2) + + def forward(self, x): + x = self.conv(x) + if self.batchnorm: + x = self.bn(x) + if self.activation: + x = self.act(x) + return x + +class PatchGAN(nn.Module): + + def __init__(self, input_channels): + super().__init__() + self.d1 = DownSampleConv(input_channels, 64, batchnorm=False) + self.d2 = DownSampleConv(64, 128) + self.d3 = DownSampleConv(128, 256) + self.d4 = DownSampleConv(256, 512) + self.final = nn.Conv2d(512, 1, kernel_size=1) + + def forward(self, x, y): + x = torch.cat([x, y], axis=1) + x0 = self.d1(x) + x1 = self.d2(x0) + x2 = self.d3(x1) + x3 = self.d4(x2) + xn = self.final(x3) + return xn + + +# collapse-hide +# https://stackoverflow.com/questions/49433936/how-to-initialize-weights-in-pytorch + +def _weights_init(m): + if isinstance(m, (nn.Conv2d, nn.ConvTranspose2d)): + torch.nn.init.normal_(m.weight, 0.0, 0.02) + if isinstance(m, nn.BatchNorm2d): + torch.nn.init.normal_(m.weight, 0.0, 0.02) + torch.nn.init.constant_(m.bias, 0) + + +def display_progress(cond, fake, real, figsize=(10, 5)): + cond = cond.detach().cpu().permute(1, 2, 0) + fake = fake.detach().cpu().permute(1, 2, 0) + real = real.detach().cpu().permute(1, 2, 0) + + fig, ax = plt.subplots(1, 3, figsize=figsize) + ax[0].imshow(cond) + ax[1].imshow(real) + ax[2].imshow(fake.sigmoid()) + plt.show() + + +class Pix2Pix(pl.LightningModule): + + def __init__(self, in_channels, out_channels, learning_rate=0.0002, lambda_recon=200, display_step=25, pruning=False): + + super().__init__() + self.save_hyperparameters() + + self.display_step = display_step + if pruning: + self.gen = UNet_Pruning(n_class=out_channels) + else: + self.gen = UNet(n_class=out_channels) + + self.patch_gan = PatchGAN(in_channels + out_channels) + + # intializing weights + self.gen = self.gen.apply(_weights_init) + self.patch_gan = self.patch_gan.apply(_weights_init) + + # self.adversarial_criterion = nn.BCEWithLogitsLoss() + self.adversarial_criterion = DiceCE(bce_weight=0.5) + self.recon_criterion = nn.L1Loss() + + def _gen_step(self, real_images, conditioned_images): + # Pix2Pix has adversarial and a reconstruction loss + # First calculate the adversarial loss + fake_images = self.gen(conditioned_images) + disc_logits = self.patch_gan(fake_images, conditioned_images) + adversarial_loss = self.adversarial_criterion(disc_logits, torch.ones_like(disc_logits)) + + # calculate reconstruction loss + recon_loss = self.recon_criterion(fake_images, real_images) + lambda_recon = self.hparams.lambda_recon + + return adversarial_loss + lambda_recon * recon_loss + + def _disc_step(self, real_images, conditioned_images): + fake_images = self.gen(conditioned_images).detach() + fake_logits = self.patch_gan(fake_images, conditioned_images) + + real_logits = self.patch_gan(real_images, conditioned_images) + + fake_loss = self.adversarial_criterion(fake_logits, torch.zeros_like(fake_logits)) + real_loss = self.adversarial_criterion(real_logits, torch.ones_like(real_logits)) + return (real_loss + fake_loss) / 2 + + def configure_optimizers(self): + lr = self.hparams.learning_rate + gen_opt = torch.optim.Adam(self.gen.parameters(), lr=lr) + disc_opt = torch.optim.Adam(self.patch_gan.parameters(), lr=lr) + return disc_opt, gen_opt + + def training_step(self, batch, batch_idx, optimizer_idx): + condition, real = batch + + loss = None + if optimizer_idx == 0: + loss = self._disc_step(real, condition) + self.log('PatchGAN Loss', loss) + elif optimizer_idx == 1: + loss = self._gen_step(real, condition) + self.log('Generator Loss', loss) + + if self.current_epoch % self.display_step == 0 and batch_idx == 0 and optimizer_idx == 1: + fake = self.gen(condition).detach() + display_progress(condition[0], fake[0], real[0]) + return loss + + +class TongueSegDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label = [] + for path_sample in self.paths_sample: + self.paths_label.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Load label + path_label = self.paths_label[index] + label = torch.from_numpy(cv2.imread(path_label, cv2.IMREAD_COLOR)) + label[label <= 128] = 0.0 + label[label > 128] = 1.0 + label = label.permute(2, 0, 1).float() + if self.transform_label: + label = self.transform_label(label) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label = tf(label) + + # label_pos = label[0, :, :] + # label_neg = torch.ones(label_pos.shape) - label[0, :, :] + # label_pos = label_pos.unsqueeze(0) + # label_neg = label_neg.unsqueeze(0) + # label = torch.cat([label_pos, label_neg], axis=0) + return sample, label + + def __len__(self): + return len(self.paths_sample) + +def train(): + # Configs + path_outputDir = os.path.join("..\output", datetime.datetime.now().strftime('%m%d-%H%M%S')) + os.makedirs(path_outputDir) + + # load data train + path_trainSample = os.path.join("..\input", "train", "sample") + path_trainLabel = os.path.join("..\input", "train", "label") + path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") + path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + + # Params + fix_rand(2021) + train_ratio = 2 / 3 + num_epochs = 300 + num_epochsEarlyStop = 30 + display_step = 5 + lambda_recon = 100 + batch_size = 16 + lr = 0.0001 + target_size = 256 + transform_sample = transforms.Compose([transforms.ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)]) + transform_label = transforms.Compose([]) + transform_both = [(TF.hflip, 0.5)] + dataset = TongueSegDataset(path_trainSample, path_trainLabel, transform_sample=transform_sample, + transform_label=transform_label, transform_both=transform_both) + + train_dataset, val_dataset = torch.utils.data.random_split(dataset, + [int(len(dataset) * train_ratio), len(dataset) - int(len(dataset) * train_ratio)]) + data_loader_train = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=0) + data_loader_val = DataLoader(val_dataset, batch_size=batch_size, shuffle=True, num_workers=0) + print("train:", len(train_dataset), " validation:", len(val_dataset)) + + pix2pix = Pix2Pix(3, 3, pruning=True, learning_rate=lr, lambda_recon=lambda_recon, display_step=display_step) + early_stop_callback = EarlyStopping(monitor="PatchGAN Loss", patience=num_epochsEarlyStop) + trainer = pl.Trainer(max_epochs=num_epochs, gpus=1, callbacks=[early_stop_callback], log_every_n_steps=16,) + trainer.fit(pix2pix, train_dataloader=data_loader_train, val_dataloaders=data_loader_val) + torch.save(pix2pix.state_dict(), path_outputDir + r"/bestModel.pth") + +def eval(): + fix_rand(2021) + path_outputDir = os.path.join("..\output", datetime.datetime.now().strftime('%m%d-%H%M%S')) + os.makedirs(path_outputDir) + path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") + path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + dataset_test = TongueSegDataset(path_testSample, path_testLabel) + data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') + + path_model = r"D:\Noguchi\Solution\TongueSegmentation\result\CompareModels\Pix2Pix_Pruning\bestModel.pth" + model = Pix2Pix(3, 3, pruning=True) + # パラメータカウント + params = 0 + for p in model.parameters(): + params += p.numel() + print("params: ", params) + model.load_state_dict(torch.load(path_model)) + model = model.gen + model.to(device) + + + + # 推論時間計測 + since = time.perf_counter() + for repeated in range(10): + for i, data in enumerate(data_loader_test, 0): + inputs = data[0].to(device) + labels = data[1].to(device) + outputs = model(inputs).sigmoid() + pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + ret, img_pred = cv2.threshold((pred * 255).astype(np.uint8), 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + time_elapsed = (time.perf_counter() - since) / 10.0 + print("time: ", time_elapsed) + + with open(path_outputDir + r'/test_time¶ms.csv', 'x', encoding='utf-8') as f: + f.write("time," + str(time_elapsed) + "\n") + f.write("params," + str(params) + "\n") + + # Evaluation + shouldSave = True + shouldShow = False + ious = [] + df = pd.DataFrame() + for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels = data[1].to(device) + outputs = model(inputs).sigmoid() + + pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, :] + pred = cv2.cvtColor(pred, cv2.COLOR_BGR2GRAY) + true = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + + img_pred = (pred * 255).astype(np.uint8) + # otsu + ret, img_pred = cv2.threshold(img_pred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + + y_pred = (img_pred / 255).flatten() + y_true = true.flatten() + tn, fp, fn, tp = confusion_matrix(y_pred, y_true).ravel() + + iou_tp = tp / (tp + fp + fn) + + ious.append(iou_tp) + + r = pd.DataFrame([name, tn, fp, fn, tp, iou_tp]).T + df = pd.concat([df, r], axis=0) + + if shouldSave and (i >= 175 or i ==153 or i==150): + num_output = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.axis("off") + plt.imshow(img_pred) + cv2.imwrite(path_outputDir + r"/" + str(i + 1) + ".png", img_pred) + + if os.path.exists(path_outputDir + r'/Log_detail.csv'): + with open(path_outputDir + r'/Log_detail.csv', 'a', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + else: + with open(path_outputDir + r'/Log_detail.csv', 'x', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + + df.columns = ["name", "tn", "fp", "fn", "tp", "iou_tp"] + mean = pd.DataFrame(df.mean(axis=0)).T + df = pd.concat([df, mean]) + df.to_csv(path_outputDir + r'/Log_detail.csv', index=False) + # + print("全体平均:", np.array(ious).mean()) + if os.path.exists(path_outputDir + r'/Log.txt'): + with open(path_outputDir + r'/Log.txt', 'w', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) + else: + with open(path_outputDir + r'/Log.txt', 'x', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) + +# TODO early stoppingした時や,いい感じのlossでモデルを随時保存する +# check point call back で実装できるが,データ構造が嫌いなので,スクラッチで実装したい. +# あと,間違えて出力がカラーになるように構築してしまったが,2 or 1でよい +# train() +eval() diff --git a/legacy/source/evaluation.py b/legacy/source/evaluation.py new file mode 100644 index 0000000..060b66d --- /dev/null +++ b/legacy/source/evaluation.py @@ -0,0 +1,184 @@ +import glob +import time +import cv2 +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np +from sklearn.metrics import confusion_matrix +from torch.utils.data import DataLoader +from tqdm import tqdm +from source.utils import * +from source.models import * +from segmentation_models.segmentation_models_pytorch.pspnet import PSPNet +from segmentation_models.segmentation_models_pytorch.deeplabv3 import DeepLabV3Plus +from segmentation_models.segmentation_models_pytorch.pspnet import PSPNet +from segmentation_models.segmentation_models_pytorch.fpn import FPN + +class TongueSegDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label = [] + for path_sample in self.paths_sample: + self.paths_label.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Load label + path_label = self.paths_label[index] + label = torch.from_numpy(cv2.imread(path_label, cv2.IMREAD_COLOR)) + label[label <= 128] = 0.0 + label[label > 128] = 1.0 + label = label.permute(2, 0, 1).float() + if self.transform_label: + label = self.transform_label(label) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label = tf(label) + + label_pos = label[0, :, :] + label_neg = torch.ones(label_pos.shape) - label[0, :, :] + label_pos = label_pos.unsqueeze(0) + label_neg = label_neg.unsqueeze(0) + label = torch.cat([label_pos, label_neg], axis=0) + return sample, label + + def __len__(self): + return len(self.paths_sample) + +fix_rand(2021) + +# load data train +path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") +path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + +dataset_test = TongueSegDataset(path_testSample, path_testLabel) +data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + +device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') + +# CHANGE THAT +shouldSave = True +model_path = r"D:\Noguchi\Solution\TongueSegmentation\result\CompareModels\FPN\bestModel.pth" +model = FPN(classes=2) + +# outputpath +path_outputDir = os.path.dirname(model_path) + +# model load +model.load_state_dict(torch.load(model_path)) +model = model.to(device) +model.eval() + +# # パラメータカウント +# params = 0 +# for p in model.parameters(): +# params += p.numel() +# print("params: ", params) +# +# # 推論時間計測 +# since = time.perf_counter() +# for repeated in range(10): +# for i, data in enumerate(data_loader_test, 0): +# inputs = data[0].to(device) +# labels = data[1].to(device) +# outputs = model(inputs).sigmoid() +# pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] +# ret, img_pred = cv2.threshold((pred * 255).astype(np.uint8), 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) +# time_elapsed = (time.perf_counter() - since) / 10.0 +# print("time: ", time_elapsed) +# +# with open(path_outputDir + r'/test_time¶ms.csv', 'x', encoding='utf-8') as f: +# f.write("time," + str(time_elapsed) + "\n") +# f.write("params," + str(params) + "\n") + + +shouldShow = True +df = pd.DataFrame() +df_refined = pd.DataFrame() +for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels = data[1].to(device) + outputs = model(inputs).sigmoid() + + pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + true = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + + img_pred = (pred * 255).astype(np.uint8) + # otsu + ret, img_pred = cv2.threshold(img_pred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + + # スコア計算 + y_pred = (img_pred / 255).flatten() + y_true = true.flatten() + tn, fp, fn, tp = confusion_matrix(y_pred, y_true).ravel() + iou_tp = tp / (tp + fp + fn) + r = pd.DataFrame([name, tn, fp, fn, tp, iou_tp]).T + df = pd.concat([df, r], axis=0) + + # ノイズ除去 Remove small regions + img_pred_refined = img_pred.copy() + contours = cv2.findContours(img_pred_refined, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[0] + # 一番面積が大きい輪郭を選択する。 + max_cnt = max(contours, key=lambda x: cv2.contourArea(x)) + # 黒い画像に一番大きい輪郭だけ塗りつぶして描画する。 + img_pred_refined = np.zeros_like(img_pred_refined) + cv2.drawContours(img_pred_refined, [max_cnt], -1, color=255, thickness=-1) + # スコア計算 + y_pred_refined = (img_pred_refined / 255).flatten() + tn, fp, fn, tp = confusion_matrix(y_pred_refined, y_true).ravel() + iou_tp = tp / (tp + fp + fn) + r = pd.DataFrame([name, tn, fp, fn, tp, iou_tp]).T + df_refined = pd.concat([df_refined, r], axis=0) + + if shouldSave and i >= 153: + cv2.imwrite(path_outputDir + r"/" + str(i + 1) + ".png", img_pred) + cv2.imwrite(path_outputDir + r"/" + str(i + 1) + "_refined.png", img_pred_refined) + + if shouldShow and i == 153: + img_input = inputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0] + plt.imshow(img_input) + plt.show() + + img_label = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.imshow(img_label) + plt.show() + + plt.imshow(img_pred) + plt.show() + + plt.imshow(img_pred_refined) + plt.show() + +df.columns = ["name", "tn", "fp", "fn", "tp", "iou_tp"] +mean = pd.DataFrame(df.mean(axis=0)).T +df = pd.concat([df, mean]) +if shouldSave: + df.to_csv(path_outputDir + r'/Log_detail.csv', index=False) + +df_refined.columns = ["name", "tn", "fp", "fn", "tp", "iou_tp"] +mean = pd.DataFrame(df_refined.mean(axis=0)).T +df_refined = pd.concat([df_refined, mean]) +if shouldSave: + df_refined.to_csv(path_outputDir + r'/Log_detail_refined.csv', index=False) + +print("全体平均:", df["iou_tp"].to_numpy()[-1]) +print("全体平均 ノイズ除去後:", df_refined["iou_tp"].to_numpy()[-1]) diff --git a/legacy/source/lightning_logs/version_0/hparams.yaml b/legacy/source/lightning_logs/version_0/hparams.yaml new file mode 100644 index 0000000..9887594 --- /dev/null +++ b/legacy/source/lightning_logs/version_0/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_1/hparams.yaml b/legacy/source/lightning_logs/version_1/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_1/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_10/hparams.yaml b/legacy/source/lightning_logs/version_10/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_10/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_11/hparams.yaml b/legacy/source/lightning_logs/version_11/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_11/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_12/hparams.yaml b/legacy/source/lightning_logs/version_12/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_12/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_13/hparams.yaml b/legacy/source/lightning_logs/version_13/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_13/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_14/hparams.yaml b/legacy/source/lightning_logs/version_14/hparams.yaml new file mode 100644 index 0000000..9887594 --- /dev/null +++ b/legacy/source/lightning_logs/version_14/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_15/hparams.yaml b/legacy/source/lightning_logs/version_15/hparams.yaml new file mode 100644 index 0000000..9887594 --- /dev/null +++ b/legacy/source/lightning_logs/version_15/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_16/hparams.yaml b/legacy/source/lightning_logs/version_16/hparams.yaml new file mode 100644 index 0000000..9887594 --- /dev/null +++ b/legacy/source/lightning_logs/version_16/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_17/hparams.yaml b/legacy/source/lightning_logs/version_17/hparams.yaml new file mode 100644 index 0000000..9887594 --- /dev/null +++ b/legacy/source/lightning_logs/version_17/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_18/hparams.yaml b/legacy/source/lightning_logs/version_18/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_18/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_19/hparams.yaml b/legacy/source/lightning_logs/version_19/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_19/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_2/hparams.yaml b/legacy/source/lightning_logs/version_2/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_2/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_20/hparams.yaml b/legacy/source/lightning_logs/version_20/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_20/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_21/hparams.yaml b/legacy/source/lightning_logs/version_21/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_21/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_22/hparams.yaml b/legacy/source/lightning_logs/version_22/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_22/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_23/hparams.yaml b/legacy/source/lightning_logs/version_23/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_23/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_24/hparams.yaml b/legacy/source/lightning_logs/version_24/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_24/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_25/hparams.yaml b/legacy/source/lightning_logs/version_25/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_25/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_26/hparams.yaml b/legacy/source/lightning_logs/version_26/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_26/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_27/hparams.yaml b/legacy/source/lightning_logs/version_27/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_27/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_28/hparams.yaml b/legacy/source/lightning_logs/version_28/hparams.yaml new file mode 100644 index 0000000..3e96dd0 --- /dev/null +++ b/legacy/source/lightning_logs/version_28/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 1 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_29/hparams.yaml b/legacy/source/lightning_logs/version_29/hparams.yaml new file mode 100644 index 0000000..4350dab --- /dev/null +++ b/legacy/source/lightning_logs/version_29/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 10 +in_channels: 3 +lambda_recon: 10 +learning_rate: 0.001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_3/hparams.yaml b/legacy/source/lightning_logs/version_3/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_3/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_30/hparams.yaml b/legacy/source/lightning_logs/version_30/hparams.yaml new file mode 100644 index 0000000..87b89c7 --- /dev/null +++ b/legacy/source/lightning_logs/version_30/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 1 +learning_rate: 0.01 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_31/hparams.yaml b/legacy/source/lightning_logs/version_31/hparams.yaml new file mode 100644 index 0000000..5cb309a --- /dev/null +++ b/legacy/source/lightning_logs/version_31/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_32/hparams.yaml b/legacy/source/lightning_logs/version_32/hparams.yaml new file mode 100644 index 0000000..f36d312 --- /dev/null +++ b/legacy/source/lightning_logs/version_32/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_33/hparams.yaml b/legacy/source/lightning_logs/version_33/hparams.yaml new file mode 100644 index 0000000..f36d312 --- /dev/null +++ b/legacy/source/lightning_logs/version_33/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_34/hparams.yaml b/legacy/source/lightning_logs/version_34/hparams.yaml new file mode 100644 index 0000000..f36d312 --- /dev/null +++ b/legacy/source/lightning_logs/version_34/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_35/hparams.yaml b/legacy/source/lightning_logs/version_35/hparams.yaml new file mode 100644 index 0000000..f36d312 --- /dev/null +++ b/legacy/source/lightning_logs/version_35/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_36/hparams.yaml b/legacy/source/lightning_logs/version_36/hparams.yaml new file mode 100644 index 0000000..f36d312 --- /dev/null +++ b/legacy/source/lightning_logs/version_36/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 diff --git a/legacy/source/lightning_logs/version_37/hparams.yaml b/legacy/source/lightning_logs/version_37/hparams.yaml new file mode 100644 index 0000000..3897421 --- /dev/null +++ b/legacy/source/lightning_logs/version_37/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: false diff --git a/legacy/source/lightning_logs/version_38/hparams.yaml b/legacy/source/lightning_logs/version_38/hparams.yaml new file mode 100644 index 0000000..3897421 --- /dev/null +++ b/legacy/source/lightning_logs/version_38/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: false diff --git a/legacy/source/lightning_logs/version_39/hparams.yaml b/legacy/source/lightning_logs/version_39/hparams.yaml new file mode 100644 index 0000000..3897421 --- /dev/null +++ b/legacy/source/lightning_logs/version_39/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: false diff --git a/legacy/source/lightning_logs/version_4/hparams.yaml b/legacy/source/lightning_logs/version_4/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_4/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_40/hparams.yaml b/legacy/source/lightning_logs/version_40/hparams.yaml new file mode 100644 index 0000000..b3d1f5b --- /dev/null +++ b/legacy/source/lightning_logs/version_40/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: true diff --git a/legacy/source/lightning_logs/version_41/hparams.yaml b/legacy/source/lightning_logs/version_41/hparams.yaml new file mode 100644 index 0000000..b3d1f5b --- /dev/null +++ b/legacy/source/lightning_logs/version_41/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: true diff --git a/legacy/source/lightning_logs/version_42/hparams.yaml b/legacy/source/lightning_logs/version_42/hparams.yaml new file mode 100644 index 0000000..b3d1f5b --- /dev/null +++ b/legacy/source/lightning_logs/version_42/hparams.yaml @@ -0,0 +1,6 @@ +display_step: 5 +in_channels: 3 +lambda_recon: 100 +learning_rate: 0.0001 +out_channels: 3 +pruning: true diff --git a/legacy/source/lightning_logs/version_5/hparams.yaml b/legacy/source/lightning_logs/version_5/hparams.yaml new file mode 100644 index 0000000..e1eac18 --- /dev/null +++ b/legacy/source/lightning_logs/version_5/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 2 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_6/hparams.yaml b/legacy/source/lightning_logs/version_6/hparams.yaml new file mode 100644 index 0000000..441af43 --- /dev/null +++ b/legacy/source/lightning_logs/version_6/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 1 diff --git a/legacy/source/lightning_logs/version_7/hparams.yaml b/legacy/source/lightning_logs/version_7/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_7/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_8/hparams.yaml b/legacy/source/lightning_logs/version_8/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_8/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/lightning_logs/version_9/hparams.yaml b/legacy/source/lightning_logs/version_9/hparams.yaml new file mode 100644 index 0000000..cb2362a --- /dev/null +++ b/legacy/source/lightning_logs/version_9/hparams.yaml @@ -0,0 +1,5 @@ +display_step: 100 +in_channels: 3 +lambda_recon: 200 +learning_rate: 0.0001 +out_channels: 2 diff --git a/legacy/source/losses.py b/legacy/source/losses.py new file mode 100644 index 0000000..79f5530 --- /dev/null +++ b/legacy/source/losses.py @@ -0,0 +1,158 @@ +from scipy.ndimage.morphology import distance_transform_edt +from skimage import segmentation as skimage_seg +from torch.nn import functional as F +import torch.nn as nn +import torch + +def dice_loss(pred, target, smooth=1.): + pred = pred.contiguous() + target = target.contiguous() + + intersection = (pred * target).sum(dim=2).sum(dim=2) + + loss = (1 - ((2. * intersection + smooth) / (pred.sum(dim=2).sum(dim=2) + target.sum(dim=2).sum(dim=2) + smooth))) + + return loss.mean() + + +class BDLoss(nn.Module): + def __init__(self): + # ref: https://github.com/LIVIAETS/surface-loss/blob/108bd9892adca476e6cdf424124bc6268707498e/losses.py#L74 + super().__init__() + + def forward(self, pred, target): + """ + pred: (batch_size, class, x,y) + target: ground truth, shape: (batch_size, class, x,y) + bound: precomputed distance map, shape (batch_size, class, x,y) + """ + + img_gt_p = target.to(torch.bool)[:, 0, :, :].cpu() + img_gt_n = ~img_gt_p + posdis = distance_transform_edt(img_gt_p) + negdis = distance_transform_edt(img_gt_n) + boundary = skimage_seg.find_boundaries(img_gt_p.numpy(), mode='inner') + sdf = negdis - posdis + sdf[boundary == 1.0] = 0 + + # pred = pred[:, 0, :, :].cpu().detach().numpy() + # pred[pred[:, :, :] < 0.5] = 0.0 + # pred[pred[:, :, :] >= 0.5] = 1.0 + # plt.imshow(pred[0]) + # plt.show() + # plt.imshow(sdf[0]) + # plt.show() + + pc = pred[:, 0, :, :] + dc = torch.tensor(sdf).to(device) + + multipled = torch.einsum("bxy,bxy->bxy", pc, dc) + bd_loss = multipled.mean() + + return bd_loss + + +def dice_loss(pred, target, smooth=1.): + pred = pred.contiguous() + target = target.contiguous() + + intersection = (pred * target).sum(dim=2).sum(dim=2) + + loss = (1 - ((2. * intersection + smooth) / (pred.sum(dim=2).sum(dim=2) + target.sum(dim=2).sum(dim=2) + smooth))) + + return loss.mean() + + +class MyBDLoss(nn.Module): + def __init__(self): + # ref: https://github.com/LIVIAETS/surface-loss/blob/108bd9892adca476e6cdf424124bc6268707498e/losses.py#L74 + super().__init__() + + def forward(self, pred, target): + """ + pred: (batch_size, class, x,y) + target: ground truth, shape: (batch_size, class, x,y) + bound: precomputed distance map, shape (batch_size, class, x,y) + """ + + img_gt_p = target.to(torch.bool)[:, 0, :, :].cpu() + img_gt_n = ~img_gt_p + posdis = distance_transform_edt(img_gt_p) + negdis = distance_transform_edt(img_gt_n) + boundary = skimage_seg.find_boundaries(img_gt_p.numpy(), mode='inner').astype(np.uint8) + sdf = negdis + posdis + sdf[boundary == 1] = 0 + sdf = sdf * sdf + + pred = pred[:, 0, :, :].cpu().detach().numpy() + pred[pred[:, :, :] < 0.5] = 0.0 + pred[pred[:, :, :] >= 0.5] = 1.0 + + boundary_pc = skimage_seg.find_boundaries(pred, mode='inner') * 255.0 + pc = torch.tensor(boundary_pc).to(device) + dc = torch.tensor(sdf).to(device) + + multipled = torch.einsum("bxy,bxy->bxy", pc, dc) + bd_loss = multipled.mean() + + return bd_loss + + +class DiceCE(nn.Module): + def __init__(self, bce_weight=0.5): + super().__init__() + self.bce_weight = bce_weight + # self.bd = DC_and_HD_loss({'batch_dice': False, 'smooth': 1e-5, 'do_bg': False, 'square': False},{}) + + def forward(self, pred, target): + pred = torch.sigmoid(pred) + bce = F.binary_cross_entropy_with_logits(pred, target, reduction='mean') + dice = dice_loss(pred, target) + + loss = (bce * self.bce_weight) + ((1.0 - self.bce_weight) * dice) + return loss + + +class DiceBD(nn.Module): + def __init__(self, BD_weight=0.5): + super().__init__() + self.BD_weight = BD_weight + self.bd = BDLoss() + + def forward(self, pred, target): + pred = torch.sigmoid(pred) + dice = dice_loss(pred, target) + bd = self.bd(pred, target) + + loss = (bd * self.BD_weight) + ((1.0 - self.BD_weight) * dice) + return loss + + +class MyDiceBD(nn.Module): + def __init__(self, BD_weight=0.5): + super().__init__() + self.BD_weight = BD_weight + self.bd = MyBDLoss() + + def forward(self, pred, target): + pred = torch.sigmoid(pred) + dice = dice_loss(pred, target) + bd = self.bd(pred, target) + + loss = (bd * self.BD_weight) + ((1.0 - self.BD_weight) * dice) + return loss + + +class MyCEBD(nn.Module): + def __init__(self, BD_weight=0.5): + super().__init__() + self.BD_weight = BD_weight + self.bd = MyBDLoss() + + def forward(self, pred, target): + pred = torch.sigmoid(pred) + bce = F.binary_cross_entropy_with_logits(pred, target, reduction='mean') + bd = self.bd(pred, target) + + loss = (bd * self.BD_weight) + ((1.0 - self.BD_weight) * bce) + return loss \ No newline at end of file diff --git a/legacy/source/main.py b/legacy/source/main.py new file mode 100644 index 0000000..0dc9656 --- /dev/null +++ b/legacy/source/main.py @@ -0,0 +1,304 @@ +import copy +import datetime +import glob +import os +import time +import cv2 +import matplotlib.pyplot as plt +import torchvision.transforms.functional as TF +import torch +import numpy as np +from sklearn.metrics import confusion_matrix +from torch.optim import lr_scheduler +from torch.utils.data import DataLoader +from torchvision import transforms +from tqdm.notebook import tqdm +from source.losses import * +from source.models import * +from source.utils import * +from segmentation_models.segmentation_models_pytorch.pspnet import PSPNet +from segmentation_models.segmentation_models_pytorch.deeplabv3 import DeepLabV3Plus +from segmentation_models.segmentation_models_pytorch.pspnet import PSPNet +from segmentation_models.segmentation_models_pytorch.fpn import FPN + +class TongueSegDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label = [] + for path_sample in self.paths_sample: + self.paths_label.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Load label + path_label = self.paths_label[index] + label = torch.from_numpy(cv2.imread(path_label, cv2.IMREAD_COLOR)) + label[label <= 128] = 0.0 + label[label > 128] = 1.0 + label = label.permute(2, 0, 1).float() + if self.transform_label: + label = self.transform_label(label) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label = tf(label) + + label_pos = label[0, :, :] + label_neg = torch.ones(label_pos.shape) - label[0, :, :] + label_pos = label_pos.unsqueeze(0) + label_neg = label_neg.unsqueeze(0) + label = torch.cat([label_pos, label_neg], axis=0) + return sample, label + + def __len__(self): + return len(self.paths_sample) + + +# Configs +path_outputDir = os.path.join("..\output", datetime.datetime.now().strftime('%m%d-%H%M%S')) +os.makedirs(path_outputDir) + +# load data train +path_trainSample = os.path.join("..\input", "train", "sample") +path_trainLabel = os.path.join("..\input", "train", "label") +path_testSample = os.path.join("..\input", "test_extra", "cropped", "sample") +path_testLabel = os.path.join("..\input", "test_extra", "cropped", "label") + +# Params +fix_rand(2021) +batch_size = 16 +train_ratio = 2 / 3 +transform_sample = transforms.Compose([transforms.ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)]) +transform_label = transforms.Compose([]) +transform_both = [(TF.hflip, 0.5)] +dataset = TongueSegDataset(path_trainSample, path_trainLabel, transform_sample=transform_sample, + transform_label=transform_label, transform_both=transform_both) + +train_dataset, val_dataset = torch.utils.data.random_split(dataset, + [int(len(dataset) * train_ratio), len(dataset) - int(len(dataset) * train_ratio)]) +data_loader_train = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=0) +data_loader_val = DataLoader(val_dataset, batch_size=batch_size, shuffle=True, num_workers=0) +print("train:", len(train_dataset), " validation:", len(val_dataset)) + +# show +for epoch in range(0, 1): + for inputs, labels in data_loader_train: + input = inputs[0, :, :, :] + label = labels[0, :, :, :] + img_input = np.array(input.permute(1, 2, 0)) + plt.imshow(img_input) + plt.show() + img_label = np.array(label[0]) / 255.0 + plt.imshow(img_label) + plt.show() + break + +device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +learning_rate = 1e-4 +num_epochs = 300 +num_epochsEarlyStop = 30 +criterion = DiceCE(bce_weight=0.5) + +# create model +fix_rand(2021) +model = UNet_Pruning(n_class=2) +model = model.to(device) +optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate) +# scheduler = lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.1) # is not used +# パラメータカウント +params = 0 +for p in model.parameters(): + if p.requires_grad: + params += p.numel() +print("params: ", params) + +since = time.time() +best_model_wts = copy.deepcopy(model.state_dict()) +best_model_epochs = 0 +best_loss = 1e5 +losses_train = [] +losses_val = [] +for epoch in tqdm(range(num_epochs)): + print('Epoch {}/{}'.format(epoch + 1, num_epochs)) + print('-' * 10) + + # Each epoch has a training and validation phase + for phase in ['train', 'val']: + + if phase == 'train': + model.train() # Set model to training mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels in data_loader_train: + inputs = inputs.to(device) + labels = labels.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss = criterion(outputs, labels) + + loss.backward() + optimizer.step() + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_train) + losses_train.append(epoch_loss) + + else: + model.eval() # Set model to evaluate mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels in data_loader_val: + inputs = inputs.to(device) + labels = labels.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss = criterion(outputs, labels) + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_val) + losses_val.append(epoch_loss) + # scheduler.step() + + print('{} Loss: {:.4f}'.format(phase, epoch_loss)) + + # Todo: early stopping, and metrics + # deep copy the model + if phase == 'val' and epoch_loss < best_loss: + best_loss = epoch_loss + best_model_wts = copy.deepcopy(model.state_dict()) + torch.save(model.state_dict(), path_outputDir + r"/epoch" + str(epoch) + ".pth") + best_model_epochs = epoch + print("best model saved") + + if (epoch - best_model_epochs) >= num_epochsEarlyStop: + break + +time_elapsed = time.time() - since +print('Training complete in {:.0f}m {:.0f}s'.format( + time_elapsed // 60, time_elapsed % 60)) +print('Best val Loss: {:4f}'.format(best_loss)) + +# load best model weights +model.load_state_dict(best_model_wts) +torch.save(model.state_dict(), path_outputDir + r"/bestModel.pth") + +# lossの可視化 +plt.plot(losses_train, label='training loss') +plt.plot(losses_val, label='validation loss') +plt.ylabel("loss") +plt.xlabel("epoch time") +# plt.ylim(0, 0.35) +plt.savefig(path_outputDir + "/loss.png") +plt.legend() +plt.show() + +# Evaluation +dataset_test = TongueSegDataset(path_testSample, path_testLabel) +data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + +# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +# model = ResNetUNet(n_class=2) +# model = model.to(device) +# model_path = r"D:\Noguchi\Solution\Tang's\output\1014-091351\epoch21.pth" +# # model_ = torch.load(model_path) +# model.load_state_dict(torch.load(model_path)) +model.eval() +shouldSave = False +shouldShow = False +ious = [] +for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels = data[1].to(device) + outputs = model(inputs).sigmoid() + + pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + true = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + + img_pred = (pred * 255).astype(np.uint8) + # otsu + ret, img_pred = cv2.threshold(img_pred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + + if shouldShow: + print("img") + img_input = inputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0] / 255.0 + plt.imshow(img_input) + plt.show() + + print("label") + img_label = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.imshow(img_label) + plt.show() + + print("output") + plt.imshow(img_pred) + plt.show() + + print("output_refined") + dst = img_pred.copy() + plt.imshow(dst) + plt.show() + + y_pred = (img_pred / 255).flatten() + y_true = true.flatten() + tn, fp, fn, tp = confusion_matrix(y_pred, y_true).ravel() + + iou_tp = tp / (tp + fp + fn) + + ious.append(iou_tp) + + if shouldSave: + num_output = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.axis("off") + plt.imshow(img_pred) + plt.savefig(path_outputDir + r"/" + str(i + 1) + ".jpg", bbox_inches='tight') + + if os.path.exists(path_outputDir + r'/Log_detail.csv'): + with open(path_outputDir + r'/Log_detail.csv', 'a', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + else: + with open(path_outputDir + r'/Log_detail.csv', 'x', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + +print("全体平均:", np.array(ious).mean()) +if os.path.exists(path_outputDir + r'/Log.txt'): + with open(path_outputDir + r'/Log.txt', 'w', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) +else: + with open(path_outputDir + r'/Log.txt', 'x', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) diff --git a/legacy/source/models.py b/legacy/source/models.py new file mode 100644 index 0000000..453b842 --- /dev/null +++ b/legacy/source/models.py @@ -0,0 +1,455 @@ +import torch.nn as nn +import torch +from torchvision import models + + + +def convrelu(in_channels, out_channels, kernel, padding): + return nn.Sequential( + nn.Conv2d(in_channels, out_channels, kernel, padding=padding), + nn.ReLU(inplace=True), + ) + + +class ResNetUNet(nn.Module): + def __init__(self, n_class): + super().__init__() + + self.base_model = models.resnet18(pretrained=True) + self.base_layers = list(self.base_model.children()) + + self.layer0 = nn.Sequential(*self.base_layers[:3]) # size=(N, 64, x.H/2, x.W/2) + self.layer0_1x1 = convrelu(64, 64, 1, 0) + self.layer1 = nn.Sequential(*self.base_layers[3:5]) # size=(N, 64, x.H/4, x.W/4) + self.layer1_1x1 = convrelu(64, 64, 1, 0) + self.layer2 = self.base_layers[5] # size=(N, 128, x.H/8, x.W/8) + self.layer2_1x1 = convrelu(128, 128, 1, 0) + self.layer3 = self.base_layers[6] # size=(N, 256, x.H/16, x.W/16) + self.layer3_1x1 = convrelu(256, 256, 1, 0) + self.layer4 = self.base_layers[7] # size=(N, 512, x.H/32, x.W/32) + self.layer4_1x1 = convrelu(512, 512, 1, 0) + + self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv_up3 = convrelu(256 + 512, 512, 3, 1) + self.conv_up2 = convrelu(128 + 512, 256, 3, 1) + self.conv_up1 = convrelu(64 + 256, 256, 3, 1) + self.conv_up0 = convrelu(64 + 256, 128, 3, 1) + + self.conv_original_size0 = convrelu(3, 64, 3, 1) + self.conv_original_size1 = convrelu(64, 64, 3, 1) + self.conv_original_size2 = convrelu(64 + 128, 64, 3, 1) + + self.conv_last = nn.Conv2d(64, n_class, 1) + + def forward(self, input): + x_original = self.conv_original_size0(input) + x_original = self.conv_original_size1(x_original) + + layer0 = self.layer0(input) + layer1 = self.layer1(layer0) + layer2 = self.layer2(layer1) + layer3 = self.layer3(layer2) + layer4 = self.layer4(layer3) + + layer4 = self.layer4_1x1(layer4) + x = self.upsample(layer4) + layer3 = self.layer3_1x1(layer3) + x = torch.cat([x, layer3], dim=1) + x = self.conv_up3(x) + + x = self.upsample(x) + layer2 = self.layer2_1x1(layer2) + x = torch.cat([x, layer2], dim=1) + x = self.conv_up2(x) + + x = self.upsample(x) + layer1 = self.layer1_1x1(layer1) + x = torch.cat([x, layer1], dim=1) + x = self.conv_up1(x) + + x = self.upsample(x) + layer0 = self.layer0_1x1(layer0) + x = torch.cat([x, layer0], dim=1) + x = self.conv_up0(x) + + x = self.upsample(x) + x = torch.cat([x, x_original], dim=1) + x = self.conv_original_size2(x) + + out = self.conv_last(x) + + return out + + +class ResNetUNet_Pruning(nn.Module): + def __init__(self, n_class): + super().__init__() + + self.base_model = models.resnet18(pretrained=True) + self.base_layers = list(self.base_model.children()) + + self.layer0 = nn.Sequential(*self.base_layers[:3]) # size=(N, 64, x.H/2, x.W/2) + self.layer0_1x1 = convrelu(64, 64, 1, 0) + self.layer1 = nn.Sequential(*self.base_layers[3:5]) # size=(N, 64, x.H/4, x.W/4) + self.layer1_1x1 = convrelu(64, 64, 1, 0) + self.layer2 = self.base_layers[5] # size=(N, 128, x.H/8, x.W/8) + self.layer2_1x1 = convrelu(128, 128, 1, 0) + self.layer3 = self.base_layers[6] # size=(N, 256, x.H/16, x.W/16) + self.layer3_1x1 = convrelu(256, 256, 1, 0) + self.layer4 = self.base_layers[7] # size=(N, 512, x.H/32, x.W/32) + self.layer4_1x1 = convrelu(512, 512, 1, 0) + + self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv_up3 = convrelu(256 + 512, 512, 3, 1) + self.conv_up2 = convrelu(128 + 512, 256, 3, 1) + self.conv_up1 = convrelu(64 + 256, 256, 3, 1) + # self.conv_up0 = convrelu(64 + 256, 128, 3, 1) + self.conv_up0 = convrelu(256, 64, 3, 1) + + self.conv_original_size0 = convrelu(3, 64, 3, 1) + self.conv_original_size1 = convrelu(64, 64, 3, 1) + # self.conv_original_size2 = convrelu(64 + 128, 64, 3, 1) + self.conv_original_size2 = convrelu(64, 64, 3, 1) + + self.conv_last = nn.Conv2d(64, n_class, 1) + + def forward(self, input): + x_original = self.conv_original_size0(input) + x_original = self.conv_original_size1(x_original) + + layer0 = self.layer0(input) # 実質,0, 1, 2 層 + layer1 = self.layer1(layer0) + layer2 = self.layer2(layer1) + layer3 = self.layer3(layer2) + layer4 = self.layer4(layer3) + + layer4 = self.layer4_1x1(layer4) + x = self.upsample(layer4) + layer3 = self.layer3_1x1(layer3) + x = torch.cat([x, layer3], dim=1) + x = self.conv_up3(x) + + x = self.upsample(x) + layer2 = self.layer2_1x1(layer2) + x = torch.cat([x, layer2], dim=1) + x = self.conv_up2(x) + + x = self.upsample(x) + layer1 = self.layer1_1x1(layer1) + x = torch.cat([x, layer1], dim=1) + x = self.conv_up1(x) + + x = self.upsample(x) + layer0 = self.layer0_1x1(layer0) + # x = torch.cat([x, layer0], dim=1) + x = self.conv_up0(x) + + x = self.upsample(x) + # x = torch.cat([x, x_original], dim=1) + x = self.conv_original_size2(x) + + out = self.conv_last(x) + + return out + + +class VGGBlock(nn.Module): + def __init__(self, in_channels, middle_channels, out_channels): + super().__init__() + self.relu = nn.ReLU(inplace=True) + self.conv1 = nn.Conv2d(in_channels, middle_channels, 3, padding=1) + self.bn1 = nn.BatchNorm2d(middle_channels) + self.conv2 = nn.Conv2d(middle_channels, out_channels, 3, padding=1) + self.bn2 = nn.BatchNorm2d(out_channels) + + def forward(self, x): + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + return out + + +class UNet(nn.Module): + def __init__(self, n_class, input_channels=3, **kwargs): + super().__init__() + + nb_filter = [32, 64, 128, 256, 512] + + self.pool = nn.MaxPool2d(2, 2) + self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv0_0 = VGGBlock(input_channels, nb_filter[0], nb_filter[0]) + self.conv1_0 = VGGBlock(nb_filter[0], nb_filter[1], nb_filter[1]) + self.conv2_0 = VGGBlock(nb_filter[1], nb_filter[2], nb_filter[2]) + self.conv3_0 = VGGBlock(nb_filter[2], nb_filter[3], nb_filter[3]) + self.conv4_0 = VGGBlock(nb_filter[3], nb_filter[4], nb_filter[4]) + + self.conv3_1 = VGGBlock(nb_filter[3]+nb_filter[4], nb_filter[3], nb_filter[3]) + self.conv2_2 = VGGBlock(nb_filter[2]+nb_filter[3], nb_filter[2], nb_filter[2]) + self.conv1_3 = VGGBlock(nb_filter[1]+nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv0_4 = VGGBlock(nb_filter[0]+nb_filter[1], nb_filter[0], nb_filter[0]) + + self.final = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + + + def forward(self, input): + x0_0 = self.conv0_0(input) + x1_0 = self.conv1_0(self.pool(x0_0)) + x2_0 = self.conv2_0(self.pool(x1_0)) + x3_0 = self.conv3_0(self.pool(x2_0)) + x4_0 = self.conv4_0(self.pool(x3_0)) + + x3_1 = self.conv3_1(torch.cat([x3_0, self.up(x4_0)], 1)) + x2_2 = self.conv2_2(torch.cat([x2_0, self.up(x3_1)], 1)) + x1_3 = self.conv1_3(torch.cat([x1_0, self.up(x2_2)], 1)) + x0_4 = self.conv0_4(torch.cat([x0_0, self.up(x1_3)], 1)) + + output = self.final(x0_4) + return output + + +class UNet_Pruning(nn.Module): + def __init__(self, n_class, input_channels=3, **kwargs): + super().__init__() + + nb_filter = [32, 64, 128, 256, 512] + + self.pool = nn.MaxPool2d(2, 2) + self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv0_0 = VGGBlock(input_channels, nb_filter[0], nb_filter[0]) + self.conv1_0 = VGGBlock(nb_filter[0], nb_filter[1], nb_filter[1]) + self.conv2_0 = VGGBlock(nb_filter[1], nb_filter[2], nb_filter[2]) + self.conv3_0 = VGGBlock(nb_filter[2], nb_filter[3], nb_filter[3]) + self.conv4_0 = VGGBlock(nb_filter[3], nb_filter[4], nb_filter[4]) + + self.conv3_1 = VGGBlock(nb_filter[3]+nb_filter[4], nb_filter[3], nb_filter[3]) + self.conv2_2 = VGGBlock(nb_filter[2]+nb_filter[3], nb_filter[2], nb_filter[2]) + self.conv1_3 = VGGBlock(nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv0_4 = VGGBlock(nb_filter[1], nb_filter[0], nb_filter[0]) + + self.final = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + + + def forward(self, input): + x0_0 = self.conv0_0(input) + x1_0 = self.conv1_0(self.pool(x0_0)) + x2_0 = self.conv2_0(self.pool(x1_0)) + x3_0 = self.conv3_0(self.pool(x2_0)) + x4_0 = self.conv4_0(self.pool(x3_0)) + + x3_1 = self.conv3_1(torch.cat([x3_0, self.up(x4_0)], 1)) + x2_2 = self.conv2_2(torch.cat([x2_0, self.up(x3_1)], 1)) + # x1_3 = self.conv1_3(torch.cat([x1_0, self.up(x2_2)], 1)) + # x0_4 = self.conv0_4(torch.cat([x0_0, self.up(x1_3)], 1)) + x1_3 = self.conv1_3(torch.cat([self.up(x2_2)], 1)) + x0_4 = self.conv0_4(torch.cat([self.up(x1_3)], 1)) + + output = self.final(x0_4) + return output + +class NestedUNet(nn.Module): + def __init__(self, n_class, input_channels=3, deep_supervision=False, **kwargs): + super().__init__() + + nb_filter = [32, 64, 128, 256, 512] + + self.deep_supervision = deep_supervision + + self.pool = nn.MaxPool2d(2, 2) + self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv0_0 = VGGBlock(input_channels, nb_filter[0], nb_filter[0]) + self.conv1_0 = VGGBlock(nb_filter[0], nb_filter[1], nb_filter[1]) + self.conv2_0 = VGGBlock(nb_filter[1], nb_filter[2], nb_filter[2]) + self.conv3_0 = VGGBlock(nb_filter[2], nb_filter[3], nb_filter[3]) + self.conv4_0 = VGGBlock(nb_filter[3], nb_filter[4], nb_filter[4]) + + self.conv0_1 = VGGBlock(nb_filter[0]+nb_filter[1], nb_filter[0], nb_filter[0]) + self.conv1_1 = VGGBlock(nb_filter[1]+nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv2_1 = VGGBlock(nb_filter[2]+nb_filter[3], nb_filter[2], nb_filter[2]) + self.conv3_1 = VGGBlock(nb_filter[3]+nb_filter[4], nb_filter[3], nb_filter[3]) + + self.conv0_2 = VGGBlock(nb_filter[0]*2+nb_filter[1], nb_filter[0], nb_filter[0]) + self.conv1_2 = VGGBlock(nb_filter[1]*2+nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv2_2 = VGGBlock(nb_filter[2]*2+nb_filter[3], nb_filter[2], nb_filter[2]) + + self.conv0_3 = VGGBlock(nb_filter[0]*3+nb_filter[1], nb_filter[0], nb_filter[0]) + self.conv1_3 = VGGBlock(nb_filter[1]*3+nb_filter[2], nb_filter[1], nb_filter[1]) + + self.conv0_4 = VGGBlock(nb_filter[0]*4+nb_filter[1], nb_filter[0], nb_filter[0]) + + if self.deep_supervision: + self.final1 = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + self.final2 = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + self.final3 = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + self.final4 = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + else: + self.final = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + + + def forward(self, input): + x0_0 = self.conv0_0(input) + x1_0 = self.conv1_0(self.pool(x0_0)) + x0_1 = self.conv0_1(torch.cat([x0_0, self.up(x1_0)], 1)) + + x2_0 = self.conv2_0(self.pool(x1_0)) + x1_1 = self.conv1_1(torch.cat([x1_0, self.up(x2_0)], 1)) + x0_2 = self.conv0_2(torch.cat([x0_0, x0_1, self.up(x1_1)], 1)) + + x3_0 = self.conv3_0(self.pool(x2_0)) + x2_1 = self.conv2_1(torch.cat([x2_0, self.up(x3_0)], 1)) + x1_2 = self.conv1_2(torch.cat([x1_0, x1_1, self.up(x2_1)], 1)) + x0_3 = self.conv0_3(torch.cat([x0_0, x0_1, x0_2, self.up(x1_2)], 1)) + + x4_0 = self.conv4_0(self.pool(x3_0)) + x3_1 = self.conv3_1(torch.cat([x3_0, self.up(x4_0)], 1)) + x2_2 = self.conv2_2(torch.cat([x2_0, x2_1, self.up(x3_1)], 1)) + x1_3 = self.conv1_3(torch.cat([x1_0, x1_1, x1_2, self.up(x2_2)], 1)) + x0_4 = self.conv0_4(torch.cat([x0_0, x0_1, x0_2, x0_3, self.up(x1_3)], 1)) + + if self.deep_supervision: + output1 = self.final1(x0_1) + output2 = self.final2(x0_2) + output3 = self.final3(x0_3) + output4 = self.final4(x0_4) + return [output1, output2, output3, output4] + + else: + output = self.final(x0_4) + return output + + +class TwoTaskUNet(nn.Module): + def __init__(self, n_class): + super().__init__() + + nb_filter = [32, 64, 128, 256, 512] + + self.downsample = nn.MaxPool2d(2, 2) + self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv0 = VGGBlock(3, nb_filter[0], nb_filter[0]) + self.conv1 = VGGBlock(nb_filter[0], nb_filter[1], nb_filter[1]) + self.conv2 = VGGBlock(nb_filter[1], nb_filter[2], nb_filter[2]) + self.conv3 = VGGBlock(nb_filter[2], nb_filter[3], nb_filter[3]) + self.conv4 = VGGBlock(nb_filter[3], nb_filter[4], nb_filter[4]) + + self.conv3_1 = VGGBlock(nb_filter[3] + nb_filter[4], nb_filter[3], nb_filter[3]) + self.conv2_1 = VGGBlock(nb_filter[2] + nb_filter[3], nb_filter[2], nb_filter[2]) + self.conv1_1 = VGGBlock(nb_filter[1] + nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv0_1 = VGGBlock(nb_filter[0] + nb_filter[1], nb_filter[0], nb_filter[0]) + self.final_1 = nn.Conv2d(nb_filter[0], n_class, kernel_size=1) + + self.conv3_2 = VGGBlock(nb_filter[3] + nb_filter[4], nb_filter[3], nb_filter[3]) + self.conv2_2 = VGGBlock(nb_filter[2] + nb_filter[3], nb_filter[2], nb_filter[2]) + self.conv1_2 = VGGBlock(nb_filter[1] + nb_filter[2], nb_filter[1], nb_filter[1]) + self.conv0_2 = VGGBlock(nb_filter[0] + nb_filter[1], nb_filter[0], nb_filter[0]) + self.final_2 = nn.Conv2d(nb_filter[0], 3, kernel_size=1) + + def forward(self, input): + # Shared Encoder + x0 = self.conv0(input) + x1 = self.conv1(self.downsample(x0)) + x2 = self.conv2(self.downsample(x1)) + x3 = self.conv3(self.downsample(x2)) + encoderOutput = self.conv4(self.downsample(x3)) + # Decoder 1 for segmentation + x3_1 = self.conv3_1(torch.cat([x3, self.upsample(encoderOutput)], 1)) + x2_1 = self.conv2_1(torch.cat([x2, self.upsample(x3_1)], 1)) + x1_1 = self.conv1_1(torch.cat([x1, self.upsample(x2_1)], 1)) + x0_1 = self.conv0_1(torch.cat([x0, self.upsample(x1_1)], 1)) + segmentation = self.final_1(x0_1) + # Decoder 2 for reconstruction + x3_2 = self.conv3_2(torch.cat([x3, self.upsample(encoderOutput)], 1)) + x2_2 = self.conv2_2(torch.cat([x2, self.upsample(x3_2)], 1)) + x1_2 = self.conv1_2(torch.cat([x1, self.upsample(x2_2)], 1)) + x0_2 = self.conv0_2(torch.cat([x0, self.upsample(x1_2)], 1)) + reconstruction = self.final_2(x0_2) + return segmentation, reconstruction + + +class TwoTaskResUNet(nn.Module): + def __init__(self, n_class): + super().__init__() + + self.base_model = models.resnet18(pretrained=True) + self.base_layers = list(self.base_model.children()) + + self.layer0 = nn.Sequential(*self.base_layers[:3]) # size=(N, 64, x.H/2, x.W/2) + self.layer1 = nn.Sequential(*self.base_layers[3:5]) # size=(N, 64, x.H/4, x.W/4) + self.layer2 = self.base_layers[5] # size=(N, 128, x.H/8, x.W/8) + self.layer3 = self.base_layers[6] # size=(N, 256, x.H/16, x.W/16) + self.layer4 = self.base_layers[7] # size=(N, 512, x.H/32, x.W/32) + + self.layer0_1x1_1 = convrelu(64, 64, 1, 0) + self.layer1_1x1_1 = convrelu(64, 64, 1, 0) + self.layer2_1x1_1 = convrelu(128, 128, 1, 0) + self.layer3_1x1_1 = convrelu(256, 256, 1, 0) + self.layer4_1x1_1 = convrelu(512, 512, 1, 0) + + self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True) + + self.conv_original_size0 = convrelu(3, 64, 3, 1) + self.conv_original_size1 = convrelu(64, 64, 3, 1) + + # Segmentation + self.conv_up3_1 = convrelu(256 + 512, 512, 3, 1) + self.conv_up2_1 = convrelu(128 + 512, 256, 3, 1) + self.conv_up1_1 = convrelu(64 + 256, 256, 3, 1) + self.conv_up0_1 = convrelu(64 + 256, 128, 3, 1) + self.conv_original_size2_1 = convrelu(64 + 128, 64, 3, 1) + self.conv_last_1 = nn.Conv2d(64, n_class, 1) + # Reconstruction + self.conv_up3_2 = convrelu(256 + 512, 512, 3, 1) + self.conv_up2_2 = convrelu(128 + 512, 256, 3, 1) + self.conv_up1_2 = convrelu(64 + 256, 256, 3, 1) + self.conv_up0_2 = convrelu(64 + 256, 128, 3, 1) + self.conv_original_size2_2 = convrelu(64 + 128, 64, 3, 1) + self.conv_last_2 = nn.Conv2d(64, 3, 1) + + def forward(self, input): + x_original = self.conv_original_size0(input) + x_original = self.conv_original_size1(x_original) + + layer0 = self.layer0(input) + layer1 = self.layer1(layer0) + layer2 = self.layer2(layer1) + layer3 = self.layer3(layer2) + encoderOutput = self.layer4(layer3) + + # Decoder 1 for segmentation + x = self.layer4_1x1_1(encoderOutput) + x = self.upsample(x) + x = self.conv_up3_1(torch.cat([x, self.layer3_1x1_1(layer3)], dim=1)) + x = self.upsample(x) + x = self.conv_up2_1(torch.cat([x, self.layer2_1x1_1(layer2)], dim=1)) + x = self.upsample(x) + x = self.conv_up1_1(torch.cat([x, self.layer1_1x1_1(layer1)], dim=1)) + x = self.upsample(x) + x = self.conv_up0_1(torch.cat([x, self.layer0_1x1_1(layer0)], dim=1)) + x = self.upsample(x) + x = self.conv_original_size2_1(torch.cat([x, x_original], dim=1)) + segmentation = self.conv_last_1(x) + # Decoder 2 for reconstruction + x = self.layer4_1x1_1(encoderOutput) + x = self.upsample(x) + x = self.conv_up3_2(torch.cat([x, self.layer3_1x1_1(layer3)], dim=1)) + x = self.upsample(x) + x = self.conv_up2_2(torch.cat([x, self.layer2_1x1_1(layer2)], dim=1)) + x = self.upsample(x) + x = self.conv_up1_2(torch.cat([x, self.layer1_1x1_1(layer1)], dim=1)) + x = self.upsample(x) + x = self.conv_up0_2(torch.cat([x, self.layer0_1x1_1(layer0)], dim=1)) + x = self.upsample(x) + x = self.conv_original_size2_2(torch.cat([x, x_original], dim=1)) + reconstruction = self.conv_last_2(x) + return segmentation, reconstruction + diff --git a/legacy/source/pytorchToOnnx.py b/legacy/source/pytorchToOnnx.py new file mode 100644 index 0000000..369ff6e --- /dev/null +++ b/legacy/source/pytorchToOnnx.py @@ -0,0 +1,80 @@ +import copy +import datetime +import glob +import os +import time +import cv2 +import matplotlib.pyplot as plt +import torchvision.transforms.functional as TF +import torch +import numpy as np +from sklearn.metrics import confusion_matrix +from torch.optim import lr_scheduler +from torch.utils.data import DataLoader +from torchvision import transforms +from tqdm.notebook import tqdm +from source.losses import * +from source.models import * +from source.utils import * + +class TongueSegDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label = [] + for path_sample in self.paths_sample: + self.paths_label.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Load label + path_label = self.paths_label[index] + label = torch.from_numpy(cv2.imread(path_label, cv2.IMREAD_COLOR)) + label[label <= 128] = 0.0 + label[label > 128] = 1.0 + label = label.permute(2, 0, 1).float() + if self.transform_label: + label = self.transform_label(label) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label = tf(label) + + label_pos = label[0, :, :] + label_neg = torch.ones(label_pos.shape) - label[0, :, :] + label_pos = label_pos.unsqueeze(0) + label_neg = label_neg.unsqueeze(0) + label = torch.cat([label_pos, label_neg], axis=0) + return sample, label + + def __len__(self): + return len(self.paths_sample) + +# Configs + +# load data train +fix_rand(2021) +path_model = r"D:\Noguchi\Solution\TongueSegmentation\result\CompareModels\ResUNet\bestModel.pth" +path_outputDir = os.path.join("..\output", datetime.datetime.now().strftime('%m%d-%H%M%S')) +os.makedirs(path_outputDir) + +model = ResNetUNet(n_class=2) +model.load_state_dict(torch.load(path_model)) +model.eval() +path_outputONNX = path_outputDir + r"\ResUNet.onnx" +torch.onnx.export(model, torch.zeros([1, 3, 256, 256]), path_outputONNX, opset_version=11) diff --git a/legacy/source/test.py b/legacy/source/test.py new file mode 100644 index 0000000..34307e5 --- /dev/null +++ b/legacy/source/test.py @@ -0,0 +1,8 @@ +import pandas as pd + +df = pd.DataFrame([[1, 2, 3, 4], [1, 2, 3, 5]]) + + +print(mean) +df = pd.concat([df, mean]) +print(df) \ No newline at end of file diff --git a/legacy/source/utils.py b/legacy/source/utils.py new file mode 100644 index 0000000..71c7de3 --- /dev/null +++ b/legacy/source/utils.py @@ -0,0 +1,90 @@ +import os +import random +import numpy as np +import torch + + +# define +def fix_rand(seed=2021): + np.random.seed(seed) + random.seed(seed) + torch.manual_seed(seed) + torch.cuda.manual_seed(seed) + torch.cuda.manual_seed_all(seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + os.environ["PYTHONHASHSEED"] = str(seed) + torch.use_deterministic_algorithms(False) + # torch.use_deterministic_algorithms(True) + + + +def RemoveSmallRegion(Src, Dst, AreaLimit, CheckMode, NeihborMode): + RemoveCount = 0 + PointLabel = np.zeros((Src.shape), np.uint8) + if CheckMode == 1: # mode1 小さい領域(白飛び)の削除 + for i in range(0, Src.shape[0]): + for j in range(0, Src.shape[1]): + if Src[i][j] < 128: + PointLabel[i][j] = 3 + else: # mode0 穴(黒飛び)の削除 + for i in range(0, Src.shape[0]): + for j in range(0, Src.shape[1]): + if Src[i][j] >= 128: + PointLabel[i][j] = 3 + + NeihborPos = list() + NeihborPos.append([-1, 0]) + NeihborPos.append([1, 0]) + NeihborPos.append([0, -1]) + NeihborPos.append([0, 1]) + + if NeihborMode == 1: + NeihborPos.append([-1, -1]) + NeihborPos.append([-1, 1]) + NeihborPos.append([1, -1]) + NeihborPos.append([1, 1]) + + NeihborCount = 4 + 4 * NeihborMode + CurrX = 0 + CurrY = 0 + + for i in range(0, Src.shape[0]): + for j in range(0, Src.shape[1]): + + if PointLabel[i][j] == 0: + GrowBuffer = list() + GrowBuffer.append([i, j]) + PointLabel[i][j] = 1 + CheckResult = 0 + + z = 0 + while z < len(GrowBuffer): + for q in range(0, NeihborCount): + CurrY = GrowBuffer[z][0] + NeihborPos[q][0] + CurrX = GrowBuffer[z][1] + NeihborPos[q][1] + if CurrX >= 0 and CurrX < Src.shape[1] and CurrY >= 0 and CurrY < Src.shape[0]: + if PointLabel[CurrY][CurrX] == 0: + GrowBuffer.append([CurrY, CurrX]) + PointLabel[CurrY][CurrX] = 1 + z = z + 1 + + if len(GrowBuffer) > AreaLimit: + CheckResult = 2 + else: + CheckResult = 1 + RemoveCount = RemoveCount + 1 + + for z in range(0, len(GrowBuffer)): + CurrX = GrowBuffer[z][1] + CurrY = GrowBuffer[z][0] + PointLabel[CurrY][CurrX] += CheckResult + + CheckMode = 255 * (1 - CheckMode) + for i in range(0, Src.shape[0]): + for j in range(0, Src.shape[1]): + if PointLabel[i][j] == 2: + Dst[i][j] = CheckMode + + elif PointLabel[i][j] == 3: + Dst[i][j] = Src[i][j] \ No newline at end of file diff --git a/legacy/temp/main.py b/legacy/temp/main.py new file mode 100644 index 0000000..bff2a8f --- /dev/null +++ b/legacy/temp/main.py @@ -0,0 +1,296 @@ +from segmentation_models.segmentation_models_pytorch.pspnet import PSPNet +import copy +import datetime +import glob +import os +import time +import cv2 +import matplotlib.pyplot as plt +import torchvision.transforms.functional as TF +import torch +import numpy as np +from sklearn.metrics import confusion_matrix +from torch.optim import lr_scheduler +from torch.utils.data import DataLoader +from torchvision import transforms +from tqdm.notebook import tqdm +from source.losses import * +from source.models import * +from source.utils import * + + +class TongueSegDataset(torch.utils.data.Dataset): + def __init__(self, path_sampleDir, path_labelDir, transform_sample=None, transform_label=None, transform_both=None): + super().__init__() + + self.transform_sample = transform_sample + self.paths_sample = glob.glob(os.path.join(path_sampleDir, '*')) + + self.paths_label = [] + for path_sample in self.paths_sample: + self.paths_label.append(os.path.join(path_labelDir, os.path.basename(path_sample))) + self.transform_label = transform_label + + self.transform_both = transform_both + + def __getitem__(self, index): + + # Load sample + path_sample = self.paths_sample[index] + sample = torch.from_numpy(cv2.imread(path_sample, cv2.IMREAD_COLOR)) / 255.0 + sample = sample.permute(2, 0, 1).float() + if self.transform_sample: + sample = self.transform_sample(sample) + + # Load label + path_label = self.paths_label[index] + label = torch.from_numpy(cv2.imread(path_label, cv2.IMREAD_COLOR)) + label[label <= 128] = 0.0 + label[label > 128] = 1.0 + label = label.permute(2, 0, 1).float() + if self.transform_label: + label = self.transform_label(label) + + if self.transform_both: + for tf, p in self.transform_both: + if random.random() < p: + sample = tf(sample) + label = tf(label) + + label_pos = label[0, :, :] + label_neg = torch.ones(label_pos.shape) - label[0, :, :] + label_pos = label_pos.unsqueeze(0) + label_neg = label_neg.unsqueeze(0) + label = torch.cat([label_pos, label_neg], axis=0) + return sample, label + + def __len__(self): + return len(self.paths_sample) + + +# Configs +path_outputDir = os.path.join("../output", datetime.datetime.now().strftime('%m%d-%H%M%S')) +os.makedirs(path_outputDir) + +# load data train +path_trainSample = os.path.join("../input", "train", "sample") +path_trainLabel = os.path.join("../input", "train", "label") +path_testSample = os.path.join("../input", "test_extra", "cropped", "sample") +path_testLabel = os.path.join("../input", "test_extra", "cropped", "label") + +# Params +fix_rand(2021) +batch_size = 16 +train_ratio = 2 / 3 +transform_sample = transforms.Compose([transforms.ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)]) +transform_label = transforms.Compose([]) +transform_both = [(TF.hflip, 0.5)] +dataset = TongueSegDataset(path_trainSample, path_trainLabel, transform_sample=transform_sample, + transform_label=transform_label, transform_both=transform_both) + +train_dataset, val_dataset = torch.utils.data.random_split(dataset, + [int(len(dataset) * train_ratio), len(dataset) - int(len(dataset) * train_ratio)]) +data_loader_train = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=0) +data_loader_val = DataLoader(val_dataset, batch_size=batch_size, shuffle=True, num_workers=0) +print("train:", len(train_dataset), " validation:", len(val_dataset)) + +# show +for epoch in range(0, 1): + for inputs, labels in data_loader_train: + input = inputs[0, :, :, :] + label = labels[0, :, :, :] + img_input = np.array(input.permute(1, 2, 0)) + plt.imshow(img_input) + plt.show() + img_label = np.array(label[0]) / 255.0 + plt.imshow(img_label) + plt.show() + break + +device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +learning_rate = 1e-4 +num_epochs = 300 +num_epochsEarlyStop = 30 +criterion = DiceCE(bce_weight=0.5) + +# create model +fix_rand(2021) +model = PSPNet(classes=2) +model = model.to(device) +optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate) +# scheduler = lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.1) # is not used + +since = time.time() +best_model_wts = copy.deepcopy(model.state_dict()) +best_model_epochs = 0 +best_loss = 1e5 +losses_train = [] +losses_val = [] +for epoch in tqdm(range(num_epochs)): + print('Epoch {}/{}'.format(epoch + 1, num_epochs)) + print('-' * 10) + + # Each epoch has a training and validation phase + for phase in ['train', 'val']: + + if phase == 'train': + model.train() # Set model to training mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels in data_loader_train: + inputs = inputs.to(device) + labels = labels.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss = criterion(outputs, labels) + + loss.backward() + optimizer.step() + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_train) + losses_train.append(epoch_loss) + + else: + model.eval() # Set model to evaluate mode + + # Iterate over data. + running_loss = 0.0 + for inputs, labels in data_loader_val: + inputs = inputs.to(device) + labels = labels.to(device) + + # zero the parameter gradients + optimizer.zero_grad() + + # forward + # track history if only in train + with torch.set_grad_enabled(phase == 'train'): + outputs = model(inputs) + loss = criterion(outputs, labels) + + # statistics + running_loss += loss.item() + + epoch_loss = running_loss / len(data_loader_val) + losses_val.append(epoch_loss) + # scheduler.step() + + print('{} Loss: {:.4f}'.format(phase, epoch_loss)) + + # Todo: early stopping, and metrics + # deep copy the model + if phase == 'val' and epoch_loss < best_loss: + best_loss = epoch_loss + best_model_wts = copy.deepcopy(model.state_dict()) + torch.save(model.state_dict(), path_outputDir + r"/epoch" + str(epoch) + ".pth") + best_model_epochs = epoch + print("best model saved") + + if (epoch - best_model_epochs) >= num_epochsEarlyStop: + break + +time_elapsed = time.time() - since +print('Training complete in {:.0f}m {:.0f}s'.format( + time_elapsed // 60, time_elapsed % 60)) +print('Best val Loss: {:4f}'.format(best_loss)) + +# load best model weights +model.load_state_dict(best_model_wts) +torch.save(model.state_dict(), path_outputDir + r"/bestModel.pth") + +# lossの可視化 +plt.plot(losses_train, label='training loss') +plt.plot(losses_val, label='validation loss') +plt.ylabel("loss") +plt.xlabel("epoch time") +# plt.ylim(0, 0.35) +plt.savefig(path_outputDir + "/loss.png") +plt.legend() +plt.show() + +# Evaluation +dataset_test = TongueSegDataset(path_testSample, path_testLabel) +data_loader_test = DataLoader(dataset_test, batch_size=1, shuffle=False) + +# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +# model = ResNetUNet(n_class=2) +# model = model.to(device) +# model_path = r"D:\Noguchi\Solution\Tang's\output\1014-091351\epoch21.pth" +# # model_ = torch.load(model_path) +# model.load_state_dict(torch.load(model_path)) +model.eval() +shouldSave = False +shouldShow = False +ious = [] +for i, data in tqdm(enumerate(data_loader_test, 0)): + name = os.path.splitext(os.path.basename(glob.glob(path_testSample + "/*")[i]))[0] + + inputs = data[0].to(device) + labels = data[1].to(device) + outputs = model(inputs).sigmoid() + + pred = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + true = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + + img_pred = (pred * 255).astype(np.uint8) + # otsu + ret, img_pred = cv2.threshold(img_pred, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + + if shouldShow: + print("img") + img_input = inputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0] / 255.0 + plt.imshow(img_input) + plt.show() + + print("label") + img_label = labels.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.imshow(img_label) + plt.show() + + print("output") + plt.imshow(img_pred) + plt.show() + + print("output_refined") + dst = img_pred.copy() + plt.imshow(dst) + plt.show() + + y_pred = (img_pred / 255).flatten() + y_true = true.flatten() + tn, fp, fn, tp = confusion_matrix(y_pred, y_true).ravel() + + iou_tp = tp / (tp + fp + fn) + + ious.append(iou_tp) + + if shouldSave: + num_output = outputs.permute(0, 2, 3, 1).to('cpu').detach().numpy()[0, :, :, 0] + plt.axis("off") + plt.imshow(img_pred) + plt.savefig(path_outputDir + r"/" + str(i + 1) + ".jpg", bbox_inches='tight') + + if os.path.exists(path_outputDir + r'/Log_detail.txt'): + with open(path_outputDir + r'/Log_detail.txt', 'a', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + else: + with open(path_outputDir + r'/Log_detail.txt', 'x', encoding='utf-8') as f: + f.write(name + ", " + str(iou_tp) + "\n") + +print("全体平均:", np.array(ious).mean()) +if os.path.exists(path_outputDir + r'/Log.txt'): + with open(path_outputDir + r'/Log.txt', 'w', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) +else: + with open(path_outputDir + r'/Log.txt', 'x', encoding='utf-8') as f: + s = f.write("全体平均:" + str(np.array(ious).mean())) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b112325 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,61 @@ +[project] +name = "tongue-seg-model" +version = "0.1.0" +description = "舌セグメンテーションモデル(ResUNet)の学習コード" +readme = "README.md" +requires-python = ">=3.12,<3.13" +dependencies = [ + "torch>=2.5", + "torchvision>=0.20", + "numpy>=2.0", + "opencv-python-headless>=5.0.0.93", + "matplotlib>=3.9", + "pydantic>=2.9", + "pyyaml>=6.0", + "onnx>=1.23.0", + "onnxruntime>=1.30.0", + "tiasdata", +] + +[dependency-groups] +dev = [ + "pytest>=8.0", + "ruff>=0.8", +] + +# Linux(Newton・Archimedes)では torch を PyTorch 公式の CUDA 12.6 版から取る. +# Archimedes のドライバ(535・CUDA 12.2 まで)では PyPI の既定(CUDA 13 版)が動かないため. +# 両サーバで同じビルドにそろう利点もある.Windows(手元)は PyPI の CPU 版のまま(ENV_01). +[tool.uv.sources] +torch = [{ index = "pytorch-cu126", marker = "sys_platform == 'linux'" }] +torchvision = [{ index = "pytorch-cu126", marker = "sys_platform == 'linux'" }] +tiasdata = { path = "external/TIASDataHub", editable = true } + +[[tool.uv.index]] +name = "pytorch-cu126" +url = "https://download.pytorch.org/whl/cu126" +explicit = true + +[build-system] +requires = ["uv_build>=0.12.5,<0.13"] +build-backend = "uv_build" + +[tool.ruff] +line-length = 100 +target-version = "py312" +# .claude/ はテンプレート所有のファイル,external/ はサブモジュール(別リポジトリ), +# legacy/ は原本(書き換えない.PLAN_01 の R1)のため lint・整形の対象から外す. +extend-exclude = [".claude", "external", "legacy"] + +[tool.ruff.lint] +select = ["E", "F", "W", "I", "B", "UP", "N"] + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" + +[tool.pytest.ini_options] +testpaths = ["tests"] +markers = [ + "slow: 学習を回す等の実行時間が長いテスト(通常実行では -m \"not slow\" で除外する)", +] diff --git a/src/tongue_seg_model/__init__.py b/src/tongue_seg_model/__init__.py new file mode 100644 index 0000000..86b7137 --- /dev/null +++ b/src/tongue_seg_model/__init__.py @@ -0,0 +1,3 @@ +"""舌セグメンテーションモデル(ResUNet)の学習コード.""" + +__version__ = "0.1.0" diff --git a/tests/test_smoke.py b/tests/test_smoke.py new file mode 100644 index 0000000..4e2e9e5 --- /dev/null +++ b/tests/test_smoke.py @@ -0,0 +1,30 @@ +"""環境構築の疎通確認(パッケージと主要な依存が読み込めること).""" + +import importlib + +import pytest + +import tongue_seg_model + + +def test_package_version() -> None: + assert tongue_seg_model.__version__ == "0.1.0" + + +@pytest.mark.parametrize( + "module", + [ + "torch", + "torchvision", + "numpy", + "cv2", + "matplotlib", + "pydantic", + "yaml", + "onnx", + "onnxruntime", + "tiasdata", + ], +) +def test_dependency_importable(module: str) -> None: + importlib.import_module(module) diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..e9d8204 --- /dev/null +++ b/uv.lock @@ -0,0 +1,935 @@ +version = 1 +revision = 3 +requires-python = "==3.12.*" +resolution-markers = [ + "sys_platform == 'linux'", + "sys_platform != 'linux'", +] + +[[package]] +name = "annotated-types" +version = "0.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5f/56/a8120250d128bed162cd73c76d45f6ef9991f3e068f62a8ee060afa3104a/annotated_types-0.8.0.tar.gz", hash = "sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7", size = 15893, upload-time = "2026-07-23T20:16:13.995Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl", hash = "sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0", size = 13427, upload-time = "2026-07-23T20:16:12.938Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "contourpy" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/5a/a55177dd22553a277388e8a1b3220e92de91bacb28356cdc73caa240121d/contourpy-1.4.0.tar.gz", hash = "sha256:20156f5a1ac4f8ce02656e39a61e82164a3d359796dc8026f75b062783d500e1", size = 13323726, upload-time = "2026-09-11T19:05:05.808Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/97/ba/01bde9753bdbba04a6da9d2bff3881f021bc708f654655e95fae26d3b3a3/contourpy-1.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:186ba929df36d61b6127da2e89cd1357e4cb79aca647381ab1a6feb0b152877b", size = 297302, upload-time = "2026-09-11T19:02:45.103Z" }, + { url = "https://files.pythonhosted.org/packages/dd/f5/c5bf67522d49a2222f3154fe46879451d26f0e35ece41770758a64ea78cb/contourpy-1.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c76f3a5318164db7d9401132fc1b5364b784c613c93fa506e3b5e6d1bf353ec8", size = 284921, upload-time = "2026-09-11T19:02:48.049Z" }, + { url = "https://files.pythonhosted.org/packages/0f/cc/cb989599eec12fda312e127eb8e04a8b21a7a6c94bf7ff1bc68273334a42/contourpy-1.4.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:43c3ccbb32c6294b183dcc8e8c46dacf5ecef809497e3d48a5be298eef185ad0", size = 356332, upload-time = "2026-09-11T19:02:51.408Z" }, + { url = "https://files.pythonhosted.org/packages/47/fb/6f620d7602507817b0b4c21dd790ed68688f1f4ae9c29aacf21f08db5cf1/contourpy-1.4.0-cp312-cp312-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:86d05cec773c9507a3950122e0e40ce77c23c75ceeb2fc189514e71893cbb34b", size = 405878, upload-time = "2026-09-11T19:02:54.093Z" }, + { url = "https://files.pythonhosted.org/packages/32/4e/693c6d6bdece679f0953775eef3a1b66d56be55478d936e7deb1f3004422/contourpy-1.4.0-cp312-cp312-manylinux_2_26_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2deb580178ca19437a84bd77e4bc2cd91a8ccad212413a83c273900868b5978c", size = 408296, upload-time = "2026-09-11T19:02:56.528Z" }, + { url = "https://files.pythonhosted.org/packages/78/f9/b6831508960d559581c448532ba4df312217072975486dbf2b24fcc5b76f/contourpy-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:875f42444c9cf48d56f724f2637e60d0f73b3b12c9041e1484580a233edf9591", size = 383243, upload-time = "2026-09-11T19:02:58.638Z" }, + { url = "https://files.pythonhosted.org/packages/f2/21/52903825a0ae7bb625e8bd30a09816d4c3c5d6174a469c10a616166cf780/contourpy-1.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f863c6100bf926cf47d13f3cd75f9bb8ebd98aaab230eeb4468b91f98f39a6b3", size = 1357306, upload-time = "2026-09-11T19:03:01.036Z" }, + { url = "https://files.pythonhosted.org/packages/d8/79/d68b1ce8539e4071518fed9523f558398f34dcd078b8927b109c72dad2ef/contourpy-1.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3863ef2e2b13fe93f8c0ebb08ee400cb07153b8b0e91c5acb26e4537f283634f", size = 1427243, upload-time = "2026-09-11T19:03:03.866Z" }, + { url = "https://files.pythonhosted.org/packages/ac/f0/b75a10e9d0616b97a30de277b6dfe83f1879880854c7330337309530eb48/contourpy-1.4.0-cp312-cp312-win32.whl", hash = "sha256:5450f091ac1be0be3ad3a2a3b3f23b5e443e78c670ced4fd347d626f92a28fd2", size = 347345, upload-time = "2026-09-11T19:03:06.192Z" }, + { url = "https://files.pythonhosted.org/packages/50/a9/dab08786bb4d77ef9a046b3c1be923be4e73c5d07d91f5a54e8ea9b09e41/contourpy-1.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:6e697d94e69f499ff6bebb899cae97a58d5d14f0e1fe9568b43a0248d2f9af8c", size = 234083, upload-time = "2026-09-11T19:03:08.122Z" }, + { url = "https://files.pythonhosted.org/packages/47/b9/3ba509755a970dbde5948e7142ac21f266be72f38017cc4087a05fdceee1/contourpy-1.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:0c7a4c2716a4e98342221954416a836cca77c996c14ddbf22b5f01d5d93ca09c", size = 559521, upload-time = "2026-09-11T19:03:10.047Z" }, +] + +[[package]] +name = "cuda-bindings" +version = "12.9.10" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cuda-pathfinder" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/7f/b2/8cef7e30e02e7ec3bf157ec192c0522546ed807c262752e884c693813494/cuda_bindings-12.9.10-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:aa1e07b12ae190a01ba3e0c85253be6ec1bfa13545a88eac5fd45ae4b0c04333", size = 7063851, upload-time = "2026-10-15T14:12:01.26Z" }, + { url = "https://files.pythonhosted.org/packages/7b/6e/0e07e8b3578547e1083a7ee105c5736033ecb189466f40e45283b46bc7c6/cuda_bindings-12.9.10-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:420e44cfcd939cd69d6cfe8efc5f08b44850994cae399a49b9299a464324ce97", size = 7627380, upload-time = "2026-10-15T14:12:03.328Z" }, +] + +[[package]] +name = "cuda-pathfinder" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/80/7cf8bbe4a8844198fa64481ffc6642003770999b9ead27e99fc03484989a/cuda_pathfinder-1.9.0-py3-none-any.whl", hash = "sha256:622df7440f7702f36b7a02a1699aa0b084fe04034d9939188fee9b16d0c36366", size = 63362, upload-time = "2026-11-13T17:02:04.522Z" }, +] + +[[package]] +name = "cuda-toolkit" +version = "12.6.3" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/88/2dbc37975fffb874418b14380418a1b99cb36f2101fd1d08c54e06ee8c95/cuda_toolkit-12.6.3-py2.py3-none-any.whl", hash = "sha256:79d8605baeb6c2f695761e0efb54bc62dbc3c9e32eb0742df7669c07befaa8f7", size = 2288, upload-time = "2025-08-13T02:03:05.283Z" }, +] + +[package.optional-dependencies] +cublas = [ + { name = "nvidia-cublas-cu12" }, +] +cudart = [ + { name = "nvidia-cuda-runtime-cu12" }, +] +cufft = [ + { name = "nvidia-cufft-cu12" }, +] +cufile = [ + { name = "nvidia-cufile-cu12" }, +] +cupti = [ + { name = "nvidia-cuda-cupti-cu12" }, +] +curand = [ + { name = "nvidia-curand-cu12" }, +] +cusolver = [ + { name = "nvidia-cusolver-cu12" }, +] +cusparse = [ + { name = "nvidia-cusparse-cu12" }, +] +nvrtc = [ + { name = "nvidia-cuda-nvrtc-cu12" }, +] +nvtx = [ + { name = "nvidia-nvtx-cu12" }, +] + +[[package]] +name = "cycler" +version = "0.12.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a9/95/a3dbbb5028f35eafb79008e7522a75244477d2838f38cbb722248dabc2a8/cycler-0.12.1.tar.gz", hash = "sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c", size = 7615, upload-time = "2023-10-07T05:32:18.335Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/05/c19819d5e3d95294a6f5947fb9b9629efb316b96de511b418c53d245aae6/cycler-0.12.1-py3-none-any.whl", hash = "sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30", size = 8321, upload-time = "2023-10-07T05:32:16.783Z" }, +] + +[[package]] +name = "filelock" +version = "4.2.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/aa/8ccff8da9a27e089727fcffd3c5b61708383217e47eb1e1b8af37b1dd166/filelock-4.2.12.tar.gz", hash = "sha256:7e7da24d3ac39268b0f156e56870001de44886318f092f9d851e692f7114d6dd", size = 680837, upload-time = "2026-11-18T01:20:03.951Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/c9/eb6b6528c7edb958d4c24ac47a8b94113d9de36e4cfc6eecd599b1a4f349/filelock-4.2.12-py3-none-any.whl", hash = "sha256:21decfec02f116ed4c954433cdb31f28c3b346b784543177b6d7059da2702ee9", size = 222442, upload-time = "2026-11-18T01:20:02.439Z" }, +] + +[[package]] +name = "flatbuffers" +version = "25.12.19" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e8/2d/d2a548598be01649e2d46231d151a6c56d10b964d94043a335ae56ea2d92/flatbuffers-25.12.19-py2.py3-none-any.whl", hash = "sha256:7634f50c427838bb021c2d66a3d1168e9d199b0607e6329399f04846d42e20b4", size = 26661, upload-time = "2025-12-19T23:16:13.622Z" }, +] + +[[package]] +name = "fonttools" +version = "4.68.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0c/b5/672312ae80ce8b8eb9779c56052a24c8f36652aa7293a1a420553bcf03e5/fonttools-4.68.0.tar.gz", hash = "sha256:73294e233070f71e2b3653b6bd8564af676d57f26d075761fb06d1ab2e4a7a5d", size = 3848583, upload-time = "2026-10-27T16:30:26.451Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/63/f332b2099599b4911786a6f6fd69552fdd5ae6a45cfaffb0c881092f36c8/fonttools-4.68.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:f265c85432c398d86f26add143423924a4747879b2dce001a3ffe0a5fed30638", size = 3143556, upload-time = "2026-10-27T16:28:21.812Z" }, + { url = "https://files.pythonhosted.org/packages/c8/97/68816bb56843e06631ff11517e4fb35fc62d76aec6e29f11df095e7f33c5/fonttools-4.68.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d225096687fc3bac0ebe3357e95b2dd8b0a49d191f016db0771d537ccdd6f47e", size = 2633689, upload-time = "2026-10-27T16:28:23.54Z" }, + { url = "https://files.pythonhosted.org/packages/21/94/b125c7a6d154d17f4f699150ef3abebd9d8ad0f7eddce9dad649a9e5c1d8/fonttools-4.68.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b41e71b2657c9843b2327b4e3c116db1757dc8cd05d978cd47cb5061272d4997", size = 5462605, upload-time = "2026-10-27T16:28:25.774Z" }, + { url = "https://files.pythonhosted.org/packages/7f/58/fe13db71e3f5a020c6875f349806e84f7550f3f24cb3cdbabdd693968b1d/fonttools-4.68.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3edce69ecdefa73ab1041901ca22eefed6ebb93a77bc77e889d940479f25bf7d", size = 5443448, upload-time = "2026-10-27T16:28:27.898Z" }, + { url = "https://files.pythonhosted.org/packages/f1/7f/48236f8c626007670586dd6b0d61ed80323a6b17ead763c881d717525cea/fonttools-4.68.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d8d5674de2b614575f0751671727056af042ac1d61beacb59a298d74282fa492", size = 5399992, upload-time = "2026-10-27T16:28:29.99Z" }, + { url = "https://files.pythonhosted.org/packages/cb/0d/09e9a433430e277e454eace1c4d02c3691a33d5257bd234702a427a9d090/fonttools-4.68.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7ab8097e7e191784974c5608eb95fb31e1243fe3054cb66778ac82558e9b36f8", size = 5563739, upload-time = "2026-10-27T16:28:32.691Z" }, + { url = "https://files.pythonhosted.org/packages/ac/54/6708f4c6742de2d5bf4280d8bde22fb8aef5120328bdc19ca34a9d2e8e8b/fonttools-4.68.0-cp312-cp312-win32.whl", hash = "sha256:1695cd2e1f9768fe3f14d369ce6ef1b3e8561069cc9e47059571985d1ea42614", size = 2481614, upload-time = "2026-10-27T16:28:35.122Z" }, + { url = "https://files.pythonhosted.org/packages/1c/3e/ef786310a3774ae7aacaa288ca6d1e1dfd03c24214137478e4b630b76af0/fonttools-4.68.0-cp312-cp312-win_amd64.whl", hash = "sha256:fedc183bdbc3fdbfbdca26e0e04566d089cbb404712509a4e824608e9304cc77", size = 2533508, upload-time = "2026-10-27T16:28:37.085Z" }, + { url = "https://files.pythonhosted.org/packages/06/11/2cc4272ddd485c448c0363be9beb0a24d3f429f1cc8c5aafa716c508e899/fonttools-4.68.0-cp312-cp312-win_arm64.whl", hash = "sha256:95628bbc5ea81d5761268f4c4f1ba709af510b970f363498ac801c0c1fd7a4a8", size = 2502049, upload-time = "2026-10-27T16:28:39.355Z" }, + { url = "https://files.pythonhosted.org/packages/35/74/4ea331ecc65ba05a58b1e4e8ccd604c8a15565f876dfbf93fc2a2ea2e22b/fonttools-4.68.0-py3-none-any.whl", hash = "sha256:d76f8fdcb6936f5e1045a0c9dd721a4bf11112e60d1e243bfa1d39f06a8b3104", size = 1248357, upload-time = "2026-10-27T16:30:24.389Z" }, +] + +[[package]] +name = "fsspec" +version = "2026.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/77/cd/9be253869fc42e764de7f3dedd6969af7d44ff9c3375214a3442a6f3fc08/fsspec-2026.9.0.tar.gz", hash = "sha256:0f08147951c8cb31d844c3547d631053b127863b60be04cf06e121333ee0e2fe", size = 333545, upload-time = "2026-09-18T17:50:42.825Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/c0/a98505f18594f1bce828bb159cec0fcf9860562f1a2c85913409fc8f3d9e/fsspec-2026.9.0-py3-none-any.whl", hash = "sha256:8dd6e646e99ea382bd85f97a45e6b526a442d79423a7dc673f1e2756d05fcb5f", size = 221738, upload-time = "2026-09-18T17:50:41.341Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960", size = 21209, upload-time = "2026-10-06T22:48:38.076Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7", size = 7552, upload-time = "2026-10-06T22:48:36.959Z" }, +] + +[[package]] +name = "jinja2" +version = "3.1.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload-time = "2025-03-05T20:05:02.478Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" }, +] + +[[package]] +name = "kiwisolver" +version = "1.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ba/07/bd78e6a8fae171ea041ef5bba3ed21a003522fa088834b069b1909981f30/kiwisolver-1.5.1.tar.gz", hash = "sha256:f1303ef2eec81262a4b708c3e858afe58d7c75ad91c1c05266eda7673369859a", size = 104395, upload-time = "2026-08-28T10:28:27.153Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6b/9b/65b302742389c6f96f2956bef5decf26011309feb2fc5d79613af18adea4/kiwisolver-1.5.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:63fb7294b768f444eb4b068965f2662f28c2fd4161e23bd60fcf3ff27b74c046", size = 123876, upload-time = "2026-08-28T10:25:27.44Z" }, + { url = "https://files.pythonhosted.org/packages/71/74/c21f339956f6f691b2ed7e31d5f3ae767304df6c460192739fc830853051/kiwisolver-1.5.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:0ebdef3eae5336568147c39a55be6a2036ffde53faa9ca2d978989ae7c2da12c", size = 66487, upload-time = "2026-08-28T10:25:28.728Z" }, + { url = "https://files.pythonhosted.org/packages/84/e5/bdb34e21523e01dceda064d63713f3bdec91388af24fba1eca7ea5e85864/kiwisolver-1.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1798e83840c3f627246104c4d8a9639c60fa068adf9ce92b61791781fa8a68c1", size = 64660, upload-time = "2026-08-28T10:25:30.071Z" }, + { url = "https://files.pythonhosted.org/packages/fc/f4/dadfec469313c7f428efa7e84b4aba9732f813c13ea7131a24b7b008ef57/kiwisolver-1.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:34633ecf50d16187ab8e5528b7a2530f2feb4e23f300db4672538b51cfc5cd38", size = 1477929, upload-time = "2026-08-28T10:25:31.495Z" }, + { url = "https://files.pythonhosted.org/packages/6f/35/09c58daac34e6f6ea5c6dee0094b422118e5a7c265586008a95fd135ac5f/kiwisolver-1.5.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d27c2123977cb9269c30a49ba45f03a4323017ef693e19db4ec9dbe1299a3002", size = 1278499, upload-time = "2026-08-28T10:25:33.375Z" }, + { url = "https://files.pythonhosted.org/packages/19/32/739765e24fbad29d13f83e546ea4abc215a78cea9d677ca09025b027724d/kiwisolver-1.5.1-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:6a797a1cefc8b9c93170db580337e1fe3d011ad18b1299943231279406342048", size = 1296677, upload-time = "2026-08-28T10:25:35.059Z" }, + { url = "https://files.pythonhosted.org/packages/df/32/03304d1010e2cc45e5b3b52cef7e43fed3a2a5cd6c87a89b4a88e1d85b5d/kiwisolver-1.5.1-cp312-cp312-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2551cf9917af48ee7c4b29cc82320489508cf96fd26a51f6fc124de661cd44c7", size = 1346037, upload-time = "2026-08-28T10:25:36.705Z" }, + { url = "https://files.pythonhosted.org/packages/3e/57/4c49377bfd274450dd72ecaa13eaac32ea804a03363e4d1db0c5aa999ceb/kiwisolver-1.5.1-cp312-cp312-manylinux_2_39_riscv64.whl", hash = "sha256:38f6e0deb4d0a4615efe0c4efc5990b06ae450ab50a0b321c0b078b6d238c083", size = 988248, upload-time = "2026-08-28T10:25:38.299Z" }, + { url = "https://files.pythonhosted.org/packages/cb/c3/38df144a08b6c5d75ca4504e5cc3141bb3bfef64c04f4ef48204f42711b6/kiwisolver-1.5.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bfd1de989b3330420e29de39352f5c049905c9e3ee67233a50d550e3d652c148", size = 2228722, upload-time = "2026-08-28T10:25:40.038Z" }, + { url = "https://files.pythonhosted.org/packages/e7/11/3221838a89cd64d9b386353e000cd8a296069a20fbe3584507fdfd5bebae/kiwisolver-1.5.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:1209042a623ddfda5497e4066c7b77651dde8e1d3a9dd97599dc7e97f3b9b78c", size = 2325216, upload-time = "2026-08-28T10:25:41.699Z" }, + { url = "https://files.pythonhosted.org/packages/83/d4/075c219230697bb5db910d37262b9bacf880f92b4811a02ab81ed073a253/kiwisolver-1.5.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:26e8268480be5061d509e29669d59103c067a26377a56491630ece11762e3858", size = 1977689, upload-time = "2026-08-28T10:25:43.559Z" }, + { url = "https://files.pythonhosted.org/packages/bb/08/1d219c3c2dd960983d0d4da623d916e9de6385df2b0bab3d1af0e9b8fccc/kiwisolver-1.5.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:d79308fa689fac89cbcfbd4dbfc80b5f95c54c5a7fd4d194be221f9d33d026e6", size = 2491443, upload-time = "2026-08-28T10:25:45.242Z" }, + { url = "https://files.pythonhosted.org/packages/ba/d3/024208ec1079d273f1047468d1bdffbf38bb75b7b268090fd3a0301b9d9a/kiwisolver-1.5.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b03af77d77e50edba2030fd5f7c352ff209314b09030a3cba7c14edf9a09a444", size = 2295200, upload-time = "2026-08-28T10:25:46.984Z" }, + { url = "https://files.pythonhosted.org/packages/6e/7c/7b210498f9f92e1cd7855f260fa69ef056881087b199ee20c208f0e4189a/kiwisolver-1.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:06a6917674de9e0fe3f66f5430787f59a9f2ddb64af9b714eaec547e29ef5c19", size = 70748, upload-time = "2026-08-28T10:25:48.444Z" }, + { url = "https://files.pythonhosted.org/packages/94/61/ef0daa157c8bb23672f7423e0d14c39db1dc6ef8ed47e6bc54c9c1bef3bf/kiwisolver-1.5.1-cp312-cp312-win_arm64.whl", hash = "sha256:ad8b9671348d7c8716715652ae11f85ed0eb99e265a2df2ca490577d69860b2c", size = 68324, upload-time = "2026-08-28T10:25:49.81Z" }, + { url = "https://files.pythonhosted.org/packages/a9/c4/1407df7512a5b36cc79840e01710dc575733c461b13ab866cae77eaf87f3/kiwisolver-1.5.1-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:482676e5bd48d70ac99d9fc78863469845421e01184fa83f1f9366dc49f7e974", size = 134002, upload-time = "2026-08-28T10:28:08.881Z" }, + { url = "https://files.pythonhosted.org/packages/16/45/c37a21ad5c0ab581a93c55ad544721aaa1f0ae94edb29c6a678a23d013e6/kiwisolver-1.5.1-graalpy312-graalpy250_312_native-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:072bdb15a3c19a5b5dbc8f8fb1f4e1884bf4f3507eeb4cc6334401274d37a5c0", size = 194292, upload-time = "2026-08-28T10:28:11.06Z" }, + { url = "https://files.pythonhosted.org/packages/a6/c1/69f00d627949580e43d57af0aa465df46868d7c29801c137a55374101294/kiwisolver-1.5.1-graalpy312-graalpy250_312_native-win_amd64.whl", hash = "sha256:a5a00665d1a0e26763a7338d7e911d4598fbc1d50dd0d6b7919b7dc6c5d6569f", size = 73362, upload-time = "2026-08-28T10:28:12.449Z" }, +] + +[[package]] +name = "markupsafe" +version = "3.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/38/9b/e422a865e1d5d57d0e509b4e0bf1c1a70a7f6382c29a5aa428df994c8bc8/markupsafe-3.0.4.tar.gz", hash = "sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6", size = 153777, upload-time = "2026-10-02T23:07:22.29Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/09/4c59d56b8461ae8eb0d8ba34bb25b7e618547044679d58a82ef9b2479fc1/markupsafe-3.0.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6", size = 11658, upload-time = "2026-10-02T23:04:51.876Z" }, + { url = "https://files.pythonhosted.org/packages/a2/f0/d6613774d86fbf6d145751d43c59875e47a6f9f17daee0aef173bd36d90e/markupsafe-3.0.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f", size = 12050, upload-time = "2026-10-02T23:04:52.931Z" }, + { url = "https://files.pythonhosted.org/packages/0d/f2/8f18e0b806eb13c1f8d07d917a720831ead54253a6dec011fbc78098a6f8/markupsafe-3.0.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b", size = 24363, upload-time = "2026-10-02T23:04:53.895Z" }, + { url = "https://files.pythonhosted.org/packages/60/ce/fa07dbe8a5675558fa36dea033e19995bc783de2dec5f540ccb9030b06aa/markupsafe-3.0.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df", size = 28525, upload-time = "2026-10-02T23:04:54.905Z" }, + { url = "https://files.pythonhosted.org/packages/85/40/be87c01f3868ec217f8a2015089d71c22c8c5a75324822e5ed1cdd87210d/markupsafe-3.0.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c", size = 24733, upload-time = "2026-10-02T23:04:56.229Z" }, + { url = "https://files.pythonhosted.org/packages/4f/a7/aeedb5140afa41fc74c225e9184ab96723a6e873b6ee1c9fede7283456d8/markupsafe-3.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581", size = 22985, upload-time = "2026-10-02T23:04:57.521Z" }, + { url = "https://files.pythonhosted.org/packages/c3/fc/e91352bb08c6a59da3ef0909d457bf95a5f5908fbf151b30a06d9dbcfbb4/markupsafe-3.0.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77", size = 22001, upload-time = "2026-10-02T23:04:58.597Z" }, + { url = "https://files.pythonhosted.org/packages/5d/f8/bffee5e7d2a3deb59748a797650a48af7e672025cf641a79344a771ad106/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c", size = 23793, upload-time = "2026-10-02T23:04:59.686Z" }, + { url = "https://files.pythonhosted.org/packages/ed/59/b853d6628ecb4d658e1d637224846d5e9bb4adf4f8df97f3be9f29dce2ec/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749", size = 22640, upload-time = "2026-10-02T23:05:00.768Z" }, + { url = "https://files.pythonhosted.org/packages/09/b2/1506df394f0f075797c418d0301498f49e43be194e3ffcb49e6fe6ccf022/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed", size = 24074, upload-time = "2026-10-02T23:05:01.813Z" }, + { url = "https://files.pythonhosted.org/packages/c7/81/5ed69cda630ac69ef60d06c09ba5a7f84ff66a2e28cf986fd5614ab3c6e6/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786", size = 21563, upload-time = "2026-10-02T23:05:03.239Z" }, + { url = "https://files.pythonhosted.org/packages/0c/fe/fb1e79be0fea60aa32602ebefc9c35a82bb42b4df157285ab7dfec12341a/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e", size = 23048, upload-time = "2026-10-02T23:05:04.479Z" }, + { url = "https://files.pythonhosted.org/packages/c8/52/7632a53360671a9b750cdbabaf9cdd89f18b42248b8e4cb42c0b0296e459/markupsafe-3.0.4-cp312-cp312-win32.whl", hash = "sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237", size = 14108, upload-time = "2026-10-02T23:05:05.513Z" }, + { url = "https://files.pythonhosted.org/packages/3f/bf/62495e180b7000aaf30000fff849e933f74264638057176cf46852500adc/markupsafe-3.0.4-cp312-cp312-win_amd64.whl", hash = "sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7", size = 14303, upload-time = "2026-10-02T23:05:06.538Z" }, + { url = "https://files.pythonhosted.org/packages/c5/8e/4c24208776a65878d656996945aacfbfe010d3720d1a98fc0eb8491fc03b/markupsafe-3.0.4-cp312-cp312-win_arm64.whl", hash = "sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9", size = 14174, upload-time = "2026-10-02T23:05:07.617Z" }, +] + +[[package]] +name = "matplotlib" +version = "3.11.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "contourpy" }, + { name = "cycler" }, + { name = "fonttools" }, + { name = "kiwisolver" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "pillow" }, + { name = "pyparsing" }, + { name = "python-dateutil" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e7/c8/9aa712a0afb882649424dd8de8ad9aa6235e796e84c6052e8f6dc1598d0d/matplotlib-3.11.2.tar.gz", hash = "sha256:cec596316640f2b394b8f0daa0ea61a8eae82d017b620b9f202befb972a59ea4", size = 32660610, upload-time = "2026-09-11T19:05:31.214Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/ce/1bfcc4873b121597791ad74032943b123218c0613af0b97e8dd05e916fb1/matplotlib-3.11.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ef752769cd962f39ea0b6ffc82d1ea43a0012c5a6157c7a075212fa509cfcff2", size = 9476466, upload-time = "2026-09-11T19:03:19.45Z" }, + { url = "https://files.pythonhosted.org/packages/a6/c4/7f5f3601ee69baf072c0c7d3ce60c03e0618621c5a56c34a62a460e29d11/matplotlib-3.11.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ef31985c4dedb5f1424e1aec6849a47dd37689cb7fa3c20b1b82187f26806261", size = 9305583, upload-time = "2026-09-11T19:03:22.39Z" }, + { url = "https://files.pythonhosted.org/packages/b8/90/2b3fd67ee273163faeda6d514be70b5596eaa0fd77b60ffc294ad0b34f5f/matplotlib-3.11.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:df4f7784aca81a94f254c0a2767d592ee25f407e488f5fa7203e51093fb6ca27", size = 9860353, upload-time = "2026-09-11T19:03:25.049Z" }, + { url = "https://files.pythonhosted.org/packages/f4/84/32549e7a462dc311aed2ab62e5d2538028840b5c53a8be0195c789937c3d/matplotlib-3.11.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b9a7ad579856284135e401ecc918c5f8a017ee30539298862a109f51b971710", size = 10670348, upload-time = "2026-09-11T19:03:28.108Z" }, + { url = "https://files.pythonhosted.org/packages/84/39/02e21b74f7439bd643d717ea846006d46e309e6d29b632b57751265311d6/matplotlib-3.11.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3aa4b8516fd26659e4363abbf317c703d9116496c5db2e9d0609a2866dd39dd2", size = 10810580, upload-time = "2026-09-11T19:03:31.402Z" }, + { url = "https://files.pythonhosted.org/packages/04/93/0d239bde12b308262265c2d98909b2f0ecad2b5deeae96241642e822e9c7/matplotlib-3.11.2-cp312-cp312-win_amd64.whl", hash = "sha256:c5c1c68ee401fc98271263410f0e5ce88285abacf7627132914e8adf3d70ff43", size = 9349409, upload-time = "2026-09-11T19:03:34.195Z" }, + { url = "https://files.pythonhosted.org/packages/49/a8/06baf901c02246c8a222b655cc4540ef9c15e1549a04e07927f9cde716c3/matplotlib-3.11.2-cp312-cp312-win_arm64.whl", hash = "sha256:643ff850d8e0f5b8319337f87ed3cb59506afb3df3cc48de777d85871233be7b", size = 9028084, upload-time = "2026-09-11T19:03:37.032Z" }, +] + +[[package]] +name = "ml-dtypes" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bc/2d/4ce5532f433dfae6dc96ed4abd7a0e18106a63666bce8eb878d9ffdc0610/ml_dtypes-0.7.0.tar.gz", hash = "sha256:67fd890fb09d1e068cfe1b4dc8e204430ae7632102b4a4f854b093b6f02b3950", size = 4353024, upload-time = "2026-11-16T16:21:26.657Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/e4/5c1579cfac55dab603df1870be84fc270df32c1e81b96314976bf5814b26/ml_dtypes-0.7.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3cfe29fc79a00f4555c5319a32c549c10ec075ec888974ab4c0a59598e1f0f48", size = 738779, upload-time = "2026-11-16T16:20:39.543Z" }, + { url = "https://files.pythonhosted.org/packages/9b/7c/39dd1b5b4458ea1c6d52f5161d92e78e723c05a33c172359dd420ca388be/ml_dtypes-0.7.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7366e3ac8630e2bb35e67945391889225e2221c581c0831ec01a8cf50de3461a", size = 436741, upload-time = "2026-11-16T16:20:41.443Z" }, + { url = "https://files.pythonhosted.org/packages/98/cc/d6949ae90ff708e8b9f1889f4e6bdb74c31b2603fa29936a97b52dd784fa/ml_dtypes-0.7.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3c4e47f553a04d33886160a9600e2313e5bee8c1c3da997baa23c8fecbfab189", size = 463670, upload-time = "2026-11-16T16:20:42.875Z" }, + { url = "https://files.pythonhosted.org/packages/60/21/3ca0cb91c528d6250d356e62645d868dc3276cb701cc194a2ae40ca99a83/ml_dtypes-0.7.0-cp312-cp312-win_amd64.whl", hash = "sha256:0b1d09c91aaa6f38052521d5377cecb1523f50d4aee7783183a955a6544b8ad6", size = 463335, upload-time = "2026-11-16T16:20:44.317Z" }, + { url = "https://files.pythonhosted.org/packages/61/e0/6d97837f234b658a4f553b59b95e24799a4bd8e544e536435d8e85e0f005/ml_dtypes-0.7.0-cp312-cp312-win_arm64.whl", hash = "sha256:b29d506d51d994efce5e1f214a6cab77d96b796c5ab59a63f23d9a8c5b20e4dd", size = 587991, upload-time = "2026-11-16T16:20:45.95Z" }, +] + +[[package]] +name = "mpmath" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e0/47/dd32fa426cc72114383ac549964eecb20ecfd886d1e5ccf5340b55b02f57/mpmath-1.3.0.tar.gz", hash = "sha256:7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f", size = 508106, upload-time = "2023-03-07T16:47:11.061Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" }, +] + +[[package]] +name = "networkx" +version = "3.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/dc/76/3af777226b63a5e64a6b36b1ec5855c14e2b94a37096d4760e595fc43511/networkx-3.7.tar.gz", hash = "sha256:fd77a511bd90f39f3d016351345b52cf5319b813bdca01de3f755d3cca62e96a", size = 1866482, upload-time = "2026-09-21T16:45:16.974Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/cd/fe58041e9011f307c490e3e17dd48cc516448f7c698a3f2d9d9d65d7e6a8/networkx-3.7-py3-none-any.whl", hash = "sha256:e3fd2c13a7814cee3746340d8d7f8598a67f16a58bf47fb7f8793fab6efca1b0", size = 2142205, upload-time = "2026-09-21T16:45:14.609Z" }, +] + +[[package]] +name = "numpy" +version = "2.5.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4e/3a/8770c288c47f0b5c2a786d3c20e79f66fd245f2d42cd232d7cd5e00e83e5/numpy-2.5.5.tar.gz", hash = "sha256:5cddc243c75114ba845f01b1f87aca1572dbf7b6c2d88636ed3e1d2bccd7f1bf", size = 20873892, upload-time = "2026-11-15T21:32:28.607Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/74/5b99f425938870958d43dc9f7b17c684e793ce47ec46b7885cdc7acea285/numpy-2.5.5-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7da9a248f149cfbb220c6da964a59c8d051d516704f7758acfb81eb382a05d97", size = 14750374, upload-time = "2026-11-15T21:30:10.113Z" }, + { url = "https://files.pythonhosted.org/packages/5c/f4/06db317e93dd6d618786004c1761214b113832bb77294c8513776956702a/numpy-2.5.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b96e9ee49ccbdb5676359f852a4497f7a9c5df6c377d8877f5330d6fd3ff42e4", size = 10749920, upload-time = "2026-11-15T21:30:13.092Z" }, + { url = "https://files.pythonhosted.org/packages/8a/92/6de34324a266b73c04ba977db5864b9016500076b26f09078a565f527d34/numpy-2.5.5-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:a3856a97e48ed8371c680fb04120b99fbcc29f2076ebe6dc3deb34f77947c5ca", size = 5513680, upload-time = "2026-11-15T21:30:15.201Z" }, + { url = "https://files.pythonhosted.org/packages/1e/a1/6563b74cd67e3873f9897afebb3244529b1494d4c0df30f3201329a7e316/numpy-2.5.5-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:f5e8603f0892d1b848e12124863b5b29af72383ee9b25ddc6fe4967d4c1ee6ef", size = 6797540, upload-time = "2026-11-15T21:30:17.172Z" }, + { url = "https://files.pythonhosted.org/packages/c2/22/82184e9a5b50a4a298e9f8fe0bd8cfc483672dbfea8a3b57c78e2376b139/numpy-2.5.5-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a0750f2156d53446caca85663d0b65d67214e1664b9050454a731ea1418d176a", size = 15284117, upload-time = "2026-11-15T21:30:19.167Z" }, + { url = "https://files.pythonhosted.org/packages/99/61/522b973ba38987b22a4a71beaed2ea6ac9fd4f687baaa2bc9a45100625e0/numpy-2.5.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:704d819265e5d1064d932968e9ee85fff2103ccc78c05b878c06943ba27b8507", size = 15720599, upload-time = "2026-11-15T21:30:21.273Z" }, + { url = "https://files.pythonhosted.org/packages/25/cd/182cf60bd9c34e617c516f138f2f68988760062fa65fca8fcc97875cf7cf/numpy-2.5.5-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:86868185bf4b6c4e5a8628ac42cfa165cd9530266c731f7dd1d11b4ad7e7cd1c", size = 16503566, upload-time = "2026-11-15T21:30:24.023Z" }, + { url = "https://files.pythonhosted.org/packages/f3/57/4fa4723e80be805f68af552731ed483974b2a11e511284a9ef6aafbcb3cf/numpy-2.5.5-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7fb87c4bcc73850ef433a0c42f096b010d3d3d284e9d00028bb030b43df3d078", size = 17082560, upload-time = "2026-11-15T21:30:26.224Z" }, + { url = "https://files.pythonhosted.org/packages/d5/0b/73d2bd5be85d3178a862e8354e2d6441b4040fadf1e7d999e01b0bdfa5c6/numpy-2.5.5-cp312-cp312-win32.whl", hash = "sha256:263b2aa236d752b18f90c5107137d24b2e3856d7db37725609f0ab5bcdb58881", size = 6146378, upload-time = "2026-11-15T21:30:28.328Z" }, + { url = "https://files.pythonhosted.org/packages/d1/71/b1ce51834c21020d189332979d38ba7350eb6cd7ca8c8ec424a663b0ca6f/numpy-2.5.5-cp312-cp312-win_amd64.whl", hash = "sha256:919eb420662b0b4ba34889df503f3d5329775b0c1d5f7e5f5af4fba8315b1e30", size = 12580189, upload-time = "2026-11-15T21:30:30.025Z" }, + { url = "https://files.pythonhosted.org/packages/c2/5e/09ae9d0d02fbfe6b160043349bbe73e6bbbbfb2565bb46146dd943687271/numpy-2.5.5-cp312-cp312-win_arm64.whl", hash = "sha256:f6622e32cb46c60bee3b2c7dd7f5c22bdc86fcb8630336b4822ec81c3986111a", size = 10535386, upload-time = "2026-11-15T21:30:32.112Z" }, +] + +[[package]] +name = "nvidia-cublas-cu12" +version = "12.6.4.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/eb/ff4b8c503fa1f1796679dce648854d58751982426e4e4b37d6fce49d259c/nvidia_cublas_cu12-12.6.4.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:08ed2686e9875d01b58e3cb379c6896df8e76c75e0d4a7f7dace3d7b6d9ef8eb", size = 393138322, upload-time = "2024-11-20T17:40:25.65Z" }, + { url = "https://files.pythonhosted.org/packages/97/0d/f1f0cadbf69d5b9ef2e4f744c9466cb0a850741d08350736dfdb4aa89569/nvidia_cublas_cu12-12.6.4.1-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:235f728d6e2a409eddf1df58d5b0921cf80cfa9e72b9f2775ccb7b4a87984668", size = 390794615, upload-time = "2024-11-20T17:39:52.715Z" }, +] + +[[package]] +name = "nvidia-cuda-cupti-cu12" +version = "12.6.80" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/8b/2f6230cb715646c3a9425636e513227ce5c93c4d65823a734f4bb86d43c3/nvidia_cuda_cupti_cu12-12.6.80-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:166ee35a3ff1587f2490364f90eeeb8da06cd867bd5b701bf7f9a02b78bc63fc", size = 8236764, upload-time = "2024-11-20T17:35:41.03Z" }, + { url = "https://files.pythonhosted.org/packages/25/0f/acb326ac8fd26e13c799e0b4f3b2751543e1834f04d62e729485872198d4/nvidia_cuda_cupti_cu12-12.6.80-py3-none-manylinux2014_aarch64.whl", hash = "sha256:358b4a1d35370353d52e12f0a7d1769fc01ff74a191689d3870b2123156184c4", size = 8236756, upload-time = "2024-10-01T16:57:45.507Z" }, + { url = "https://files.pythonhosted.org/packages/49/60/7b6497946d74bcf1de852a21824d63baad12cd417db4195fc1bfe59db953/nvidia_cuda_cupti_cu12-12.6.80-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:6768bad6cab4f19e8292125e5f1ac8aa7d1718704012a0e3272a6f61c4bce132", size = 8917980, upload-time = "2024-11-20T17:36:04.019Z" }, + { url = "https://files.pythonhosted.org/packages/a5/24/120ee57b218d9952c379d1e026c4479c9ece9997a4fb46303611ee48f038/nvidia_cuda_cupti_cu12-12.6.80-py3-none-manylinux2014_x86_64.whl", hash = "sha256:a3eff6cdfcc6a4c35db968a06fcadb061cbc7d6dde548609a941ff8701b98b73", size = 8917972, upload-time = "2024-10-01T16:58:06.036Z" }, +] + +[[package]] +name = "nvidia-cuda-nvrtc-cu12" +version = "12.6.85" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f5/31/ffb400c5ae99daf09687aa6c42831c5d824f71c4851363ed2a4a1ac52bab/nvidia_cuda_nvrtc_cu12-12.6.85-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:800927308ccc5dd6246d3f61f7fcef2ed7ec4e59e199090d360d3293f78bd5a2", size = 23649944, upload-time = "2024-11-20T17:38:06.511Z" }, + { url = "https://files.pythonhosted.org/packages/48/ab/476146f59ff5ef5bd6e62c187097d859ea78b5752d19c6c3f9be5f90dafc/nvidia_cuda_nvrtc_cu12-12.6.85-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:3f3134f50963882373063901657554f230bedf6039d30b09f6be55c64c993a37", size = 23162872, upload-time = "2024-11-20T17:37:42.967Z" }, +] + +[[package]] +name = "nvidia-cuda-runtime-cu12" +version = "12.6.77" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8f/ea/590b2ac00d772a8abd1c387a92b46486d2679ca6622fd25c18ff76265663/nvidia_cuda_runtime_cu12-12.6.77-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6116fad3e049e04791c0256a9778c16237837c08b27ed8c8401e2e45de8d60cd", size = 908052, upload-time = "2024-11-20T17:35:19.905Z" }, + { url = "https://files.pythonhosted.org/packages/b7/3d/159023799677126e20c8fd580cca09eeb28d5c5a624adc7f793b9aa8bbfa/nvidia_cuda_runtime_cu12-12.6.77-py3-none-manylinux2014_aarch64.whl", hash = "sha256:d461264ecb429c84c8879a7153499ddc7b19b5f8d84c204307491989a365588e", size = 908040, upload-time = "2024-10-01T16:57:22.221Z" }, + { url = "https://files.pythonhosted.org/packages/e1/23/e717c5ac26d26cf39a27fbc076240fad2e3b817e5889d671b67f4f9f49c5/nvidia_cuda_runtime_cu12-12.6.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ba3b56a4f896141e25e19ab287cd71e52a6a0f4b29d0d31609f60e3b4d5219b7", size = 897690, upload-time = "2024-11-20T17:35:30.697Z" }, + { url = "https://files.pythonhosted.org/packages/f0/62/65c05e161eeddbafeca24dc461f47de550d9fa8a7e04eb213e32b55cfd99/nvidia_cuda_runtime_cu12-12.6.77-py3-none-manylinux2014_x86_64.whl", hash = "sha256:a84d15d5e1da416dd4774cb42edf5e954a3e60cc945698dc1d5be02321c44dc8", size = 897678, upload-time = "2024-10-01T16:57:33.821Z" }, +] + +[[package]] +name = "nvidia-cudnn-cu12" +version = "9.10.2.21" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-cublas-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/41/e79269ce215c857c935fd86bcfe91a451a584dfc27f1e068f568b9ad1ab7/nvidia_cudnn_cu12-9.10.2.21-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:c9132cc3f8958447b4910a1720036d9eff5928cc3179b0a51fb6d167c6cc87d8", size = 705026878, upload-time = "2025-06-06T21:52:51.348Z" }, + { url = "https://files.pythonhosted.org/packages/ba/51/e123d997aa098c61d029f76663dedbfb9bc8dcf8c60cbd6adbe42f76d049/nvidia_cudnn_cu12-9.10.2.21-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:949452be657fa16687d0930933f032835951ef0892b37d2d53824d1a84dc97a8", size = 706758467, upload-time = "2025-06-06T21:54:08.597Z" }, +] + +[[package]] +name = "nvidia-cufft-cu12" +version = "11.3.0.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/1f/37/c50d2b2f2c07e146776389e3080f4faf70bcc4fa6e19d65bb54ca174ebc3/nvidia_cufft_cu12-11.3.0.4-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d16079550df460376455cba121db6564089176d9bac9e4f360493ca4741b22a6", size = 200164144, upload-time = "2024-11-20T17:40:58.288Z" }, + { url = "https://files.pythonhosted.org/packages/ce/f5/188566814b7339e893f8d210d3a5332352b1409815908dad6a363dcceac1/nvidia_cufft_cu12-11.3.0.4-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8510990de9f96c803a051822618d42bf6cb8f069ff3f48d93a8486efdacb48fb", size = 200164135, upload-time = "2024-10-01T17:03:24.212Z" }, + { url = "https://files.pythonhosted.org/packages/8f/16/73727675941ab8e6ffd86ca3a4b7b47065edcca7a997920b831f8147c99d/nvidia_cufft_cu12-11.3.0.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ccba62eb9cef5559abd5e0d54ceed2d9934030f51163df018532142a8ec533e5", size = 200221632, upload-time = "2024-11-20T17:41:32.357Z" }, + { url = "https://files.pythonhosted.org/packages/60/de/99ec247a07ea40c969d904fc14f3a356b3e2a704121675b75c366b694ee1/nvidia_cufft_cu12-11.3.0.4-py3-none-manylinux2014_x86_64.whl", hash = "sha256:768160ac89f6f7b459bee747e8d175dbf53619cfe74b2a5636264163138013ca", size = 200221622, upload-time = "2024-10-01T17:03:58.79Z" }, +] + +[[package]] +name = "nvidia-cufile-cu12" +version = "1.11.1.6" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b2/66/cc9876340ac68ae71b15c743ddb13f8b30d5244af344ec8322b449e35426/nvidia_cufile_cu12-1.11.1.6-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:cc23469d1c7e52ce6c1d55253273d32c565dd22068647f3aa59b3c6b005bf159", size = 1142103, upload-time = "2024-11-20T17:42:11.83Z" }, + { url = "https://files.pythonhosted.org/packages/17/bf/cc834147263b929229ce4aadd62869f0b195e98569d4c28b23edc72b85d9/nvidia_cufile_cu12-1.11.1.6-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:8f57a0051dcf2543f6dc2b98a98cb2719c37d3cee1baba8965d57f3bbc90d4db", size = 1066155, upload-time = "2024-11-20T17:41:49.376Z" }, +] + +[[package]] +name = "nvidia-curand-cu12" +version = "10.3.7.77" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/42/ac/36543605358a355632f1a6faa3e2d5dfb91eab1e4bc7d552040e0383c335/nvidia_curand_cu12-10.3.7.77-py3-none-manylinux2014_aarch64.whl", hash = "sha256:6e82df077060ea28e37f48a3ec442a8f47690c7499bff392a5938614b56c98d8", size = 56289881, upload-time = "2024-10-01T17:04:18.981Z" }, + { url = "https://files.pythonhosted.org/packages/73/1b/44a01c4e70933637c93e6e1a8063d1e998b50213a6b65ac5a9169c47e98e/nvidia_curand_cu12-10.3.7.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a42cd1344297f70b9e39a1e4f467a4e1c10f1da54ff7a85c12197f6c652c8bdf", size = 56279010, upload-time = "2024-11-20T17:42:50.958Z" }, + { url = "https://files.pythonhosted.org/packages/4a/aa/2c7ff0b5ee02eaef890c0ce7d4f74bc30901871c5e45dee1ae6d0083cd80/nvidia_curand_cu12-10.3.7.77-py3-none-manylinux2014_x86_64.whl", hash = "sha256:99f1a32f1ac2bd134897fc7a203f779303261268a65762a623bf30cc9fe79117", size = 56279000, upload-time = "2024-10-01T17:04:45.274Z" }, + { url = "https://files.pythonhosted.org/packages/a6/02/5362a9396f23f7de1dd8a64369e87c85ffff8216fc8194ace0fa45ba27a5/nvidia_curand_cu12-10.3.7.77-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:7b2ed8e95595c3591d984ea3603dd66fe6ce6812b886d59049988a712ed06b6e", size = 56289882, upload-time = "2024-11-20T17:42:25.222Z" }, +] + +[[package]] +name = "nvidia-cusolver-cu12" +version = "11.7.1.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-cublas-cu12" }, + { name = "nvidia-cusparse-cu12" }, + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/93/17/dbe1aa865e4fdc7b6d4d0dd308fdd5aaab60f939abfc0ea1954eac4fb113/nvidia_cusolver_cu12-11.7.1.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:0ce237ef60acde1efc457335a2ddadfd7610b892d94efee7b776c64bb1cac9e0", size = 157833628, upload-time = "2024-10-01T17:05:05.591Z" }, + { url = "https://files.pythonhosted.org/packages/f0/6e/c2cf12c9ff8b872e92b4a5740701e51ff17689c4d726fca91875b07f655d/nvidia_cusolver_cu12-11.7.1.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e9e49843a7707e42022babb9bcfa33c29857a93b88020c4e4434656a655b698c", size = 158229790, upload-time = "2024-11-20T17:43:43.211Z" }, + { url = "https://files.pythonhosted.org/packages/9f/81/baba53585da791d043c10084cf9553e074548408e04ae884cfe9193bd484/nvidia_cusolver_cu12-11.7.1.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:6cf28f17f64107a0c4d7802be5ff5537b2130bfc112f25d5a30df227058ca0e6", size = 158229780, upload-time = "2024-10-01T17:05:39.875Z" }, + { url = "https://files.pythonhosted.org/packages/7c/5f/07d0ba3b7f19be5a5ec32a8679fc9384cfd9fc6c869825e93be9f28d6690/nvidia_cusolver_cu12-11.7.1.2-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:dbbe4fc38ec1289c7e5230e16248365e375c3673c9c8bac5796e2e20db07f56e", size = 157833630, upload-time = "2024-11-20T17:43:16.77Z" }, +] + +[[package]] +name = "nvidia-cusparse-cu12" +version = "12.5.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nvidia-nvjitlink-cu12" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/eb/eb/6681efd0aa7df96b4f8067b3ce7246833dd36830bb4cec8896182773db7d/nvidia_cusparse_cu12-12.5.4.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d25b62fb18751758fe3c93a4a08eff08effedfe4edf1c6bb5afd0890fe88f887", size = 216451147, upload-time = "2024-11-20T17:44:18.055Z" }, + { url = "https://files.pythonhosted.org/packages/d3/56/3af21e43014eb40134dea004e8d0f1ef19d9596a39e4d497d5a7de01669f/nvidia_cusparse_cu12-12.5.4.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:7aa32fa5470cf754f72d1116c7cbc300b4e638d3ae5304cfa4a638a5b87161b1", size = 216451135, upload-time = "2024-10-01T17:06:03.826Z" }, + { url = "https://files.pythonhosted.org/packages/06/1e/b8b7c2f4099a37b96af5c9bb158632ea9e5d9d27d7391d7eb8fc45236674/nvidia_cusparse_cu12-12.5.4.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:7556d9eca156e18184b94947ade0fba5bb47d69cec46bf8660fd2c71a4b48b73", size = 216561367, upload-time = "2024-11-20T17:44:54.824Z" }, + { url = "https://files.pythonhosted.org/packages/43/ac/64c4316ba163e8217a99680c7605f779accffc6a4bcd0c778c12948d3707/nvidia_cusparse_cu12-12.5.4.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:23749a6571191a215cb74d1cdbff4a86e7b19f1200c071b3fcf844a5bea23a2f", size = 216561357, upload-time = "2024-10-01T17:06:29.861Z" }, +] + +[[package]] +name = "nvidia-cusparselt-cu12" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/73/b9/598f6ff36faaece4b3c50d26f50e38661499ff34346f00e057760b35cc9d/nvidia_cusparselt_cu12-0.7.1-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8878dce784d0fac90131b6817b607e803c36e629ba34dc5b433471382196b6a5", size = 283835557, upload-time = "2025-02-26T00:16:54.265Z" }, + { url = "https://files.pythonhosted.org/packages/56/79/12978b96bd44274fe38b5dde5cfb660b1d114f70a65ef962bcbbed99b549/nvidia_cusparselt_cu12-0.7.1-py3-none-manylinux2014_x86_64.whl", hash = "sha256:f1bb701d6b930d5a7cea44c19ceb973311500847f81b634d802b7b539dc55623", size = 287193691, upload-time = "2025-02-26T00:15:44.104Z" }, +] + +[[package]] +name = "nvidia-nccl-cu12" +version = "2.29.3" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/28/cf/bcf8bb0c0030b1b9a345331f6281c37d2a8669758521eb93c382f6f87c8f/nvidia_nccl_cu12-2.29.3-py3-none-manylinux_2_18_aarch64.whl", hash = "sha256:6351b79dc7d2cc3d654ea1523616b9eeded71fe9c8da66b71eef9a5d1b2adad4", size = 289708535, upload-time = "2026-02-03T21:10:58.804Z" }, + { url = "https://files.pythonhosted.org/packages/31/5a/cac7d231f322b66caa16fd4b136ebc8e4b18b2805811c2d58dc47210cdea/nvidia_nccl_cu12-2.29.3-py3-none-manylinux_2_18_x86_64.whl", hash = "sha256:35ad42e7d5d722a83c36a3a478e281c20a5646383deaf1b9ed1a9ab7d61bed53", size = 289760316, upload-time = "2026-02-03T21:11:37.899Z" }, +] + +[[package]] +name = "nvidia-nvjitlink-cu12" +version = "12.9.86" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/46/0c/c75bbfb967457a0b7670b8ad267bfc4fffdf341c074e0a80db06c24ccfd4/nvidia_nvjitlink_cu12-12.9.86-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:e3f1171dbdc83c5932a45f0f4c99180a70de9bd2718c1ab77d14104f6d7147f9", size = 39748338, upload-time = "2025-06-05T20:10:25.613Z" }, + { url = "https://files.pythonhosted.org/packages/97/bc/2dcba8e70cf3115b400fef54f213bcd6715a3195eba000f8330f11e40c45/nvidia_nvjitlink_cu12-12.9.86-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:994a05ef08ef4b0b299829cde613a424382aff7efb08a7172c1fa616cc3af2ca", size = 39514880, upload-time = "2025-06-05T20:10:04.89Z" }, +] + +[[package]] +name = "nvidia-nvshmem-cu12" +version = "3.4.5" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/6a/03aa43cc9bd3ad91553a88b5f6fb25ed6a3752ae86ce2180221962bc2aa5/nvidia_nvshmem_cu12-3.4.5-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b48363fc6964dede448029434c6abed6c5e37f823cb43c3bcde7ecfc0457e15", size = 138936938, upload-time = "2025-09-06T00:32:05.589Z" }, + { url = "https://files.pythonhosted.org/packages/b5/09/6ea3ea725f82e1e76684f0708bbedd871fc96da89945adeba65c3835a64c/nvidia_nvshmem_cu12-3.4.5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:042f2500f24c021db8a06c5eec2539027d57460e1c1a762055a6554f72c369bd", size = 139103095, upload-time = "2025-09-06T00:32:31.266Z" }, +] + +[[package]] +name = "nvidia-nvtx-cu12" +version = "12.6.77" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b9/93/80f8a520375af9d7ee44571a6544653a176e53c2b8ccce85b97b83c2491b/nvidia_nvtx_cu12-12.6.77-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:f44f8d86bb7d5629988d61c8d3ae61dddb2015dee142740536bc7481b022fe4b", size = 90549, upload-time = "2024-11-20T17:38:17.387Z" }, + { url = "https://files.pythonhosted.org/packages/2b/53/36e2fd6c7068997169b49ffc8c12d5af5e5ff209df6e1a2c4d373b3a638f/nvidia_nvtx_cu12-12.6.77-py3-none-manylinux2014_aarch64.whl", hash = "sha256:adcaabb9d436c9761fca2b13959a2d237c5f9fd406c8e4b723c695409ff88059", size = 90539, upload-time = "2024-10-01T17:00:27.179Z" }, + { url = "https://files.pythonhosted.org/packages/56/9a/fff8376f8e3d084cd1530e1ef7b879bb7d6d265620c95c1b322725c694f4/nvidia_nvtx_cu12-12.6.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b90bed3df379fa79afbd21be8e04a0314336b8ae16768b58f2d34cb1d04cd7d2", size = 89276, upload-time = "2024-11-20T17:38:27.621Z" }, + { url = "https://files.pythonhosted.org/packages/9e/4e/0d0c945463719429b7bd21dece907ad0bde437a2ff12b9b12fee94722ab0/nvidia_nvtx_cu12-12.6.77-py3-none-manylinux2014_x86_64.whl", hash = "sha256:6574241a3ec5fdc9334353ab8c479fe75841dbe8f4532a8fc97ce63503330ba1", size = 89265, upload-time = "2024-10-01T17:00:38.172Z" }, +] + +[[package]] +name = "onnx" +version = "1.23.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ml-dtypes" }, + { name = "numpy" }, + { name = "protobuf" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3f/62/bc2dfadb63ecf04cb2d65a6b17751863039d36c65de51d6a3128ab35f1e7/onnx-1.23.2.tar.gz", hash = "sha256:008cb0467b2bbee41448acc7da8b6f4e704624cb0d327a2d5adafc7ce19bc5b8", size = 6023090, upload-time = "2026-10-06T04:25:58.681Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d7/d9/967d6f6838ad60964de912a5e7d01915282899b254460705d952f5d14c1a/onnx-1.23.2-cp312-abi3-macosx_13_0_universal2.whl", hash = "sha256:1b8680ce1e6a9a4736374a9dce4de14ea8ee05e0dccf0784a78a6e5646bdc1f6", size = 9725612, upload-time = "2026-10-06T04:25:34.299Z" }, + { url = "https://files.pythonhosted.org/packages/f9/50/2e156ef2cae1c9f4ff01a41dffa43fc1eb7b969755055436bf6df1805d54/onnx-1.23.2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a203efdbaabbbe8f25e854e2b2921382d6fcf4c67895656f939044b0632974e8", size = 8640515, upload-time = "2026-10-06T04:25:36.727Z" }, + { url = "https://files.pythonhosted.org/packages/87/56/21509a657f9a73ab0ca307d325043f49ca6c4ff6bf79edeb9e159190d44d/onnx-1.23.2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7abf381d278f31ac62487fddedc9dd42da842dce94d5d43536836ee3efdf4a2b", size = 8881633, upload-time = "2026-10-06T04:25:38.868Z" }, + { url = "https://files.pythonhosted.org/packages/ec/ef/0a69093ffa0b999747b373c75d07182a812722a0e595d21f763a8d406260/onnx-1.23.2-cp312-abi3-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e79e35e152d3095c6910ae81013bbc68679e32bfc0ca76f840968d4b6fdfb864", size = 7314844, upload-time = "2026-10-06T04:25:41.088Z" }, + { url = "https://files.pythonhosted.org/packages/97/a3/e4d4aedd0cc6820de416bb99623fc12b9a22a387d00596bb98505de9a805/onnx-1.23.2-cp312-abi3-win32.whl", hash = "sha256:b0b8dae0d33dd8606370bc264b0b1d6e64cfdf8b83d7c676fab8eff6b88ca409", size = 7736405, upload-time = "2026-10-06T04:25:42.893Z" }, + { url = "https://files.pythonhosted.org/packages/38/ce/102fd4a0b2a6d111a9c86745e084c4c68c0ee020eaa359a03a8d43e4646f/onnx-1.23.2-cp312-abi3-win_amd64.whl", hash = "sha256:9b382ba898a7c142a0801d03cf04ecabced96c1543c7b643a86f0928143802de", size = 7872489, upload-time = "2026-10-06T04:25:44.802Z" }, + { url = "https://files.pythonhosted.org/packages/bd/1d/37f2c7f821f79ceed3c976bd087d16abdd2b0bba6c19475322e7a31bae59/onnx-1.23.2-cp312-abi3-win_arm64.whl", hash = "sha256:80cef0fad59524d02c21ec93f4fbccdcc6223f1c33339d597519a2d27cac19a7", size = 8047076, upload-time = "2026-10-06T04:25:46.93Z" }, +] + +[[package]] +name = "onnxruntime" +version = "1.32.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flatbuffers" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "protobuf" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/a4/480cd367bc135dd9951c89d461cc6af6be9302cd2ce91e231f6cb0e7ee1b/onnxruntime-1.32.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:d52510bbbcc880c13b826f7d75cdf33ac5cf0bb864d960000fc29ce73f0cb83e", size = 22519308, upload-time = "2026-11-13T11:06:13.395Z" }, + { url = "https://files.pythonhosted.org/packages/4a/8f/1e43fb994513c7c7a9c6965272ef89d963c1bd4080993a6267bf913701d1/onnxruntime-1.32.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:e36c187006e7a7c8b8d6d57f1a209dd63f52430dca6c282b177718ad6b841054", size = 23196724, upload-time = "2026-11-13T11:06:16.67Z" }, + { url = "https://files.pythonhosted.org/packages/a3/81/55845186c20cba59f614991f4065dea148e48eeb9749893768c85ce64327/onnxruntime-1.32.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:99e1074c4b2197accd5073052a465361be17b89c093b8ffb6e6bd8f986c52df8", size = 27780211, upload-time = "2026-11-13T11:06:19.734Z" }, + { url = "https://files.pythonhosted.org/packages/a9/3e/27039badc39a1b01628b6b40b1ff1bf4a886e6dfb2f311c483606b7c86f7/onnxruntime-1.32.0-cp312-cp312-win_amd64.whl", hash = "sha256:efe7456952c243a05a53d5b8732953625144642c2f3989094277f6217f0c0c40", size = 16698767, upload-time = "2026-11-13T11:06:22.618Z" }, + { url = "https://files.pythonhosted.org/packages/5d/e1/2ee4e15cebe7c2868e1d9ef391450db0951e6bbb2f01b2eb926722e19397/onnxruntime-1.32.0-cp312-cp312-win_arm64.whl", hash = "sha256:64d394c69d561af3efd4d4f49dcac8f11d0ce135a20701c16d53b74056cd4cf8", size = 16030610, upload-time = "2026-11-13T11:06:25.786Z" }, +] + +[[package]] +name = "opencv-python-headless" +version = "5.1.0.95" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6b/51/33b8c7255f3bdd920d6238aa478faf1e2136d5a51f17d826c13902ca7195/opencv_python_headless-5.1.0.95.tar.gz", hash = "sha256:9002add14b121b9a0d64dcaff48e5cac69a7987efcf2847f7db075c2d3b9633b", size = 83423991, upload-time = "2026-11-17T18:19:14.93Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a7/76/95bb6ecdb317bf839fc653d26055df7355b9290876ffebc0a8a68f0c8740/opencv_python_headless-5.1.0.95-cp37-abi3-macosx_15_0_arm64.whl", hash = "sha256:512f5c704eeedd0c550cf2daca42e4312f6d30bb047680f1563c661eb9ee7e82", size = 25824488, upload-time = "2026-11-17T17:40:36.008Z" }, + { url = "https://files.pythonhosted.org/packages/e7/ba/e4773fad5195bbb33e4acbec6710315e90b487c23d101f8b886d8341ed7c/opencv_python_headless-5.1.0.95-cp37-abi3-macosx_15_0_x86_64.whl", hash = "sha256:1193ffb8a60d0496dbac652f052791dc0f0da6a298e215c93d1d8c9dd67b89e9", size = 47012519, upload-time = "2026-11-17T17:40:59.708Z" }, + { url = "https://files.pythonhosted.org/packages/8c/2a/e42c34358d69a26bd5e88ba9241437c58b78876cf0d13ecc09df9042ed4f/opencv_python_headless-5.1.0.95-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:58835db7491d6564e816c4fbbedffe72afa3976dc19ccd7439916ec0e534f6c2", size = 35797194, upload-time = "2026-11-17T18:17:12.136Z" }, + { url = "https://files.pythonhosted.org/packages/37/63/6f18cf6b25aca818c5432317f9c9db3ee87d9f03d576d1e5953910429be3/opencv_python_headless-5.1.0.95-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:93cc83677f07791a9d3284bb6b9bbf7c2ffcca05aabcee239e68ca4abaf50aa1", size = 57722171, upload-time = "2026-11-17T18:17:22.507Z" }, + { url = "https://files.pythonhosted.org/packages/26/db/73313673e5c07eb4023c929022e6ef5f7cfd7885f7ea14019b1e1f74540a/opencv_python_headless-5.1.0.95-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:11d9753e15b8b3c56e6aa765139f722ca19ff26016d43bc81035f5d122731a81", size = 40022516, upload-time = "2026-11-17T18:17:30.669Z" }, + { url = "https://files.pythonhosted.org/packages/c2/be/cdf44e32b580af6c0e8f237665c538e6a5a37872f865e92e08fb854d5fd9/opencv_python_headless-5.1.0.95-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:7d387d4a64abe0c737440d38b5a90822f9bbcc10c8ce06a35904d6ecf7a2fb30", size = 63704594, upload-time = "2026-11-17T18:17:50.623Z" }, + { url = "https://files.pythonhosted.org/packages/a0/fb/2a03c688595f0c1541c31fe5a767072102f7bed82e3122e9348723c347fb/opencv_python_headless-5.1.0.95-cp37-abi3-win32.whl", hash = "sha256:3d57365e8050a968a60095fa78a108f765b094914f5ad863c45ff5cef8844069", size = 37076072, upload-time = "2026-11-17T14:37:37.864Z" }, + { url = "https://files.pythonhosted.org/packages/26/d1/a52c8d8e1cecf86725930170dfba1c7c1f59674ac8f131e96583aa41433d/opencv_python_headless-5.1.0.95-cp37-abi3-win_amd64.whl", hash = "sha256:2fd11ce2e88feb28869ad5762a31546ce0062e7c55c130c425ccd3918a19e4fa", size = 47789463, upload-time = "2026-11-17T14:37:33.153Z" }, + { url = "https://files.pythonhosted.org/packages/a5/72/0af4755ec5ea9fd7d478900405193f6e2d895383f26a31875e7fc7d22a12/opencv_python_headless-5.1.0.95-cp37-abi3-win_arm64.whl", hash = "sha256:a508c7c30815ccb5990d15427daf1397e33c850d8aab6efc3a5eaff035bebc80", size = 15631616, upload-time = "2026-11-17T14:37:27.735Z" }, +] + +[[package]] +name = "packaging" +version = "26.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, +] + +[[package]] +name = "pillow" +version = "13.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ce/a4/9cc30690a394a8305e8be4c9036aa16d0dfddadd09079860b582f562496d/pillow-13.0.0.tar.gz", hash = "sha256:cdcd1ba258178f7356d74170c9a81ba4eab6a5d55748bc402a5a2a6fe6be3510", size = 47058631, upload-time = "2026-10-16T22:18:09.718Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7a/b8/58d79332229482eb0d27c82973850808c19d37e5bdc14443d3417bd373f5/pillow-13.0.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:67c8d44ad89fa7eb88de5d6ef6199b1e03dd24974f85a67639fc8badb801fe79", size = 5568643, upload-time = "2026-10-16T22:15:44.474Z" }, + { url = "https://files.pythonhosted.org/packages/39/4b/f2ed53d83aa44ac19599ac0a54897f867fafb95f406980d1e24083f8cbe3/pillow-13.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc481f742ccda20e9ed760b8f978dff50f2a4e9bc253ac167fb0a05b0783ef52", size = 4852329, upload-time = "2026-10-16T22:15:46.284Z" }, + { url = "https://files.pythonhosted.org/packages/3b/bb/9e30e8ed18c20800ee327a12107d5249ad8dc444867b3adfcc21654e3c71/pillow-13.0.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8bf295fe459343bc6093c8e5e0df60bfa189e0fcb775a22e2c2488fdeccc6c0d", size = 6519309, upload-time = "2026-10-16T22:15:48.14Z" }, + { url = "https://files.pythonhosted.org/packages/e6/99/fdf65cc539e266ab93546c261bdf98411fe165c6e4e13f9dbf597097192b/pillow-13.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:42d63be3af4f9b951b199b0a9d23365d37ab14687e6d77b74940432c8515c4ca", size = 7144542, upload-time = "2026-10-16T22:15:50.093Z" }, + { url = "https://files.pythonhosted.org/packages/26/9b/f38b7c4d8f599537e2d1a6d546cec9beef7536ff8f5c49a3f9c78179d8ac/pillow-13.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4bd024d567eca931b668978d672dba914d4b8e2628e2c3073a2ad178de8a2620", size = 6618042, upload-time = "2026-10-16T22:15:52.054Z" }, + { url = "https://files.pythonhosted.org/packages/a8/7c/45ee28531f89ee4582967d8a17f7a26d71ca64cd902b93c269590cd60a00/pillow-13.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:23edf4ec4b6f4f240e8df6e4985e9ee2ced86474632433e55fb1e2548744bf40", size = 7228137, upload-time = "2026-10-16T22:15:54.009Z" }, + { url = "https://files.pythonhosted.org/packages/01/bc/9c2a969cb1b70201d04fa17fd5aedf02a732870b8da86bceaaa30b0ca385/pillow-13.0.0-cp312-cp312-win32.whl", hash = "sha256:02464da86f561f410e13b061ec37c3068a9cb557a095494157742d07b3c24a27", size = 6515423, upload-time = "2026-10-16T22:15:56.25Z" }, + { url = "https://files.pythonhosted.org/packages/ff/cd/73a79ecdc822076002eb24b5e1e4a530b0bb5310fcb6d239abbec877110b/pillow-13.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:ff3fe9eb621fbb9db4c4be33ab946f6bac5f98ab50ca8d3260503653656c961b", size = 7272166, upload-time = "2026-10-16T22:15:58.597Z" }, + { url = "https://files.pythonhosted.org/packages/4a/a3/be5a1236efd085b3984e4305da8f179ae9dab80c991d2ad78f2bd5c4c843/pillow-13.0.0-cp312-cp312-win_arm64.whl", hash = "sha256:c3bc8ee0271387e0b1e3ad0ff893645990a656e79bf9c42f4f734a3642b11d51", size = 2698943, upload-time = "2026-10-16T22:16:00.637Z" }, + { url = "https://files.pythonhosted.org/packages/60/da/f6d644e631c5b370c5d0b899f3ccadd2780aab070b29a110527cf4e1fd2c/pillow-13.0.0-pp312-pypy312_pp80-macosx_10_15_x86_64.whl", hash = "sha256:8619685cad8efc4c38c66d3b36aad854523297c43d748b3b6f0cc03c90ba3463", size = 5523188, upload-time = "2026-10-16T22:17:59.334Z" }, + { url = "https://files.pythonhosted.org/packages/e4/b0/2594f202d743a35d4fe80682bfd96f277e5ca7aecb27cf64ef5bfc1d000b/pillow-13.0.0-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:7e91e97a929232cdb828889ee6ad0e48d7f40f4ec38818f4e4a8968b2b1af22e", size = 4806808, upload-time = "2026-10-16T22:18:01.188Z" }, + { url = "https://files.pythonhosted.org/packages/8e/ed/d504165ef79af6fafe25c76726cf30f544cc236002f7ed054f1d51adc4ff/pillow-13.0.0-pp312-pypy312_pp80-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:93ff9c9c3663ce23aaa5d0b6b6abac55359e2a0c06c7e30f3771829af816be63", size = 5464358, upload-time = "2026-10-16T22:18:02.779Z" }, + { url = "https://files.pythonhosted.org/packages/7b/fe/a10aba5503ca13e9e009b8bd0a1a4ce5584bdce246245fd6f3a83701369c/pillow-13.0.0-pp312-pypy312_pp80-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e65dd6e75de67b2362a4fa3e16aa627595f65054dc4ec73d64680c84d592fa61", size = 6043514, upload-time = "2026-10-16T22:18:04.538Z" }, + { url = "https://files.pythonhosted.org/packages/c0/37/66b12dc476041fe523bca29c9d58fbf1ea92a4eaf73acfb9e993948f1191/pillow-13.0.0-pp312-pypy312_pp80-win_amd64.whl", hash = "sha256:567f20f1c75897d7663830da6ea8af719e03d712b1d9ee7f813319f9ece42e5a", size = 7366030, upload-time = "2026-10-16T22:18:06.638Z" }, +] + +[[package]] +name = "pluggy" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8", size = 123304, upload-time = "2026-10-15T09:50:58.343Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" }, +] + +[[package]] +name = "protobuf" +version = "7.36.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d9/89/5b8517baa72f84a67b8a307ba953c91057af618bf40bf676f3c03551f8f0/protobuf-7.36.2.tar.gz", hash = "sha256:497d0463ff3316681da6c0b9e8d06cb465d61abce00b613ab42226175644d1bb", size = 512737, upload-time = "2026-09-17T20:07:59.326Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/72/98342feb672507c8f3a69e34b4fa8961f608edba5c1a48a6f47156d92cb5/protobuf-7.36.2-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:cbc70b17ee27e28894c7fee8bb04be1abead49e936bc70eb60052531eee2079e", size = 456039, upload-time = "2026-09-17T20:07:51.542Z" }, + { url = "https://files.pythonhosted.org/packages/b6/ea/91fdf7c2b8bbd49cde056f00a9df6773532987e1c00fe2830b895af95c7e/protobuf-7.36.2-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:e11e1f0180583a2af89db6a2ecd9e8dc40aa6d2988ca175bfd0e6d12ea72d74e", size = 344219, upload-time = "2026-09-17T20:07:52.914Z" }, + { url = "https://files.pythonhosted.org/packages/17/ab/5fd5f8ece73fad885c5a09aa849b32d70472f954ba3a92d3bb5974ea953b/protobuf-7.36.2-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:f4fee11ec330d238b34a05c9b675f693c20415d1c5bd7d5320cc2f8a798eb9cf", size = 357223, upload-time = "2026-09-17T20:07:53.985Z" }, + { url = "https://files.pythonhosted.org/packages/db/f3/3996583dd2906297a637af12114deddf7658af6e683fedb83be061983fb5/protobuf-7.36.2-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:89f23aa53c24553a2416fd4fd1ec06f74fa42b14b546d8883128813f775bbfd2", size = 343223, upload-time = "2026-09-17T20:07:54.931Z" }, + { url = "https://files.pythonhosted.org/packages/fc/1b/dcc64f358fcb51811b58ae40b3d28f820725f116d86487cc20bd4b130701/protobuf-7.36.2-cp310-abi3-win32.whl", hash = "sha256:912c1221170e16c08d1f086762f563dd61ff83c18b5fa6652952dfaded66f728", size = 442998, upload-time = "2026-09-17T20:07:55.826Z" }, + { url = "https://files.pythonhosted.org/packages/8a/55/b77bda4e5e5f5971fb51b07663694690e9afdb9402136c16a522bd621cad/protobuf-7.36.2-cp310-abi3-win_amd64.whl", hash = "sha256:a300819d441e078a5608c0d3c709796bb548136058fda017ae51d425b44fd353", size = 456514, upload-time = "2026-09-17T20:07:57.188Z" }, + { url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" }, +] + +[[package]] +name = "pydantic" +version = "2.14.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b4/fc/1203d011145c98ddce3cd2f505bb54375ef8d43223053df6bfcf3c746f46/pydantic-2.14.3.tar.gz", hash = "sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d", size = 925636, upload-time = "2026-11-05T09:17:04.686Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/72/b8/b864503789ef5c58597d2a7b4adbee62c26440ab1e682581fc6838df8947/pydantic-2.14.3-py3-none-any.whl", hash = "sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8", size = 494071, upload-time = "2026-11-05T09:17:02.426Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.50.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9c/0f/34f9ce4ba701dd0b815033ef94d99b56f66200e578ee6052aa3ac26f064e/pydantic_core-2.50.4.tar.gz", hash = "sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6", size = 522249, upload-time = "2026-11-05T09:15:26.774Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/10/bf/d1f6b81709538f831ebe1c42f50fb89db3dfda06f9e9b1ea24e90fc69209/pydantic_core-2.50.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6", size = 2231444, upload-time = "2026-11-05T09:12:06.969Z" }, + { url = "https://files.pythonhosted.org/packages/c1/39/6618e541658d5a687a8d4962fc304350073a8f322bc4c62e8ed4c2d514d6/pydantic_core-2.50.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783", size = 2108048, upload-time = "2026-11-05T09:12:08.85Z" }, + { url = "https://files.pythonhosted.org/packages/d9/54/1c941fffa4e14bfc9ab0cd4977075f0e03201447856130d08a33cd45e47b/pydantic_core-2.50.4-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466", size = 2256866, upload-time = "2026-11-05T09:12:10.495Z" }, + { url = "https://files.pythonhosted.org/packages/61/a0/8028ef3e014be522ce43060aeac82a5be2288215e660866f5e6260acc123/pydantic_core-2.50.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c", size = 2125682, upload-time = "2026-11-05T09:12:12.278Z" }, + { url = "https://files.pythonhosted.org/packages/c3/f2/b98bb73b1734ec4e42e786a766abc24f3c89620a0ddbaf8aa14e4b4c628c/pydantic_core-2.50.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c", size = 2197108, upload-time = "2026-11-05T09:12:13.873Z" }, + { url = "https://files.pythonhosted.org/packages/f1/d1/7a7142786781400143e8806633fe5b65e2d407c311041fc9494490f05b18/pydantic_core-2.50.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8", size = 2380521, upload-time = "2026-11-05T09:12:15.539Z" }, + { url = "https://files.pythonhosted.org/packages/b5/34/cf710ca48d4498b04a3ea605d45892675dc2b14a94a25121a8d03f56d3e9/pydantic_core-2.50.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3", size = 2457436, upload-time = "2026-11-05T09:12:17.447Z" }, + { url = "https://files.pythonhosted.org/packages/91/23/e0c6e3cd09a0ac809953fea698c816b9f03bf0b35b6820c9553e4f5d85a8/pydantic_core-2.50.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd", size = 2261727, upload-time = "2026-11-05T09:12:19.097Z" }, + { url = "https://files.pythonhosted.org/packages/f9/00/292a0ed96d5d2d6edb49468ef481336e5b7e54f13435d73b7c912c891c23/pydantic_core-2.50.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823", size = 2262071, upload-time = "2026-11-05T09:12:20.78Z" }, + { url = "https://files.pythonhosted.org/packages/f8/36/d4690faf8c082eacf7754e52ab6bebe1bc73b167272e28699c00480ee908/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf", size = 2298931, upload-time = "2026-11-05T09:12:22.614Z" }, + { url = "https://files.pythonhosted.org/packages/21/17/b180af6d17cf6c8e0d3d2661fc501a4a40959744ca4947d6ad0db81b1416/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2", size = 2474285, upload-time = "2026-11-05T09:12:24.842Z" }, + { url = "https://files.pythonhosted.org/packages/6e/bb/7e44d4ac6e1292f1859384c688713045bdf5448e0635c49c003d2be3bb6c/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344", size = 2498172, upload-time = "2026-11-05T09:12:26.434Z" }, + { url = "https://files.pythonhosted.org/packages/d8/84/5101f35294579c4bef7dc32fd4f097d91eedac2e195894266bdabc1e6dfd/pydantic_core-2.50.4-cp312-cp312-win32.whl", hash = "sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1", size = 2119592, upload-time = "2026-11-05T09:12:27.971Z" }, + { url = "https://files.pythonhosted.org/packages/82/88/d438a8fcf3738e9ff2670f724047ca3893ec899bcd5cdfc077a2aab133c6/pydantic_core-2.50.4-cp312-cp312-win_amd64.whl", hash = "sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821", size = 2264064, upload-time = "2026-11-05T09:12:29.538Z" }, + { url = "https://files.pythonhosted.org/packages/77/d4/4a0c73dc3ef9e50b122b8c3527afcded15a44838f1c9668d2d4b72cc09f0/pydantic_core-2.50.4-cp312-cp312-win_arm64.whl", hash = "sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113", size = 2167792, upload-time = "2026-11-05T09:12:31.103Z" }, + { url = "https://files.pythonhosted.org/packages/9a/18/2f6a25e9104d5af713d16671711927601da1f0db74e785be67bd590385c9/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3", size = 2212591, upload-time = "2026-11-05T09:14:56.262Z" }, + { url = "https://files.pythonhosted.org/packages/4c/1b/ba8b721af10a7659e7fbbef320ff8eb55462557a72607858af5a9bd22cb1/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d", size = 2048167, upload-time = "2026-11-05T09:14:57.681Z" }, + { url = "https://files.pythonhosted.org/packages/48/42/3f8638e7d90bdd9a7c7f3e5084723af59e7f43f15a292e242d35624073ce/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8", size = 2119548, upload-time = "2026-11-05T09:14:59.317Z" }, + { url = "https://files.pythonhosted.org/packages/e0/8d/4bfbacaf191f7939893d165e18eb301731fa3366c59a6e57336c4f168fbd/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296", size = 2279952, upload-time = "2026-11-05T09:15:00.907Z" }, +] + +[[package]] +name = "pygments" +version = "2.21.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, +] + +[[package]] +name = "pyparsing" +version = "3.3.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e4/11/b213bebff182584360cb8d17c72c1677fec5c5c228de439e63bcf8ab1c8f/pyparsing-3.3.3.tar.gz", hash = "sha256:928ae7e20211f3b6f3915a72f06a0cfd29ab9d24279dd6346b6b1a7146397d36", size = 1050487, upload-time = "2026-09-20T20:59:05.609Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/bb/d215ee7c73b61497b28a5503f9f53523f294fcc936762b7caf90e0c1c2b5/pyparsing-3.3.3-py3-none-any.whl", hash = "sha256:ece8c00a69cf01b45d0b1dedabb469c90d8caf996d4fda40f147627a122849a4", size = 126420, upload-time = "2026-09-20T20:59:04.025Z" }, +] + +[[package]] +name = "pytest" +version = "9.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/79/42/bb4641652e58dedeac2ec51abc1f8cae4fee4ec63899a0999016229a0f2a/pytest-9.2.0.tar.gz", hash = "sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b", size = 1797555, upload-time = "2026-10-27T21:30:20.728Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/39/1f5d8c8877a0fa327db959c19341d4be61660de1ab6b7391f9eb805bcd67/pytest-9.2.0-py3-none-any.whl", hash = "sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588", size = 411776, upload-time = "2026-10-27T21:30:19.131Z" }, +] + +[[package]] +name = "python-dateutil" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzdata" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/18/39/b3927f3616f6223832f9b760e4208e8a7c7e1dea2b4d9ad7d32a5d214c3a/python_dateutil-4.0.0.tar.gz", hash = "sha256:d7295ff14fdc0f92f662100bfb6c551d160ca090f2939f1ec5b9794265c03f06", size = 250419, upload-time = "2026-11-01T07:02:42.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/a9/52b89563d154433d79b51ed1eb4842bf7334cb2696891a7fe135618853d7/python_dateutil-4.0.0-py3-none-any.whl", hash = "sha256:a5e246f79eb80475e691bf93862cead98decd8a498cf53ba0516fcdc0f50dc1c", size = 92853, upload-time = "2026-11-01T07:02:40.797Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, + { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, + { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, + { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, + { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, + { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, + { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, + { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, +] + +[[package]] +name = "ruff" +version = "0.17.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/86/cc/7b71512eb8b49926efb887cc66c74dd993642943c29eba51a877f6b85692/ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e", size = 5368382, upload-time = "2026-11-12T17:54:55.04Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/f2/61df414cb4338617290a9023ad09486e207fb9a6d09357a7be34f2e369a4/ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396", size = 10231309, upload-time = "2026-11-12T17:54:09.314Z" }, + { url = "https://files.pythonhosted.org/packages/d1/72/8ed970f3361f7c8d3f8e1b3b1af27cf086bc4b3a6b62ec20e21a1aaaaff5/ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b", size = 10250018, upload-time = "2026-11-12T17:54:11.983Z" }, + { url = "https://files.pythonhosted.org/packages/dc/4b/8b10f6c9d0a18413301ae8dd2af9d180a81bb738b1b731d944a37404c523/ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7", size = 9504737, upload-time = "2026-11-12T17:54:14.567Z" }, + { url = "https://files.pythonhosted.org/packages/b7/ea/1b3afa3943239dede7a0755ea139bdb51879f0f3f96f92894081d5c7d2e5/ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963", size = 10168006, upload-time = "2026-11-12T17:54:17.195Z" }, + { url = "https://files.pythonhosted.org/packages/31/08/ee641daa45f83792f91274b65796cb011f1065f588911bfa3909ad9e31e7/ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342", size = 10043751, upload-time = "2026-11-12T17:54:19.815Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cf/1c59fdb42d0b5671ad5b160636fab4005ee28db72cb06aef6e3f3c04f377/ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882", size = 10690562, upload-time = "2026-11-12T17:54:22.789Z" }, + { url = "https://files.pythonhosted.org/packages/49/c5/578074716173fb0c1591e9648a9f85c469888d9530cb35b89b757dc1208b/ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f", size = 11338465, upload-time = "2026-11-12T17:54:25.523Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b9/d6428bcf5ed88f4dc1d6e3417ee350236ed36e7a35f9477b727c00e437bf/ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d", size = 10895501, upload-time = "2026-11-12T17:54:28.441Z" }, + { url = "https://files.pythonhosted.org/packages/f2/8a/1e29c0c3785ae7e5cd0d54ee8717a08867ef71545796340be4c653c57e24/ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e", size = 10613231, upload-time = "2026-11-12T17:54:30.862Z" }, + { url = "https://files.pythonhosted.org/packages/32/b6/88944350c14bb90651014d678ad554e233ae2a79c14ad52101845f93d15b/ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df", size = 10562789, upload-time = "2026-11-12T17:54:33.869Z" }, + { url = "https://files.pythonhosted.org/packages/6f/fd/2792e955b0bf54295cdcdddc4bb3f380c0790d7e60e789f528a9e6e48a31/ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db", size = 10069824, upload-time = "2026-11-12T17:54:36.663Z" }, + { url = "https://files.pythonhosted.org/packages/07/9c/d7cad341b4c19237948a6dd1fcea1c9c39c9d08b70f22f0e157d1236ebd6/ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580", size = 10038961, upload-time = "2026-11-12T17:54:39.452Z" }, + { url = "https://files.pythonhosted.org/packages/cc/a1/9cd0d4c371ddc70267d3bd557e718e2bdfb94c25e49d25605edfabb764bd/ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697", size = 10385012, upload-time = "2026-11-12T17:54:41.808Z" }, + { url = "https://files.pythonhosted.org/packages/8f/a9/35f078ce98d4df318328ea5270382b5b65e680f7953b3db54f8e009c420c/ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586", size = 10793672, upload-time = "2026-11-12T17:54:44.342Z" }, + { url = "https://files.pythonhosted.org/packages/2c/a5/2e136dede2a88aaaf54498bbbdc81bc810f788ef6ef01efb97037d73cd1d/ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a", size = 9929908, upload-time = "2026-11-12T17:54:47.067Z" }, + { url = "https://files.pythonhosted.org/packages/ec/8c/e4db9ae1e0ee233c04df007ab6d0d42f799ae9abd95d352b6092ee7bc4bf/ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550", size = 10275454, upload-time = "2026-11-12T17:54:49.401Z" }, + { url = "https://files.pythonhosted.org/packages/e6/65/a1648bc1550e7683bf7bf1e2ce2485c9f8535cbca6cca9ec7b73cc12fb8e/ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e", size = 9849020, upload-time = "2026-11-12T17:54:52.055Z" }, +] + +[[package]] +name = "setuptools" +version = "84.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/70/b3/c19426f783614d625699a4b247faf628ea9ab1db228674491767b417f9e1/setuptools-84.2.1.tar.gz", hash = "sha256:3ff8b3b5492a0aa66960f4419365a86b84e013070d4313e4d4a6894f5d64d6bc", size = 1230289, upload-time = "2026-10-20T19:01:37.742Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/55/6dc6d6bb953bdfc52519a0059592c52b6e3b8ad51cf8256dffceb55b0610/setuptools-84.2.1-py3-none-any.whl", hash = "sha256:ca140b45d5325a9478f880e351484f62fef15f336462e449ca0c03c873d589c2", size = 876263, upload-time = "2026-10-20T19:01:35.678Z" }, +] + +[[package]] +name = "sympy" +version = "1.14.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mpmath" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/d3/803453b36afefb7c2bb238361cd4ae6125a569b4db67cd9e79846ba2d68c/sympy-1.14.0.tar.gz", hash = "sha256:d3d3fe8df1e5a0b42f0e7bdf50541697dbe7d23746e894990c030e2b05e72517", size = 7793921, upload-time = "2025-04-27T18:05:01.611Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl", hash = "sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5", size = 6299353, upload-time = "2025-04-27T18:04:59.103Z" }, +] + +[[package]] +name = "tiasdata" +version = "0.1.0" +source = { editable = "external/TIASDataHub" } +dependencies = [ + { name = "pydantic" }, +] + +[package.metadata] +requires-dist = [ + { name = "openpyxl", marker = "extra == 'import'", specifier = ">=3.1.5" }, + { name = "pillow", marker = "extra == 'import'", specifier = ">=11.0" }, + { name = "pydantic", specifier = ">=2.9" }, +] +provides-extras = ["import"] + +[package.metadata.requires-dev] +dev = [ + { name = "openpyxl", specifier = ">=3.1.5" }, + { name = "pillow", specifier = ">=11.0" }, + { name = "pytest", specifier = ">=8.0" }, + { name = "ruff", specifier = ">=0.8" }, +] + +[[package]] +name = "tongue-seg-model" +version = "0.1.0" +source = { editable = "." } +dependencies = [ + { name = "matplotlib" }, + { name = "numpy" }, + { name = "onnx" }, + { name = "onnxruntime" }, + { name = "opencv-python-headless" }, + { name = "pydantic" }, + { name = "pyyaml" }, + { name = "tiasdata" }, + { name = "torch", version = "2.14.1+cu126", source = { registry = "https://download.pytorch.org/whl/cu126" }, marker = "sys_platform == 'linux'" }, + { name = "torch", version = "2.15.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux'" }, + { name = "torchvision", version = "0.29.1+cu126", source = { registry = "https://download.pytorch.org/whl/cu126" }, marker = "sys_platform == 'linux'" }, + { name = "torchvision", version = "0.29.2", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux'" }, +] + +[package.dev-dependencies] +dev = [ + { name = "pytest" }, + { name = "ruff" }, +] + +[package.metadata] +requires-dist = [ + { name = "matplotlib", specifier = ">=3.9" }, + { name = "numpy", specifier = ">=2.0" }, + { name = "onnx", specifier = ">=1.23.0" }, + { name = "onnxruntime", specifier = ">=1.30.0" }, + { name = "opencv-python-headless", specifier = ">=5.0.0.93" }, + { name = "pydantic", specifier = ">=2.9" }, + { name = "pyyaml", specifier = ">=6.0" }, + { name = "tiasdata", editable = "external/TIASDataHub" }, + { name = "torch", marker = "sys_platform != 'linux'", specifier = ">=2.5" }, + { name = "torch", marker = "sys_platform == 'linux'", specifier = ">=2.5", index = "https://download.pytorch.org/whl/cu126" }, + { name = "torchvision", marker = "sys_platform != 'linux'", specifier = ">=0.20" }, + { name = "torchvision", marker = "sys_platform == 'linux'", specifier = ">=0.20", index = "https://download.pytorch.org/whl/cu126" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "pytest", specifier = ">=8.0" }, + { name = "ruff", specifier = ">=0.8" }, +] + +[[package]] +name = "torch" +version = "2.14.1+cu126" +source = { registry = "https://download.pytorch.org/whl/cu126" } +resolution-markers = [ + "sys_platform == 'linux'", +] +dependencies = [ + { name = "cuda-bindings" }, + { name = "cuda-toolkit", extra = ["cublas", "cudart", "cufft", "cufile", "cupti", "curand", "cusolver", "cusparse", "nvrtc", "nvtx"] }, + { name = "filelock" }, + { name = "fsspec" }, + { name = "jinja2" }, + { name = "networkx" }, + { name = "nvidia-cudnn-cu12" }, + { name = "nvidia-cusparselt-cu12" }, + { name = "nvidia-nccl-cu12" }, + { name = "nvidia-nvjitlink-cu12" }, + { name = "nvidia-nvshmem-cu12" }, + { name = "setuptools" }, + { name = "sympy" }, + { name = "triton" }, + { name = "typing-extensions" }, +] +wheels = [ + { url = "https://download-r2.pytorch.org/whl/cu126/torch-2.14.1%2Bcu126-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:d5ec05cc53a2e756f12d938a029d88e54e761a4bc0e2cdd56ccf51475625fd24", upload-time = "2026-09-30T19:57:19Z" }, + { url = "https://download-r2.pytorch.org/whl/cu126/torch-2.14.1%2Bcu126-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:75727245346d8f92224a860bf40c56bd681edcfa0456d01d7dfcb0bf6f0cf86c", upload-time = "2026-09-30T19:57:48Z" }, +] + +[[package]] +name = "torch" +version = "2.15.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "sys_platform != 'linux'", +] +dependencies = [ + { name = "filelock" }, + { name = "fsspec" }, + { name = "jinja2" }, + { name = "networkx" }, + { name = "setuptools" }, + { name = "sympy" }, + { name = "typing-extensions" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/17/24/7b9b755e8c4dd2395c6a94bab6a4ed8aded1735ff2538bc63cbba8abeddd/torch-2.15.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:593e5fd0c204284890d1c3dff643be34e549e1d24523e13402510f960d4da438", size = 138558517, upload-time = "2026-10-28T15:16:35.918Z" }, + { url = "https://files.pythonhosted.org/packages/74/0b/a57c0b58a64b7a197dc40fc464bb96c0de867f95a2b1cbb3ec9e54414fde/torch-2.15.0-cp312-cp312-win_amd64.whl", hash = "sha256:f2bd0a3709a7493a6ef2ac5a654111242a854439f7558f910b6b653b56f7504d", size = 126738207, upload-time = "2026-10-28T15:16:40.586Z" }, +] + +[[package]] +name = "torchvision" +version = "0.29.1+cu126" +source = { registry = "https://download.pytorch.org/whl/cu126" } +resolution-markers = [ + "sys_platform == 'linux'", +] +dependencies = [ + { name = "numpy" }, + { name = "pillow" }, + { name = "torch", version = "2.14.1+cu126", source = { registry = "https://download.pytorch.org/whl/cu126" } }, +] +wheels = [ + { url = "https://download-r2.pytorch.org/whl/cu126/torchvision-0.29.1%2Bcu126-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:00ec6517420091214edd608e40d82ff6c0357d1a24399dde27ed64ca3a66e022", upload-time = "2026-09-30T15:46:21Z" }, + { url = "https://download-r2.pytorch.org/whl/cu126/torchvision-0.29.1%2Bcu126-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:f846900988cbd64b055886c9ad7e7a44606c5710e8272921062c647f237eae34", upload-time = "2026-09-30T15:46:21Z" }, +] + +[[package]] +name = "torchvision" +version = "0.29.2" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "sys_platform != 'linux'", +] +dependencies = [ + { name = "numpy" }, + { name = "pillow" }, + { name = "torch", version = "2.15.0", source = { registry = "https://pypi.org/simple" } }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/ec/ce97c46e5322b588b95be388f2c21878d014ca20838478e7aab59edd128a/torchvision-0.29.2-py3-none-macosx_14_0_arm64.whl", hash = "sha256:d412494ff011f24c884a3cffd33eba1cb45a0299d4e26c1e175113f9d3b3ebc7", size = 1823414, upload-time = "2026-10-28T15:21:31.892Z" }, + { url = "https://files.pythonhosted.org/packages/cf/9a/a728c3af061bff5e0c8a8389b6dfe99646f8290a2f6a5f8fb624a0c15b92/torchvision-0.29.2-py3-none-win_amd64.whl", hash = "sha256:5812c312d4401c3587a045fa4c6228d982ebc4faa9b472275d11afe5852e24f9", size = 1379121, upload-time = "2026-10-28T15:21:30.558Z" }, +] + +[[package]] +name = "triton" +version = "3.8.0" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/87/07/0f8cd8e8db0472334253efdaaab3d0819fea27aa99bf0e7f1aeea4ceb5ae/triton-3.8.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a9c404c69ed4a39e8ec632eaf6b9fe058a060bf98979c177f6ef666f06bb8d50", size = 226474486, upload-time = "2026-08-28T16:08:18.29Z" }, + { url = "https://files.pythonhosted.org/packages/c1/09/b7012e5bfae67640f268aa584caa80fe1674f6b0da949046b679972c33e3/triton-3.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e91ffa46d095b252248297292dd22bcbacd53a125a0c2eefbbbf74925a320bc3", size = 247972921, upload-time = "2026-08-28T15:55:53.157Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ff/50/0195198eb1d75bab716bb0a813abea4cc394bfa17a92a189f021a34859af/typing_inspection-0.4.5.tar.gz", hash = "sha256:7f16c411e7930dc79596d42ab44672a3fe5f60eb34b781a1647e7872363120c7", size = 81194, upload-time = "2026-11-04T14:13:23.774Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/de/0c/ea2544850a7c135e15033a5c7a8e7211136184b7ae63e2239d557c2b3019/typing_inspection-0.4.5-py3-none-any.whl", hash = "sha256:bc210535442b39e1bf2805e0c7a17dfd6a4ace760c84c7f7d16245d23a6b1c39", size = 14874, upload-time = "2026-11-04T14:13:22.616Z" }, +] + +[[package]] +name = "tzdata" +version = "2026.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/29/6a1391d31cd00ff9e927215a224a880e1e84e826b64ba80a499e51c074d8/tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d", size = 201017, upload-time = "2026-10-28T09:57:09.137Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0a/66/9a06c2227fedfd4919f0eaaa8b94377d9730882a7e4f95823c9a331ab5e1/tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec", size = 348210, upload-time = "2026-10-28T09:57:07.276Z" }, +]