annading commited on
Commit
080fa88
1 Parent(s): 80eb764

updated paths

Browse files
.gitignore CHANGED
@@ -2,5 +2,4 @@
2
  .DS_Store
3
  gradio_cached_examples/**
4
  *.png
5
- *.jpeg
6
- *.pth
 
2
  .DS_Store
3
  gradio_cached_examples/**
4
  *.png
5
+ *.jpeg
 
app.py CHANGED
@@ -6,8 +6,8 @@ os.environ["CUDA_HOME"] = "/usr/local/cuda-11.8/"
6
  subprocess.run(['pip', 'install', '-e', 'GroundingDINO'])
7
  sys.path.append(os.path.join(os.getcwd(), "GroundingDINO"))
8
  sys.path.append(os.path.join(os.getcwd(), "segment_anything"))
9
- os.system("wget https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/groundingdino_swint_ogc.pth")
10
- os.system("wget https://huggingface.co/spaces/mrtlive/segment-anything-model/resolve/main/sam_vit_h_4b8939.pth")
11
 
12
  import gradio as gr
13
  from dino_sam import sam_dino_vid
 
6
  subprocess.run(['pip', 'install', '-e', 'GroundingDINO'])
7
  sys.path.append(os.path.join(os.getcwd(), "GroundingDINO"))
8
  sys.path.append(os.path.join(os.getcwd(), "segment_anything"))
9
+ # os.system("wget https://huggingface.co/ShilongLiu/GroundingDINO/resolve/main/groundingdino_swint_ogc.pth")
10
+ # os.system("wget https://huggingface.co/spaces/mrtlive/segment-anything-model/resolve/main/sam_vit_h_4b8939.pth")
11
 
12
  import gradio as gr
13
  from dino_sam import sam_dino_vid
dino_sam.py CHANGED
@@ -34,7 +34,7 @@ def sam_dino_vid(
34
  fps_processed: int = 1,
35
  video_options: list[str] = ["Bounding boxes"],
36
  config_path: str = "GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py",
37
- weights_path: str = "groundingdino_swint_ogc.pth",
38
  device: str = 'cuda',
39
  batch_size: int = 10
40
  ) -> (str, str):
@@ -49,7 +49,7 @@ def sam_dino_vid(
49
  boxes_needed = False
50
  if "Masks" in video_options:
51
  masks_needed = True
52
- checkpoint = "sam_vit_h_4b8939.pth"
53
  model_type = "vit_h"
54
  sam = sam_model_registry[model_type](checkpoint=checkpoint)
55
  sam.to(device=device)
@@ -58,9 +58,9 @@ def sam_dino_vid(
58
  # create new dirs and paths for results
59
  filename = os.path.splitext(os.path.basename(vid_path))[0]
60
  results_dir = "../processed/" + filename + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
61
- os.mkdir(results_dir)
62
  frames_dir = os.path.join(results_dir, "frames")
63
- os.mkdir(frames_dir)
64
  csv_path = os.path.join(results_dir, "detections.csv")
65
 
66
  # load the groundingDINO model
 
34
  fps_processed: int = 1,
35
  video_options: list[str] = ["Bounding boxes"],
36
  config_path: str = "GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py",
37
+ weights_path: str = "weights/groundingdino_swint_ogc.pth",
38
  device: str = 'cuda',
39
  batch_size: int = 10
40
  ) -> (str, str):
 
49
  boxes_needed = False
50
  if "Masks" in video_options:
51
  masks_needed = True
52
+ checkpoint = "weights/sam_vit_h_4b8939.pth"
53
  model_type = "vit_h"
54
  sam = sam_model_registry[model_type](checkpoint=checkpoint)
55
  sam.to(device=device)
 
58
  # create new dirs and paths for results
59
  filename = os.path.splitext(os.path.basename(vid_path))[0]
60
  results_dir = "../processed/" + filename + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
61
+ os.makedirs(results_dir, exist_ok=True)
62
  frames_dir = os.path.join(results_dir, "frames")
63
+ os.makedirs(frames_dir, exist_ok=True)
64
  csv_path = os.path.join(results_dir, "detections.csv")
65
 
66
  # load the groundingDINO model
weights/groundingdino_swint_ogc.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b3ca2563c77c69f651d7bd133e97139c186df06231157a64c507099c52bc799
3
+ size 693997677
weights/sam_vit_h_4b8939.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7bf3b02f3ebf1267aba913ff637d9a2d5c33d3173bb679e46d9f338c26f262e
3
+ size 2564550879