Skip to content

Commit f794678

Browse files
author
Mark-ZhouWX
committed
update finetune to README.md
1 parent 56df163 commit f794678

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

research/segment-anything/README.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,62 @@ Since SAM can efficiently process prompts, masks for the entire image can be gen
6868
python use_sam_with_amg.py --model-type vit_h
6969
```
7070

71-
<p float="left">
72-
<img alt="img.png" width="400" src="images/dengta.jpg"/>
73-
<img alt="img.png" width="400" src="images/dengta-amg-vith.png"/>
74-
</p>
71+
<div align="center">
72+
<img src="images/dengta.jpg" height="350" />
73+
    
74+
<img src="images/dengta-amg-vith.png" height="350" />
75+
</div>
7576

7677
See `python use_sam_with_amg.py --help` to explore more custom settings.
7778

7879
## Finetune
7980

80-
To be continued
81+
Finetune is a popular method that adapts large pretrained model to specific downstream tasks. Currently, finetune with box-prompt are supported. The bounding boxes are used as prompt input to predict mask.
82+
Beside fine-tuning our code on COCO2017 dataset which contains common seen objects and lies in the similar distribution of the original [training dataset](https://segment-anything.com/dataset/index.html)) of SAM, We have done further experiments on a medical imaging segmentation dataset [FLARE22](https://flare22.grand-challenge.org/Dataset/). Result shows that the finetune method in this repository is effective.
83+
84+
The bellowing shows the mask quality before and after finetune.
85+
86+
87+
| pretrained_model | dataset | epochs | mIOU |
88+
| :--------------: | -------- | :-----------: | ---- |
89+
| sam-vit-b | COCO2017 | 0 (zero-shot) | 77.4 |
90+
| sam-vit-b | COCO2017 | 20 | 83.6 |
91+
| sam-vit-b | FLARE22 | 0 (zero-shot) | 79.5 |
92+
| sam-vit-b | FLARE22 | 10 | 88.1 |
93+
94+
To finetune COCO dataset, please run:
95+
96+
```shell
97+
mpirun --allow-run-as-root -n 8 python train.py -c configs/coco_box_finetune.yaml
98+
```
99+
100+
The original FLARE22 dataset contains image in 3D format and ground truth labelled as instance segmentation ids. Run
101+
102+
```shell
103+
python scripts/preprocess_CT_MR_dataset.py
104+
```
105+
106+
to preprocess it to the format of 2D RGB image and binary mask
107+
108+
To finetune FLARE22 dataset, please run:
109+
110+
```shell
111+
mpirun --allow-run-as-root -n 8 python train.py -c configs/flare_box_finetune.yaml
112+
```
113+
114+
Here are the examples of segmentation result predicted by fine-tuned SAM:
115+
116+
<div align="center">
117+
<img src="images/coco_bear.jpg" height="350" />
118+
  
119+
<img src="images/flare_organ.jpg" height="350" />
120+
</div>
121+
122+
<p align="center">
123+
<em> COCO2017 image example</em>
124+
                      
125+
                      
126+
<em> FLARE22 image example </em>
127+
</p>
128+
129+
109 KB
Loading
70.3 KB
Loading

0 commit comments

Comments
 (0)