SkalskiP commited on
Commit
fe42dd8
1 Parent(s): e6a707f

initial commit

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import shlex
2
+ import subprocess
3
+
4
+ subprocess.run(
5
+ shlex.split(
6
+ "git clone https://github.com/facebookresearch/segment-anything-2.git && cd segment-anything-2 && pip install -e ."
7
+ )
8
+ )
9
+
10
+ import torch
11
+ from sam2.build_sam import build_sam2
12
+ from sam2.sam2_image_predictor import SAM2ImagePredictor
13
+
14
+ DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
15
+ CHECKPOINT = f"checkpoints/sam2_hiera_large.pt"
16
+ CONFIG = "sam2_hiera_l.yaml"
17
+
18
+ sam2_model = build_sam2(CONFIG, CHECKPOINT, device=DEVICE)