updated interface
Browse files
app.py
CHANGED
@@ -1,8 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import subprocess
|
2 |
import os
|
3 |
import sys
|
4 |
# set CUDA_HOME
|
5 |
-
os.environ["CUDA_HOME"] =
|
6 |
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'max_split_size_mb:5000'
|
7 |
subprocess.run(['pip', 'install', '-e', 'GroundingDINO'])
|
8 |
sys.path.append(os.path.join(os.getcwd(), "GroundingDINO"))
|
@@ -11,8 +17,7 @@ sys.path.append(os.path.join(os.getcwd(), "segment_anything"))
|
|
11 |
import gradio as gr
|
12 |
from dino_sam import sam_dino_vid
|
13 |
|
14 |
-
|
15 |
-
VID_PATH = ""
|
16 |
|
17 |
def run_sam_dino(input_vid,
|
18 |
grounding_caption,
|
@@ -22,7 +27,7 @@ def run_sam_dino(input_vid,
|
|
22 |
video_options):
|
23 |
new_input_vid = input_vid.replace(" ", "_")
|
24 |
os.rename(input_vid, new_input_vid)
|
25 |
-
csv_path, vid_path = sam_dino_vid(new_input_vid, grounding_caption, box_threshold, text_threshold, fps_processed, video_options)
|
26 |
global CSV_PATH
|
27 |
CSV_PATH = csv_path
|
28 |
global VID_PATH
|
@@ -46,7 +51,7 @@ with gr.Blocks() as demo:
|
|
46 |
with gr.Row():
|
47 |
with gr.Column():
|
48 |
input = gr.Video(label="Input Video", interactive=True)
|
49 |
-
grounding_caption = gr.Textbox(label="What do you want to detect?")
|
50 |
with gr.Accordion("Advanced Options", open=False):
|
51 |
box_threshold = gr.Slider(
|
52 |
label="Box Threshold",
|
@@ -90,5 +95,22 @@ with gr.Blocks() as demo:
|
|
90 |
cache_examples=True,
|
91 |
label='Example'
|
92 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
demo.launch(share=False)
|
|
|
1 |
+
# Setting global vars
|
2 |
+
CSV_PATH = ""
|
3 |
+
VID_PATH = ""
|
4 |
+
BATCH_SIZE = 5 # CHANGE THIS TO FIT YOUR GPU, YOU MAY NEED SOME TRIAL AND ERROR
|
5 |
+
CUDA_PATH = "/usr/local/cuda-11.8/" # CHANGE THIS TO YOUR LOCAL CUDA PATH
|
6 |
+
|
7 |
import subprocess
|
8 |
import os
|
9 |
import sys
|
10 |
# set CUDA_HOME
|
11 |
+
os.environ["CUDA_HOME"] = CUDA_PATH
|
12 |
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'max_split_size_mb:5000'
|
13 |
subprocess.run(['pip', 'install', '-e', 'GroundingDINO'])
|
14 |
sys.path.append(os.path.join(os.getcwd(), "GroundingDINO"))
|
|
|
17 |
import gradio as gr
|
18 |
from dino_sam import sam_dino_vid
|
19 |
|
20 |
+
|
|
|
21 |
|
22 |
def run_sam_dino(input_vid,
|
23 |
grounding_caption,
|
|
|
27 |
video_options):
|
28 |
new_input_vid = input_vid.replace(" ", "_")
|
29 |
os.rename(input_vid, new_input_vid)
|
30 |
+
csv_path, vid_path = sam_dino_vid(new_input_vid, grounding_caption, box_threshold, text_threshold, fps_processed, video_options, batch_size=BATCH_SIZE)
|
31 |
global CSV_PATH
|
32 |
CSV_PATH = csv_path
|
33 |
global VID_PATH
|
|
|
51 |
with gr.Row():
|
52 |
with gr.Column():
|
53 |
input = gr.Video(label="Input Video", interactive=True)
|
54 |
+
grounding_caption = gr.Textbox(label="What do you want to detect? (Muliple species should be separated by commas. i.e. 'baboons, chimpanzees')")
|
55 |
with gr.Accordion("Advanced Options", open=False):
|
56 |
box_threshold = gr.Slider(
|
57 |
label="Box Threshold",
|
|
|
95 |
cache_examples=True,
|
96 |
label='Example'
|
97 |
)
|
98 |
+
|
99 |
+
gr.DuplicateButton()
|
100 |
+
|
101 |
+
gr.Markdown(
|
102 |
+
"""
|
103 |
+
## Frequently Asked Questions
|
104 |
+
|
105 |
+
##### How can I run the interface on my own computer?
|
106 |
+
By clicking on the three dots on the top right corner of the interface, you will be able to clone the repository or run it with a Docker image on your local machine. \
|
107 |
+
For local machine setup instructions please check the README file.
|
108 |
+
|
109 |
+
##### The video is very slow to process, how can I speed it up?
|
110 |
+
You can speed up the processing by adjusting the frame detection rate in the advanced options. The lower the number the slower the processing time. Choosing only\
|
111 |
+
bounding boxes will make the processing faster. You can also duplicate the space using the Duplicate Button and choose a different GPU which will make the processing faster.
|
112 |
+
|
113 |
+
"""
|
114 |
+
)
|
115 |
|
116 |
demo.launch(share=False)
|