SkalskiP commited on
Commit
1549f96
·
1 Parent(s): fe42dd8

initial commit

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -1,18 +1,22 @@
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)
 
 
 
 
 
 
 
 
 
 
1
  import subprocess
2
+ import shlex
3
+ import os
4
 
5
+ # Clone the repository
6
+ subprocess.run(shlex.split("git clone https://github.com/facebookresearch/segment-anything-2.git"))
 
 
 
7
 
8
+ # Change to the repository directory
9
+ os.chdir("segment-anything-2")
 
10
 
11
+ # Install the package
12
+ subprocess.run(shlex.split("pip install -e ."))
 
13
 
14
+ # import torch
15
+ # from sam2.build_sam import build_sam2
16
+ # from sam2.sam2_image_predictor import SAM2ImagePredictor
17
+ #
18
+ # DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
19
+ # CHECKPOINT = f"checkpoints/sam2_hiera_large.pt"
20
+ # CONFIG = "sam2_hiera_l.yaml"
21
+ #
22
+ # sam2_model = build_sam2(CONFIG, CHECKPOINT, device=DEVICE)