Update README.md
Browse files
README.md
CHANGED
@@ -4,45 +4,18 @@ pipeline_tag: mask-generation
|
|
4 |
library_name: sam2
|
5 |
---
|
6 |
|
7 |
-
|
|
|
8 |
|
9 |
-
The official code is publicly release in this [repo](https://github.com/facebookresearch/segment-anything-2/).
|
10 |
|
11 |
## Usage
|
12 |
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
```python
|
16 |
-
import torch
|
17 |
-
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
18 |
-
|
19 |
-
predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-small")
|
20 |
-
|
21 |
-
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
|
22 |
-
predictor.set_image(<your_image>)
|
23 |
-
masks, _, _ = predictor.predict(<input_prompts>)
|
24 |
-
```
|
25 |
-
|
26 |
-
For video prediction:
|
27 |
-
|
28 |
-
```python
|
29 |
-
import torch
|
30 |
-
from sam2.sam2_video_predictor import SAM2VideoPredictor
|
31 |
-
|
32 |
-
predictor = SAM2VideoPredictor.from_pretrained("facebook/sam2-hiera-small")
|
33 |
-
|
34 |
-
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
|
35 |
-
state = predictor.init_state(<your_video>)
|
36 |
-
|
37 |
-
# add new prompts and instantly get the output on the same frame
|
38 |
-
frame_idx, object_ids, masks = predictor.add_new_points_or_box(state, <your_prompts>):
|
39 |
-
|
40 |
-
# propagate the prompts to get masklets throughout the video
|
41 |
-
for frame_idx, object_ids, masks in predictor.propagate_in_video(state):
|
42 |
-
...
|
43 |
-
```
|
44 |
-
|
45 |
-
Refer to the [demo notebooks](https://github.com/facebookresearch/segment-anything-2/tree/main/notebooks) for details.
|
46 |
|
47 |
### Citation
|
48 |
|
|
|
4 |
library_name: sam2
|
5 |
---
|
6 |
|
7 |
+
MedSAM2 Small - CoreML Version
|
8 |
+
MedSAM2 Small is a specialized version of SAM2 for medical image segmentation tasks, now available for use with CoreML. This model is optimized to work seamlessly on Apple devices, enabling efficient, on-device predictions. To get started, follow the instructions below.
|
9 |
|
10 |
+
For detailed information, refer to the SAM2 paper and the official repository. The official code is publicly release in this [repo](https://github.com/facebookresearch/segment-anything-2/).
|
11 |
|
12 |
## Usage
|
13 |
|
14 |
+
1. Download the .zip files containing the CoreML model from the repo.
|
15 |
+
2. Extract the contents of the .zip file to a directory of your choice.
|
16 |
+
3. Push to [SAM2 Studio](https://github.com/huggingface/sam2-studio)
|
17 |
+
4. Open SAM2 Studio Repo on your Apple device using XCode.
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
### Citation
|
21 |
|