Replace colour model with binary lesion model v0.2.0
Browse filesFinal 51-epoch model trained on all 1,465 images; outputs background/lesion only.
- README.md +32 -36
- config.json +20 -10
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -6,7 +6,7 @@ library_name: cervicalseg
|
|
| 6 |
tags:
|
| 7 |
- medical-imaging
|
| 8 |
- cervical
|
| 9 |
-
-
|
| 10 |
- dinov3
|
| 11 |
- dpt
|
| 12 |
- wtconv
|
|
@@ -14,80 +14,76 @@ tags:
|
|
| 14 |
|
| 15 |
# CervicalSeg
|
| 16 |
|
| 17 |
-
CervicalSeg is a
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
宫颈阴道镜图像
|
| 22 |
-
融合阶段使用 WTConv。
|
| 23 |
|
| 24 |
## Classes / 类别
|
| 25 |
|
| 26 |
-
| Index | Class |
|
| 27 |
|---:|---|---|
|
| 28 |
-
| 0 | background |
|
| 29 |
-
| 1 |
|
| 30 |
-
| 2 | green | green |
|
| 31 |
-
| 3 | red | red |
|
| 32 |
|
| 33 |
## Usage / 使用方法
|
| 34 |
|
| 35 |
```bash
|
| 36 |
-
pip install cervicalseg
|
| 37 |
```
|
| 38 |
|
| 39 |
-
Use `cervicalseg>=0.1.1` for compatibility with both Transformers 4.56+ and 5.x DINOv3 module
|
| 40 |
-
layouts.
|
| 41 |
-
|
| 42 |
-
请使用 `cervicalseg>=0.1.1`,以兼容 Transformers 4.56+ 与 5.x 的两种 DINOv3 模块命名。
|
| 43 |
-
|
| 44 |
```python
|
| 45 |
from cervicalseg import CervicalSeg
|
| 46 |
|
| 47 |
segmenter = CervicalSeg(device="auto")
|
| 48 |
result = segmenter.predict("image.jpg")
|
| 49 |
-
|
| 50 |
-
result.
|
|
|
|
| 51 |
result.save_overlay("overlay.jpg")
|
| 52 |
```
|
| 53 |
|
| 54 |
The first call downloads `model.safetensors`; later calls reuse the Hugging Face cache. Output masks
|
| 55 |
-
are restored to the original image size.
|
|
|
|
| 56 |
|
| 57 |
首次调用会下载 `model.safetensors`,后续调用复用 Hugging Face 缓存。输出 mask 会恢复到原图尺寸。
|
|
|
|
| 58 |
|
| 59 |
-
##
|
| 60 |
-
|
| 61 |
-
The data were split at the patient level to prevent patient leakage between train, validation, and
|
| 62 |
-
test sets.
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
| Test | 216 | 0.3633 | 0.5296 | 0.8891 |
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
| blue | 0.5651 | 0.5697 | 0.5674 | 0.3961 |
|
| 76 |
-
| green | 0.3784 | 0.4950 | 0.4289 | 0.2730 |
|
| 77 |
-
| red | 0.6850 | 0.5219 | 0.5924 | 0.4209 |
|
| 78 |
|
| 79 |
## Intended use and limitations / 用途与限制
|
| 80 |
|
| 81 |
- Research use only.
|
| 82 |
- Not a medical device and not for clinical diagnosis or treatment decisions.
|
| 83 |
- Predictions require review by qualified professionals.
|
|
|
|
| 84 |
- Performance may not generalize to devices, institutions, populations, or acquisition conditions
|
| 85 |
not represented in the training data.
|
| 86 |
-
- Green-region segmentation is the weakest class in the reported test results.
|
| 87 |
|
| 88 |
- 仅用于研究。
|
| 89 |
- 不是医疗器械,不得直接用于临床诊断或治疗决策。
|
| 90 |
- 预测结果需要由具备资质的专业人员复核。
|
|
|
|
| 91 |
- 对训练数据未覆盖的设备、机构、人群和采集条件,模型性能可能下降。
|
| 92 |
|
| 93 |
## License / 许可证
|
|
|
|
| 6 |
tags:
|
| 7 |
- medical-imaging
|
| 8 |
- cervical
|
| 9 |
+
- binary-segmentation
|
| 10 |
- dinov3
|
| 11 |
- dpt
|
| 12 |
- wtconv
|
|
|
|
| 14 |
|
| 15 |
# CervicalSeg
|
| 16 |
|
| 17 |
+
CervicalSeg is a binary lesion segmentation model for cervical colposcopy images. It combines a
|
| 18 |
+
DINOv3 ViT-S/16 backbone, a DPT decoder, and WTConv in the final two high-resolution decoder fusion
|
| 19 |
+
stages. It predicts the lesion region only and does not classify red, blue, or green annotation
|
| 20 |
+
categories.
|
| 21 |
|
| 22 |
+
CervicalSeg 是宫颈阴道镜图像二分类病灶分割模型,采用 DINOv3 ViT-S/16、DPT 解码器,并在最后
|
| 23 |
+
两个高分辨率融合阶段使用 WTConv。模型只预测病灶区域,不再区分红、蓝、绿标注类别。
|
| 24 |
|
| 25 |
## Classes / 类别
|
| 26 |
|
| 27 |
+
| Index | Class | Meaning |
|
| 28 |
|---:|---|---|
|
| 29 |
+
| 0 | background | non-lesion region / 非病灶区域 |
|
| 30 |
+
| 1 | lesion | lesion region / 病灶区域 |
|
|
|
|
|
|
|
| 31 |
|
| 32 |
## Usage / 使用方法
|
| 33 |
|
| 34 |
```bash
|
| 35 |
+
pip install "cervicalseg>=0.2.0"
|
| 36 |
```
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
```python
|
| 39 |
from cervicalseg import CervicalSeg
|
| 40 |
|
| 41 |
segmenter = CervicalSeg(device="auto")
|
| 42 |
result = segmenter.predict("image.jpg")
|
| 43 |
+
|
| 44 |
+
# result.mask contains only 0=background and 1=lesion.
|
| 45 |
+
result.save_mask("mask.png") # binary PNG containing 0 and 255
|
| 46 |
result.save_overlay("overlay.jpg")
|
| 47 |
```
|
| 48 |
|
| 49 |
The first call downloads `model.safetensors`; later calls reuse the Hugging Face cache. Output masks
|
| 50 |
+
are restored to the original image size. The single overlay colour is for visualization only and is
|
| 51 |
+
not a lesion subtype.
|
| 52 |
|
| 53 |
首次调用会下载 `model.safetensors`,后续调用复用 Hugging Face 缓存。输出 mask 会恢复到原图尺寸。
|
| 54 |
+
叠加图中的单一颜色仅用于显示病灶范围,不代表病灶类别。
|
| 55 |
|
| 56 |
+
## Training and evaluation / 训练与评估
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
The public v0.2.0 checkpoint was trained for 51 epochs on all 1,465 available images: 1,028 from the
|
| 59 |
+
original training split, 221 from validation, and 216 from test. All non-background annotations were
|
| 60 |
+
merged into one lesion label. Because all samples were used to fit the final model, no held-out test
|
| 61 |
+
metric applies to this public checkpoint.
|
| 62 |
|
| 63 |
+
公开的 v0.2.0 权重使用全部 1,465 张图像训练 51 个 epoch,其中原 train/val/test 分别为
|
| 64 |
+
1,028/221/216 张。所有非背景标注合并为一个病灶标签。由于最终模型使用了全部样本训练,因此该
|
| 65 |
+
公开权重没有独立测试集指标。
|
|
|
|
| 66 |
|
| 67 |
+
For model-development reference only, the separate patient-level validation experiment at epoch 51
|
| 68 |
+
obtained lesion IoU 0.5847 and lesion Dice 0.7379. These are development results, not an independent
|
| 69 |
+
evaluation of the all-data public checkpoint.
|
| 70 |
|
| 71 |
+
仅供模型开发参考:按患者划分的独立验证实验在第 51 个 epoch 得到病灶 IoU 0.5847、病灶 Dice
|
| 72 |
+
0.7379;这些结果不是对全量训练公开权重的独立测试。
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
## Intended use and limitations / 用途与限制
|
| 75 |
|
| 76 |
- Research use only.
|
| 77 |
- Not a medical device and not for clinical diagnosis or treatment decisions.
|
| 78 |
- Predictions require review by qualified professionals.
|
| 79 |
+
- The model detects lesion extent but does not predict lesion grade, pathology, or colour category.
|
| 80 |
- Performance may not generalize to devices, institutions, populations, or acquisition conditions
|
| 81 |
not represented in the training data.
|
|
|
|
| 82 |
|
| 83 |
- 仅用于研究。
|
| 84 |
- 不是医疗器械,不得直接用于临床诊断或治疗决策。
|
| 85 |
- 预测结果需要由具备资质的专业人员复核。
|
| 86 |
+
- 模型仅检测病灶范围,不预测病灶分级、病理结果或颜色类别。
|
| 87 |
- 对训练数据未覆盖的设备、机构、人群和采集条件,模型性能可能下降。
|
| 88 |
|
| 89 |
## License / 许可证
|
config.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
{
|
| 2 |
-
"format_version":
|
| 3 |
"model": {
|
| 4 |
"class_names": [
|
| 5 |
"background",
|
| 6 |
-
"
|
| 7 |
-
"green",
|
| 8 |
-
"red"
|
| 9 |
],
|
| 10 |
"image_size": [
|
| 11 |
576,
|
|
@@ -75,11 +73,23 @@
|
|
| 75 |
},
|
| 76 |
"checkpoint": {
|
| 77 |
"filename": "model.safetensors",
|
| 78 |
-
"size_bytes":
|
| 79 |
-
"sha256": "
|
| 80 |
-
"training_epoch":
|
| 81 |
-
"
|
| 82 |
-
"
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"format_version": 2,
|
| 3 |
"model": {
|
| 4 |
"class_names": [
|
| 5 |
"background",
|
| 6 |
+
"lesion"
|
|
|
|
|
|
|
| 7 |
],
|
| 8 |
"image_size": [
|
| 9 |
576,
|
|
|
|
| 73 |
},
|
| 74 |
"checkpoint": {
|
| 75 |
"filename": "model.safetensors",
|
| 76 |
+
"size_bytes": 96875968,
|
| 77 |
+
"sha256": "2322f48bf36f0fdf77f090c5621c8d31aa6892b51000d40e42f7f43b23c29b98",
|
| 78 |
+
"training_epoch": 51,
|
| 79 |
+
"checkpoint_selection": "final_epoch",
|
| 80 |
+
"training_splits": [
|
| 81 |
+
"train",
|
| 82 |
+
"val",
|
| 83 |
+
"test"
|
| 84 |
+
],
|
| 85 |
+
"training_sample_counts": {
|
| 86 |
+
"train": 1028,
|
| 87 |
+
"val": 221,
|
| 88 |
+
"test": 216
|
| 89 |
+
},
|
| 90 |
+
"training_samples_total": 1465,
|
| 91 |
+
"final_training_loss": 0.08957859227885158,
|
| 92 |
+
"development_validation_foreground_iou_epoch_51": 0.5847087461680525,
|
| 93 |
+
"development_validation_foreground_dice_epoch_51": 0.7379384351628312
|
| 94 |
}
|
| 95 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2322f48bf36f0fdf77f090c5621c8d31aa6892b51000d40e42f7f43b23c29b98
|
| 3 |
+
size 96875968
|