Image Classification
Transformers
Safetensors
Flair
vit
medical-imaging
brain-tumor
mri
vision-transformer
Instructions to use Songline/BrainTumor_FlairClassifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Songline/BrainTumor_FlairClassifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Songline/BrainTumor_FlairClassifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Songline/BrainTumor_FlairClassifier") model = AutoModelForImageClassification.from_pretrained("Songline/BrainTumor_FlairClassifier", device_map="auto") - Flair
How to use Songline/BrainTumor_FlairClassifier with Flair:
from flair.models import SequenceTagger tagger = SequenceTagger.load("Songline/BrainTumor_FlairClassifier") - Notebooks
- Google Colab
- Kaggle
| license: mit | |
| library_name: transformers | |
| pipeline_tag: image-classification | |
| base_model: google/vit-base-patch16-224-in21k | |
| tags: | |
| - medical-imaging | |
| - brain-tumor | |
| - mri | |
| - flair | |
| - vision-transformer | |
| # Brain Tumor FLAIR Classifier | |
| 基于单份三维 FLAIR NIfTI 的脑肿瘤病例级二分类模型 | |
| 模型基于 `google/vit-base-patch16-224-in21k` 微调 | |
| 输入 `.nii` 或 `.nii.gz` | |
| 输出 `yes_probability` 与 `yes` 或 `no` 分类结果 | |
| ## Model Details | |
| | 项目 | 内容 | | |
| | --- | --- | | |
| | 架构 | Vision Transformer | | |
| | 输入 | 三维 FLAIR NIfTI | | |
| | 病例聚合 | 25 张轴位有效切片的阳性概率均值 | | |
| | 冻结阈值 | `0.548381` | | |
| | 权重格式 | `safetensors` | | |
| ## Quick Start | |
| ```powershell | |
| git lfs install | |
| git clone <repository-url> | |
| cd brain-tumor-flair-classifier | |
| git lfs pull | |
| python -m venv .venv | |
| .\.venv\Scripts\Activate.ps1 | |
| pip install -e . | |
| python examples\infer.py --input path\to\flair.nii.gz --output outputs\result.json | |
| ``` | |
| GPU 可用时默认使用 CUDA | |
| ```powershell | |
| python examples\infer.py --input path\to\flair.nii.gz --device cpu | |
| ``` | |
| ## Python API | |
| ```python | |
| from brain_tumor_flair_classifier import FlairClassifier | |
| classifier = FlairClassifier.from_pretrained('本地模型目录') | |
| result = classifier.predict_nifti('path/to/flair.nii.gz') | |
| print(result['yes_probability']) | |
| ``` | |
| 发布到 Hugging Face 后可直接使用模型 ID | |
| ```python | |
| classifier = FlairClassifier.from_pretrained('用户名/模型仓库名') | |
| ``` | |
| ## Output | |
| ```json | |
| { | |
| "model_version": "v1", | |
| "threshold": 0.548381, | |
| "predicted_class": "yes", | |
| "yes_probability": 0.721431, | |
| "no_probability": 0.278569, | |
| "evaluated_slices": 25 | |
| } | |
| ``` | |
| ## Evaluation | |
| | 数据范围 | 分类结果 | | |
| | --- | --- | | |
| | 内部固定测试 | 29 / 30 正确 | | |
| | UCSF-PDGM 外部开发阳性集 | 灵敏度 16 / 20 | | |
| | HBN-SSI 外部开发健康集 | 特异度 12 / 12 | | |
| | UPENN-GBM 最终盲测阳性集 | 灵敏度 9 / 10 | | |
| | OpenNeuro ds003592 最终盲测健康集 | 特异度 10 / 10 | | |
| | 合并最终盲测分类 | 19 / 20 正确 | | |
| 完整数据边界和评测说明见 [docs/evaluation.md](docs/evaluation.md) | |
| ## Files | |
| - `config.json` 模型配置 | |
| - `model.safetensors` 微调权重 | |
| - `preprocessor_config.json` 图像预处理配置 | |
| - `examples/infer.py` NIfTI 推理示例 | |
| - `NOTICE.md` 第三方组件与数据来源 | |
| ## License | |
| 代码采用 [MIT License](LICENSE) | |