diff --git a/CLAUDE.md b/CLAUDE.md index 9a5a5b5..497bb2b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,7 +5,7 @@ ## 開発進捗 -最新: 前任者の 4 手法を今のデータで動かして比べた(TEST_08.第 2 候補までは苔の除去+SVM が最も高い).次は GM の資料への反映と,今のモデルの再評価,`color_model.json` を作り直すかの判断 +最新: 前任者の手法を並木先生の 1 回目のラベルで動かせるようにした(`configs/predecessor_first_round/`).次は実データでの実行と TEST への記録,GM の資料への反映 ※ 本欄は**最新ステップ 1 行のみ上書き更新**.詳細な進捗履歴(動機・設計判断・失敗パターン)は [docs/PROGRESS.md](docs/PROGRESS.md) に追記する.運用ルールは `.claude/rules/progress-log.md` を参照(該当ファイル編集時に自動ロードされる). ## 必須ルール(コード実装時) diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_with_mild.yaml new file mode 100644 index 0000000..9a09319 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_with_mild.yaml @@ -0,0 +1,28 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(4) SVM・Hue による舌苔の除去(スライドのしきい値.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: tongue_body + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced + coat_removal: # スライドの値 + white: { h: [0, 180], s: [0, 80], v: [0, 255] } + yellow: { h: [0, 20], s: [0, 255], v: [0, 255] } diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_without_mild.yaml new file mode 100644 index 0000000..f48a2cc --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_slide_without_mild.yaml @@ -0,0 +1,28 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(4) SVM・Hue による舌苔の除去(スライドのしきい値.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: tongue_body + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced + coat_removal: # スライドの値 + white: { h: [0, 180], s: [0, 80], v: [0, 255] } + yellow: { h: [0, 20], s: [0, 255], v: [0, 255] } diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_with_mild.yaml new file mode 100644 index 0000000..4377945 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_with_mild.yaml @@ -0,0 +1,28 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(4) SVM・Hue による舌苔の除去(最終コードのしきい値.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: tongue_body + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced + coat_removal: # 前任者の最終コードの値 + white: { h: [0, 180], s: [0, 92], v: [0, 255] } + yellow: { h: [0, 89], s: [0, 255], v: [0, 255] } diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_without_mild.yaml new file mode 100644 index 0000000..a7c628c --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_coat_removed_without_mild.yaml @@ -0,0 +1,28 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(4) SVM・Hue による舌苔の除去(最終コードのしきい値.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: tongue_body + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced + coat_removal: # 前任者の最終コードの値 + white: { h: [0, 180], s: [0, 92], v: [0, 255] } + yellow: { h: [0, 89], s: [0, 255], v: [0, 255] } diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_lateral_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_lateral_with_mild.yaml new file mode 100644 index 0000000..6596b2a --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_lateral_with_mild.yaml @@ -0,0 +1,25 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(2) SVM・苔の除去なし(manifest の DeepTIAS の特徴量.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: deeptias_lateral + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced diff --git a/configs/predecessor_first_round/cv_first_round_color_svm_lateral_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_color_svm_lateral_without_mild.yaml new file mode 100644 index 0000000..e396171 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_color_svm_lateral_without_mild.yaml @@ -0,0 +1,25 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(2) SVM・苔の除去なし(manifest の DeepTIAS の特徴量.tias-train color-cv.GPU 不要)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: deeptias_lateral + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_with_mild.yaml new file mode 100644 index 0000000..ba3067d --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_with_mild.yaml @@ -0,0 +1,41 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(3) ResNet34 + 色を変えた疑似画像・疑似画像のみ(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 + color_shift_pseudo: # 学習データに色を変えた疑似画像を使う(メモリ上で作り,保存しない) + mode: pseudo_only + uniform_half_range: 0.5 diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_without_mild.yaml new file mode 100644 index 0000000..e4a87a2 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_pseudo_only_without_mild.yaml @@ -0,0 +1,41 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(3) ResNet34 + 色を変えた疑似画像・疑似画像のみ(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 + color_shift_pseudo: # 学習データに色を変えた疑似画像を使う(メモリ上で作り,保存しない) + mode: pseudo_only + uniform_half_range: 0.5 diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_with_mild.yaml new file mode 100644 index 0000000..007a787 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_with_mild.yaml @@ -0,0 +1,41 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(3) ResNet34 + 色を変えた疑似画像・実画像+疑似画像(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 + color_shift_pseudo: # 学習データに色を変えた疑似画像を使う(メモリ上で作り,保存しない) + mode: real_plus_pseudo + uniform_half_range: 0.5 diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_without_mild.yaml new file mode 100644 index 0000000..0936bda --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_color_shift_real_plus_pseudo_without_mild.yaml @@ -0,0 +1,41 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(3) ResNet34 + 色を変えた疑似画像・実画像+疑似画像(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 + color_shift_pseudo: # 学習データに色を変えた疑似画像を使う(メモリ上で作り,保存しない) + mode: real_plus_pseudo + uniform_half_range: 0.5 diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_with_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_with_mild.yaml new file mode 100644 index 0000000..35ff9ad --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_with_mild.yaml @@ -0,0 +1,38 @@ +# 5-fold 交差検証(ややあり込み): 前任者の手法の比較(並木先生の 1 回目のラベル).(1) ResNet34(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 diff --git a/configs/predecessor_first_round/cv_first_round_pred_resnet34_without_mild.yaml b/configs/predecessor_first_round/cv_first_round_pred_resnet34_without_mild.yaml new file mode 100644 index 0000000..6cf7727 --- /dev/null +++ b/configs/predecessor_first_round/cv_first_round_pred_resnet34_without_mild.yaml @@ -0,0 +1,38 @@ +# 5-fold 交差検証(ややあり除外): 前任者の手法の比較(並木先生の 1 回目のラベル).(1) ResNet34(tias-train cv)(SPEC_02「前任者の手法との比較」) +# 臨床データはサーバ上にのみ置く.手元ではこの設定で実行しない(手元用は configs/predecessor_first_round/synthetic/). +data: + bundle: + name: tongue_color_first_round + version: 1 + label_kind: tongue_color_first_round + severities: [strong, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: true + +train: + image_size: 224 + batch_size: 32 + max_epochs: 200 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 4 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 diff --git a/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_coat_removed_synthetic.yaml b/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_coat_removed_synthetic.yaml new file mode 100644 index 0000000..ca0aeb6 --- /dev/null +++ b/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_coat_removed_synthetic.yaml @@ -0,0 +1,28 @@ +# 手元確認用: 合成バンドル(scripts/make_synthetic_bundle.py --first-round)で前任者の手法の比較(1 回目のラベル)(SVM・coat_removed)を通す設定.GPU 不要. +# TIASDATA_BUNDLES=data/synthetic_bundles_first_round を付けて実行する. +data: + bundle: + name: tongue_color_first_round_synthetic # 実データ(tongue_color_first_round)とは別の名前.サーバで動かしても実データを読まない + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: tongue_body + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced + coat_removal: # 前任者の最終コードの値 + white: { h: [0, 180], s: [0, 92], v: [0, 255] } + yellow: { h: [0, 89], s: [0, 255], v: [0, 255] } diff --git a/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_lateral_synthetic.yaml b/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_lateral_synthetic.yaml new file mode 100644 index 0000000..88a9b53 --- /dev/null +++ b/configs/predecessor_first_round/synthetic/cv_first_round_color_svm_lateral_synthetic.yaml @@ -0,0 +1,25 @@ +# 手元確認用: 合成バンドル(scripts/make_synthetic_bundle.py --first-round)で前任者の手法の比較(1 回目のラベル)(SVM・lateral)を通す設定.GPU 不要. +# TIASDATA_BUNDLES=data/synthetic_bundles_first_round を付けて実行する. +data: + bundle: + name: tongue_color_first_round_synthetic # 実データ(tongue_color_first_round)とは別の名前.サーバで動かしても実データを読まない + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +train: + inner_val_ratio: 0.15 # ハイパーパラメータ選び用の内側の検証(CNN の早期終了用と同じ分け方) + class_weighting: none + +color: + classifier: svm_rbf + features: deeptias_lateral + max_side: null # 元の解像度のまま + svm: + c_values: [0.1, 1.0, 10.0, 100.0] + gammas: [scale, 0.01, 0.1, 1.0] + class_weight: balanced diff --git a/configs/predecessor_first_round/synthetic/cv_first_round_pred_resnet34_synthetic.yaml b/configs/predecessor_first_round/synthetic/cv_first_round_pred_resnet34_synthetic.yaml new file mode 100644 index 0000000..0d99b42 --- /dev/null +++ b/configs/predecessor_first_round/synthetic/cv_first_round_pred_resnet34_synthetic.yaml @@ -0,0 +1,38 @@ +# 手元確認用: 合成バンドル(scripts/make_synthetic_bundle.py --first-round)で前任者の手法の比較(1 回目のラベル)を通す設定.CPU で動くよう小さくしてある. +# TIASDATA_BUNDLES=data/synthetic_bundles_first_round を付けて実行する. +data: + bundle: + name: tongue_color_first_round_synthetic # 実データ(tongue_color_first_round)とは別の名前.サーバで動かしても実データを読まない + version: 1 + label_kind: tongue_color_first_round + severities: [strong, mild, normal] + +split: + seed: 42 + n_folds: 5 + +model: + name: resnet34 + pretrained: false + +train: + image_size: 64 + batch_size: 8 + max_epochs: 2 + patience: 50 + lr: 1.285e-4 + weight_decay: 1.0e-4 + warmup_epochs: 0 # CosineAnnealing のみ + inner_val_ratio: 0.15 # 早期終了は内側の検証で行う(前任者はテストの損失) + num_workers: 0 + amp: true + augmentation: # 色を変える拡張はこの比較の設定に限って明示的に有効にする(SPEC_02) + horizontal_flip_prob: 0.5 + rotation_degrees: 5.0 + scale_range: null + translate_ratio: 0.0 + color_jitter: + brightness: 0.05 + contrast: 0.05 + saturation: 0.05 + hue: 0.05 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" index 9861323..b55f6f3 100644 --- "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" @@ -74,6 +74,8 @@ | 合成バンドルの生成 | `uv run python scripts/make_synthetic_bundle.py` | 前任者の手法の比較を手元で流すための合成データ.出力は `data/synthetic_bundles/tongue_color_synthetic/v3/`(実データの `tongue_color` とは別の名前.版 3 と同じ形で,DeepTIAS の特徴量の 15 列つき).作り直しは `--overwrite`(目印のある出力先だけ消す) | | 前任者の手法の試運転(ResNet34・疑似画像) | `TIASDATA_BUNDLES=data/synthetic_bundles uv run tias-train cv --config configs/predecessor/synthetic/<設定>` | 合成バンドル・事前学習なし・小さな画像・2 エポック.PowerShell は先に `$env:TIASDATA_BUNDLES = "data/synthetic_bundles"` | | 前任者の手法の試運転(SVM) | `TIASDATA_BUNDLES=data/synthetic_bundles uv run tias-train color-cv --config configs/predecessor/synthetic/cv_color_svm__synthetic.yaml` | 合成バンドルを読む.GPU 不要 | +| 合成バンドルの生成(1 回目のラベル) | `uv run python scripts/make_synthetic_bundle.py --first-round` | 出力は `data/synthetic_bundles_first_round/tongue_color_first_round_synthetic/v1/`(実データの `tongue_color_first_round` とは別の名前.所見 `tongue_color_first_round` と,1 クラスずらして一部を空にした `tongue_color` の列つき).作り直しは `--overwrite` | +| 1 回目のラベルの試運転 | `TIASDATA_BUNDLES=data/synthetic_bundles_first_round uv run tias-train --config configs/predecessor_first_round/synthetic/<設定>` | ResNet34 は `cv`,SVM は `color-cv`.PowerShell は先に `$env:TIASDATA_BUNDLES = "data/synthetic_bundles_first_round"` | | 回収した結果の集計 | `uv run python scripts/summarize_cv.py runs` | `runs/*_cv_*` を読み,モデル × 学習率 × 不均衡対策 × 条件ごとの表と,「除外 − 込み」「対策あり − 対策なし」の対応比較を Markdown で出す([TEST_03](../06_TEST/TEST_03_交差検証結果.md) の表) | 設定ファイル: @@ -90,6 +92,8 @@ | `configs/export/*.yaml` | 判定モデルの書き出し(`color_logistic_`.特徴・候補は `configs/color/` と同じ.`color_synthetic` は手元用) | | `configs/predecessor/*.yaml` | 前任者の手法の比較(各 `with_mild`・`without_mild`.[SPEC_02](../04_SPEC/SPEC_02_学習・評価仕様.md)「前任者の手法との比較」).`cv_pred_resnet34_*`(ResNet34.`color_shift_*` は色を変えた疑似画像)は `tias-train cv`,`cv_color_svm_*`(`lateral`: 苔の除去なし,`coat_removed`: 最終コードのしきい値,`coat_removed_slide`: スライドのしきい値)は `tias-train color-cv` | | `configs/predecessor/synthetic/*.yaml` | 上の手元用(ResNet34 系 3 本・SVM 3 本.`TIASDATA_BUNDLES=data/synthetic_bundles` で合成バンドル `tongue_color_synthetic` を読む.実データとは別の名前なので,サーバで動かしても実データを読まずに止まる) | +| `configs/predecessor_first_round/*.yaml` | 前任者の手法を並木先生の 1 回目のラベルで動かす追実験(`configs/predecessor/` の 12 本と `data.bundle` 以外は同じ.`cv_first_round_pred_resnet34_*` は `tias-train cv`,`cv_first_round_color_svm_*` は `tias-train color-cv`.[SPEC_02](../04_SPEC/SPEC_02_学習・評価仕様.md)「1 回目のラベルでの実行」) | +| `configs/predecessor_first_round/synthetic/*.yaml` | 上の手元用(ResNet34・SVM の `lateral`・`coat_removed` の 3 本.`TIASDATA_BUNDLES=data/synthetic_bundles_first_round` で合成バンドル `tongue_color_first_round_synthetic` を読む) | **サーバでの実行例**: @@ -106,6 +110,7 @@ - 色特徴分類器は GPU を使わないので `--cpu` で回す(例: `uv run tias-remote run --name color1 --cpu --server Archimedes -- bash -c "tias-train color-cv --config configs/color/cv_color_logistic_with_mild.yaml;"`).1 本は Archimedes で約 1 分・Newton で約 2 分(大半が画像の読み込みと特徴抽出.2026-09-28 実測) - 前任者の手法の比較も同じ形で回す(例: `uv run tias-remote run --name pred1 -- tias-train cv --config configs/predecessor/cv_pred_resnet34_with_mild.yaml`.SVM は `--cpu` で `tias-train color-cv`).Newton の RTX A6000 で ResNet34 は 1 本 13〜21 分.SVM は特徴量の列で数秒,苔の除去で約 1.5 分(2026-11-01 実測) +- 1 回目のラベルの追実験も同じ形で回す(例: `uv run tias-remote run --name pred1 -- tias-train cv --config configs/predecessor_first_round/cv_first_round_pred_resnet34_with_mild.yaml`) - ConvNeXt-Tiny の 5-fold 交差検証 1 本は Archimedes の RTX A6000 で約 2.5 分(2026-09-28 実測.画像の読み込み約 8 秒を含む) - 事前学習の重みは初回にサーバが Hugging Face からダウンロードする(`~/.cache/huggingface`) - ログに出る `lr_scheduler.step() before optimizer.step()` の警告は,混合精度で最初の数ステップの勾配がオーバーフローして捨てられたときに出るもので無害 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" index 08a2c7f..bd09cc7 100644 --- "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" @@ -50,8 +50,8 @@ | --- | --- | --- | | `image_path` | 画像ディレクトリからの相対パス | `path` から `files/` を除いたもの | | `patient_id` | 患者を一意に識別する ID.**必須**.分割の単位になる | `subject_id`(患者単位.現行の版 3 で 449 人) | -| `label` | 舌色 5 分類のいずれか | 所見 `tongue_color` の `label` | -| `severity` | 程度(`strong` / `mild` / `normal`).学習には使わず,評価の層別分析に使う | 所見 `tongue_color` の `severity` | +| `label` | 舌色 5 分類のいずれか | `data.bundle.label_kind` の所見(既定 `tongue_color`)の `label` | +| `severity` | 程度(`strong` / `mild` / `normal`).学習には使わず,評価の層別分析に使う | 所見 `tongue_color` の `severity`.`label_kind: tongue_color_first_round` では `level` を変換したもの([SPEC_02](SPEC_02_学習・評価仕様.md)「1 回目のラベルでの実行」) | | `note` | 任意の備考(除外理由等) | 空 | - **1 人の患者が複数の画像を持ち,画像ごとに異なる `label` を持つことがある**(`tongue_color` の版 1 で 450 人中 179 人・696 枚).不正なデータとして扱わない @@ -59,7 +59,7 @@ - **実験の記録**: バンドルの指紋(`name`・`version`・`manifest_sha256`)を実験の出力に残す(「実験の出力」).患者 ID を含まないので回収してよい - **`survey` だけが全ファイルの SHA-256 を照合する**(`Bundle.verify`).時間がかかるので `cv`・`color-cv`・`color-export` は照合しない - バンドルの例外の文面はハッシュを伏せ,ファイルを読めないとき(`OSError`)はパスもハッシュも含まない固定の文面で止める(バンドルのファイル名はハッシュであり,ログは回収対象のため) -- 種類が `tongue_crop_masked` でない行・パスの形が想定と違う行・所見が欠けた行があれば,変換せずに止める +- 種類が `tongue_crop_masked` でない行・パスの形が想定と違う行・`label_kind` の所見が欠けた行があれば,変換せずに止める.`label_kind` でない所見の列は読まない(`tongue_color_first_round` の設定では `tongue_color` が空でも止めない) ### 合成データの配置 (Synthetic Data Layout) @@ -92,6 +92,7 @@ | キー | 内容 | 既定値 | | --- | --- | --- | | `data.bundle.name`・`data.bundle.version` | TIASDataHub のバンドルの名前と版(実データはこちら.例: `tongue_color`・`2`).`data.root` とはどちらか一方だけを指定する | なし | +| `data.bundle.label_kind` | ラベルに使う所見(`tongue_color`・`tongue_color_first_round`.未知の値は設定の読み込みで止める).`tongue_color_first_round` は `level` を `severity` に変換する([SPEC_02](SPEC_02_学習・評価仕様.md)「1 回目のラベルでの実行」) | `tongue_color` | | `data.root` | 合成データのルート(`images/` と manifest を含む).`~` を展開する.相対パスはカレントディレクトリ基準 | なし | | `data.manifest` | manifest のパス.相対パスは `data.root` 基準.`data.bundle` とは同時に指定できない | `manifest.csv`(`data.root` のとき) | | `data.severities` | 学習・評価に使う程度(`strong`・`mild`・`normal` の部分集合).空・重複・未知の値は不可.**分割の後に適用する**([SPEC_02](SPEC_02_学習・評価仕様.md)「程度(ややあり)の扱い」) | `[strong, mild, normal]` | diff --git "a/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273\350\251\225\344\276\241\344\273\225\346\247\230.md" "b/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273\350\251\225\344\276\241\344\273\225\346\247\230.md" index f1b16fa..50d83df 100644 --- "a/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273\350\251\225\344\276\241\344\273\225\346\247\230.md" +++ "b/docs/04_SPEC/SPEC_02_\345\255\246\347\277\222\343\203\273\350\251\225\344\276\241\344\273\225\346\247\230.md" @@ -18,7 +18,7 @@ ※ 撮影条件差の吸収のために色系の拡張を試す場合は,**独立した実験**として効果を測る. -※ 例外: 前任者の手法を動かし直す比較の設定(`configs/predecessor/`)に限り,`train.augmentation.color_jitter` と `train.color_shift_pseudo` で色を変える処理を明示的に有効にする(下記「前任者の手法との比較」).既定は無効のまま. +※ 例外: 前任者の手法を動かし直す比較の設定(`configs/predecessor/`・`configs/predecessor_first_round/`)に限り,`train.augmentation.color_jitter` と `train.color_shift_pseudo` で色を変える処理を明示的に有効にする(下記「前任者の手法との比較」).既定は無効のまま. ## モデル (Model) @@ -252,7 +252,7 @@ ## 前任者の手法との比較 (Predecessor Comparison) -前任者(鈴木さん)の 4 手法を今のデータ(TIASDataHub の版 3)で動かし直し,今のモデルと同じ分割・同じ評価で比べる.**ラベルを付け直したので前任者の数字はそのまま比べない**.前任者のリポジトリのコード・データは使わず,説明とスライドの値から実装した.設定は `configs/predecessor/` にある. +前任者(鈴木さん)の 4 手法を今のデータ(TIASDataHub の版 3)で動かし直し,今のモデルと同じ分割・同じ評価で比べる.**ラベルを付け直したので前任者の数字はそのまま比べない**.前任者のリポジトリのコード・データは使わず,説明とスライドの値から実装した.設定は `configs/predecessor/` にある.並木先生の 1 回目のラベルで動かす追実験の設定は `configs/predecessor_first_round/` にある(下記「1 回目のラベルでの実行」). | 手法 | コマンド | 設定(`<条件>` は `with_mild`・`without_mild`) | | --- | --- | --- | @@ -342,6 +342,42 @@ | 疑似画像の元画像 | 近い色から(版ごとに違う) | 変換先以外から一様 | 上記「元画像の選び方の決定」 | | 舌本体が空の画像 | 例外 | 件数を示して止める | 黙って除かない | +### 1 回目のラベルでの実行 (First Round Labels) + +前任者の追実験として,同じ 4 手法を並木先生の 1 回目のラベル(TIASDataHub のデータセット `tongue_color_first_round` の版 1.1133 枚)で動かす.設定は `configs/predecessor_first_round/` の 12 本で,上の表の設定と `data.bundle` 以外は同じである(分割の seed も 42). + +| 上の表の設定 | 1 回目のラベルの設定 | +| --- | --- | +| `cv_pred_resnet34_<条件>.yaml` | `cv_first_round_pred_resnet34_<条件>.yaml` | +| `cv_pred_resnet34_color_shift_<モード>_<条件>.yaml` | `cv_first_round_pred_resnet34_color_shift_<モード>_<条件>.yaml` | +| `cv_color_svm_lateral_<条件>.yaml` | `cv_first_round_color_svm_lateral_<条件>.yaml` | +| `cv_color_svm_coat_removed_<条件>.yaml` | `cv_first_round_color_svm_coat_removed_<条件>.yaml` | +| `cv_color_svm_coat_removed_slide_<条件>.yaml` | `cv_first_round_color_svm_coat_removed_slide_<条件>.yaml` | + +実験 ID は設定ファイル名から作るので,`<日時>_cv_first_round_<手法>_<条件>_<コミット>` になり,新しいラベルの run と名前で見分けられる. + +**ラベルの読み方**: `data.bundle.label_kind: tongue_color_first_round` で所見 `tongue_color_first_round`(`label`・`level`)を読む.同じ manifest の所見 `tongue_color`(新しいラベル.65 行は空)の列は読まない.特徴量は既存と同じ所見 `deeptias_features` の 15 列を読む. + +**程度の変換**: `level` を次のように `severity` に変換し,既存の `validate_records` を通す. + +| `label` | `level` | `severity` | +| --- | --- | --- | +| `light_red` | 1(YES) | `normal` | +| `light_red` 以外 | 1(ややあり) | `mild` | +| `light_red` 以外 | 2(あり)・3(非常にあり) | `strong` | + +- 2 と 3 は同じ `strong` にまとめる.新しいラベルの比較と同じ 2 条件(`with_mild`・`without_mild`)で動かすため +- `light_red` の `level` 2・3,範囲外や空の値,未知の `label` は,件数と最初の行番号を示して止める(黙って除外しない).`level` は manifest の文字列 `1`・`2`・`3` だけを認める + +**新しいラベルの比較([TEST_08](../06_TEST/TEST_08_前任者の手法との比較.md))と比べるときの注意**: + +- 画像の集合が違う(TEST_08 は 1076 枚,こちらは 1133 枚).分割は画像の集合と層化のグループに依存するので,同じ seed でも分割は同じにならない.**差はラベルだけの影響とは言えない**.fold ごとの対応比較もできない +- 分割は上記の変換後の `