Typer CLI package for the Vit medical multi-axis Vision Transformer project.
Project description
btvit-cli
基于 PyTorch 的三轴 ViT 医学影像二分类 CLI。
安装
pip install btvit-cli
vit --version
当前主线
项目现在只保留一条流程:
axis阶段分别训练x / y / z三个轴的单轴 ViTfusion阶段复用三轴 encoder,训练患者级fusion_nn头pred阶段支持两种患者级输出:weighted_votefusion_nnboth
每个患者的每张 (16, 368) 灰度图都作为独立样本共享患者标签,不再使用旧的中间特征缓存或跨轴组合穷举训练流程。
快速开始
1. 导出模板
vit get --path ./configs
导出内容:
model_config.yamldata_config.yamltraining_config.yamlexperiment_config.yamlmulti_axis_config.yamlmonitoring_config.yamlUSAGE.md
2. 训练三轴 ViT
vit train --config configs/base --stage axis --axis x --verbose
vit train --config configs/base --stage axis --axis y --verbose
vit train --config configs/base --stage axis --axis z --verbose
关键参数:
--stage axis--axis x|y|z--config <yaml_dir>--data可选。未提供时使用multi_axis.axis_data_paths.<axis>--label可选。未提供时使用配置文件中的标签路径
3. 训练 fusion 头
vit train --config configs/base --stage fusion --fusion concat --verbose
fusion 阶段会默认解析:
experiments/<name>/axis-x/checkpoints/best_model.pthexperiments/<name>/axis-y/checkpoints/best_model.pthexperiments/<name>/axis-z/checkpoints/best_model.pth
也可以显式覆盖:
--axis-checkpoint-x--axis-checkpoint-y--axis-checkpoint-z--fusion sum|concat
4. 患者级预测
vit pred --mode weighted_vote --config configs/base --data dataset/predict_root
vit pred --mode fusion_nn --config configs/base --data dataset/predict_root --fusion concat
vit pred --mode both --config configs/base --data dataset/predict_root --label dataset/label.csv --fusion sum
预测模式:
weighted_vote:单图概率 -> 轴内患者均值 -> 三轴均值;均值> 2/3判阳性fusion_nn:单图特征 -> 轴内患者均值 ->sum|concat-> fusion headboth:同时输出两条分支
预测数据支持:
- 根目录包含
data-x/、data-y/、data-z/ - 平铺 PNG 目录,文件名为
{patient_id}_{Z}_{Y}_{X}.png
输出结构
训练输出:
experiments/<experiment_name>/
axis-x/
checkpoints/
results/
logs/
axis-y/
checkpoints/
results/
logs/
axis-z/
checkpoints/
results/
logs/
fusion/
checkpoints/
results/
logs/
testset/
data-x/
data-y/
data-z/
label.csv
预测输出:
predictions.csvprediction_summary.jsonconfusion_matrix_weighted_vote.png,当有标签且启用weighted_voteconfusion_matrix_fusion_nn.png,当有标签且启用fusion_nn
配置要点
training.common:设备、worker、混合精度等公共训练参数training.axis:单轴 ViT 训练参数training.fusion:fusion 头训练参数multi_axis.patient_pooling:患者内均值聚合规则multi_axis.weighted_vote:固定三轴投票开关multi_axis.fusion_head:患者级 fusion 头配置,包含fusion: sum|concatmonitoring.axis / monitoring.fusion / monitoring.prediction:分阶段监控与fusion_nn预测阈值
开发
conda activate Vit
pip install -e .
vit --help
构建:
conda run -n Vit python -m build
许可证
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
btvit_cli-0.2.4.tar.gz
(140.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
btvit_cli-0.2.4-py3-none-any.whl
(127.1 kB
view details)
File details
Details for the file btvit_cli-0.2.4.tar.gz.
File metadata
- Download URL: btvit_cli-0.2.4.tar.gz
- Upload date:
- Size: 140.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750fe5b3d067584519b4099ec63270e7b4f4cfa97761434e9d4eef317a0c25d3
|
|
| MD5 |
a147f06d86adda0d154606b3e087302d
|
|
| BLAKE2b-256 |
faf634624b8f7360273c401a55372611cf8441231b545fd08c133c61f686299b
|
File details
Details for the file btvit_cli-0.2.4-py3-none-any.whl.
File metadata
- Download URL: btvit_cli-0.2.4-py3-none-any.whl
- Upload date:
- Size: 127.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29032d316bc46e15def5b2ff636dc5c7f12647979180d2c797767f7b7189af5c
|
|
| MD5 |
0b0a2b39223c5752b0f3dfd287955a86
|
|
| BLAKE2b-256 |
f4f5ab1357166eb2f6e4db3a27197b70c8d4858c5b809f28c1d1b0650fe45ebd
|