SkalskiP commited on
Commit
61d1727
1 Parent(s): e4d42b3

initial commit

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -12,7 +12,15 @@ os.chdir("segment-anything-2")
12
  # Install the package
13
  subprocess.run(shlex.split("pip install -e ."))
14
 
 
 
 
15
 
 
 
 
 
 
16
 
17
  def run(image):
18
  return None
@@ -31,15 +39,3 @@ demo = gr.Interface(
31
  allow_duplication=True,
32
  )
33
  demo.queue().launch()
34
-
35
-
36
-
37
- # import torch
38
- # from sam2.build_sam import build_sam2
39
- # from sam2.sam2_image_predictor import SAM2ImagePredictor
40
- #
41
- # DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
42
- # CHECKPOINT = f"checkpoints/sam2_hiera_large.pt"
43
- # CONFIG = "sam2_hiera_l.yaml"
44
- #
45
- # sam2_model = build_sam2(CONFIG, CHECKPOINT, device=DEVICE)
 
12
  # Install the package
13
  subprocess.run(shlex.split("pip install -e ."))
14
 
15
+ import torch
16
+ from sam2.build_sam import build_sam2
17
+ from sam2.sam2_image_predictor import SAM2ImagePredictor
18
 
19
+ DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
20
+ CHECKPOINT = f"checkpoints/sam2_hiera_large.pt"
21
+ CONFIG = "sam2_hiera_l.yaml"
22
+
23
+ sam2_model = build_sam2(CONFIG, CHECKPOINT, device=DEVICE)
24
 
25
  def run(image):
26
  return None
 
39
  allow_duplication=True,
40
  )
41
  demo.queue().launch()