merve HF staff commited on
Commit
f8d9637
·
verified ·
1 Parent(s): 09252ed

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +55 -3
README.md CHANGED
@@ -1,3 +1,55 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ ---
5
+ license: apache-2.0
6
+ pipeline_tag: mask-generation
7
+ tags:
8
+ - sam2
9
+ ---
10
+
11
+ # SAM2-Hiera-tiny
12
+
13
+ This repository contains tiny variant of SAM2 model. SAM2 is the state-of-the-art mask generation model released by Meta.
14
+
15
+ ## Usage
16
+
17
+ You can use it like below. First install packaged version of SAM2.
18
+
19
+ ```bash
20
+ pip install samv2 huggingface_hub
21
+ ```
22
+
23
+ Each model requires different classes to infer.
24
+
25
+ ```python
26
+
27
+ from huggingface_hub import hf_hub_download
28
+ from sam2.build_sam import build_sam2
29
+ from sam2.sam2_image_predictor import SAM2ImagePredictor
30
+
31
+ hf_hub_download(repo_id = "merve/sam2-hiera-tiny", filename="sam2_hiera_tiny.pt", local_dir = "./")
32
+
33
+ ckpt = f"./sam2_hiera_tiny.pt"
34
+ config = "sam2_hiera_t.yaml"
35
+
36
+ sam2_model = build_sam2(config, ckpt, device="cuda", apply_postprocessing=False)
37
+ predictor = SAM2ImagePredictor(sam2_model)
38
+
39
+ # it accepts coco format
40
+ box = [x1, y1, w, h]
41
+ predictor.set_image(image)
42
+
43
+ masks = predictor.predict(box=box,
44
+ multimask_output=False)
45
+ ```
46
+
47
+ ## Resources
48
+
49
+ The team behind SAM2 made example notebooks for all tasks.
50
+
51
+ - See [image predictor example](https://github.com/facebookresearch/segment-anything-2/blob/main/notebooks/image_predictor_example.ipynb) for full example on prompting.
52
+
53
+ - See [automatic mask generation example](https://github.com/facebookresearch/segment-anything-2/blob/main/notebooks/automatic_mask_generator_example.ipynb) for generating all masks.
54
+
55
+ - See [video object segmentation example](https://github.com/facebookresearch/segment-anything-2/blob/main/notebooks/video_predictor_example.ipynb)