Update README.md
Browse filesAdd instructions for using medical adapters
README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
license: apache-2.0
|
3 |
pipeline_tag: image-segmentation
|
4 |
tags:
|
5 |
-
-
|
6 |
---
|
7 |
|
8 |
-
Welcome Medical Adapters Zoo (Med-Adpt Zoo)!
|
9 |
|
10 |
## Med-Adpt Zoo Map 🐘🐊🦍🦒🦨🦜🦥
|
11 |
|
@@ -27,14 +27,42 @@ Check our paper: [Medical SAM Adapter](https://arxiv.org/abs/2304.12620) for the
|
|
27 |
|
28 |
## Why
|
29 |
|
30 |
-
SAM (Segment Anything Model) is one of the most popular open
|
31 |
An efficient way to solve it is using Adapters, i.e., some layers with a few parameters to be added to the pre-trained SAM model to fine-tune it to the target down-stream tasks.
|
32 |
Medical image segmentation includes many different organs, lesions, abnormalities as the targets.
|
33 |
-
So we are training different
|
34 |
|
35 |
Download an adapter for your target disease—trained on organs, lesions, and abnormalities—and effortlessly enhance SAM.
|
36 |
|
37 |
-
One adapter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
## Authorship
|
40 |
|
|
|
2 |
license: apache-2.0
|
3 |
pipeline_tag: image-segmentation
|
4 |
tags:
|
5 |
+
- medical
|
6 |
---
|
7 |
|
8 |
+
Welcome to Medical Adapters Zoo (Med-Adpt Zoo)!
|
9 |
|
10 |
## Med-Adpt Zoo Map 🐘🐊🦍🦒🦨🦜🦥
|
11 |
|
|
|
27 |
|
28 |
## Why
|
29 |
|
30 |
+
SAM (Segment Anything Model) is one of the most popular open models for image segmentation. Unfortunately, it does not perform well on the medical images.
|
31 |
An efficient way to solve it is using Adapters, i.e., some layers with a few parameters to be added to the pre-trained SAM model to fine-tune it to the target down-stream tasks.
|
32 |
Medical image segmentation includes many different organs, lesions, abnormalities as the targets.
|
33 |
+
So we are training different adapters for each of the targets, and sharing them here for the easy usage in the community.
|
34 |
|
35 |
Download an adapter for your target disease—trained on organs, lesions, and abnormalities—and effortlessly enhance SAM.
|
36 |
|
37 |
+
One adapter transfers your SAM to a medical domain expert. Give it a try!
|
38 |
+
|
39 |
+
## How to Use
|
40 |
+
|
41 |
+
1. Download the code of our MedSAM-Adapter [here](https://github.com/KidsWithTokens/Medical-SAM-Adapter).
|
42 |
+
2. Download the weights of the original SAM model.
|
43 |
+
3. Load the original model and our adapter for downstream tasks.
|
44 |
+
|
45 |
+
```python
|
46 |
+
import torch
|
47 |
+
import torchvision.transforms as transforms
|
48 |
+
|
49 |
+
import cfg
|
50 |
+
from utils import *
|
51 |
+
|
52 |
+
# set your own configs
|
53 |
+
args = cfg.parse_args()
|
54 |
+
GPUdevice = torch.device('cuda', args.gpu_device)
|
55 |
+
|
56 |
+
# load the original SAM model
|
57 |
+
net = get_network(args, args.net, use_gpu=args.gpu, gpu_device=GPUdevice, distribution = args.distributed)
|
58 |
+
|
59 |
+
# load task-specific adapter
|
60 |
+
adapter_path = 'OpticCup_Fundus_SAM_1024.pth'
|
61 |
+
adapter = torch.load(adapter_path)['state_dict']
|
62 |
+
for name, param in adapter.items():
|
63 |
+
if name in adapter:
|
64 |
+
net.state_dict()[name].copy_(param)
|
65 |
+
```
|
66 |
|
67 |
## Authorship
|
68 |
|