Spaces:
Running
on
Zero
Running
on
Zero
add dependencies
Browse files- app.py +8 -4
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
# subprocess.run(
|
5 |
# "pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git",
|
6 |
# shell=True,
|
@@ -15,6 +19,7 @@ import copy
|
|
15 |
import warnings
|
16 |
from decord import VideoReader, cpu
|
17 |
import numpy as np
|
|
|
18 |
|
19 |
warnings.filterwarnings("ignore")
|
20 |
|
@@ -47,6 +52,7 @@ tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained
|
|
47 |
model.eval()
|
48 |
print("Model loaded successfully!")
|
49 |
|
|
|
50 |
def process_video(video_path, question):
|
51 |
max_frames_num = 64
|
52 |
video, frame_time, video_time = load_video(video_path, max_frames_num, 1, force_sample=True)
|
@@ -78,7 +84,6 @@ def process_video(video_path, question):
|
|
78 |
response = tokenizer.batch_decode(output, skip_special_tokens=True)[0].strip()
|
79 |
return response
|
80 |
|
81 |
-
# Gradio interface
|
82 |
def gradio_interface(video_file, question):
|
83 |
if video_file is None:
|
84 |
return "Please upload a video file."
|
@@ -103,6 +108,5 @@ with gr.Blocks() as demo:
|
|
103 |
outputs=output
|
104 |
)
|
105 |
|
106 |
-
# Launch the app
|
107 |
if __name__ == "__main__":
|
108 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import subprocess # 🥲
|
3 |
+
subprocess.run(
|
4 |
+
"pip install flash-attn --no-build-isolation",
|
5 |
+
env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
|
6 |
+
shell=True,
|
7 |
+
)
|
8 |
# subprocess.run(
|
9 |
# "pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git",
|
10 |
# shell=True,
|
|
|
19 |
import warnings
|
20 |
from decord import VideoReader, cpu
|
21 |
import numpy as np
|
22 |
+
import spaces
|
23 |
|
24 |
warnings.filterwarnings("ignore")
|
25 |
|
|
|
52 |
model.eval()
|
53 |
print("Model loaded successfully!")
|
54 |
|
55 |
+
@spaces.GPU
|
56 |
def process_video(video_path, question):
|
57 |
max_frames_num = 64
|
58 |
video, frame_time, video_time = load_video(video_path, max_frames_num, 1, force_sample=True)
|
|
|
84 |
response = tokenizer.batch_decode(output, skip_special_tokens=True)[0].strip()
|
85 |
return response
|
86 |
|
|
|
87 |
def gradio_interface(video_file, question):
|
88 |
if video_file is None:
|
89 |
return "Please upload a video file."
|
|
|
108 |
outputs=output
|
109 |
)
|
110 |
|
|
|
111 |
if __name__ == "__main__":
|
112 |
demo.launch()
|
requirements.txt
CHANGED
@@ -6,4 +6,6 @@ torchvision
|
|
6 |
decord
|
7 |
einops
|
8 |
accelerate
|
|
|
|
|
9 |
git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
|
|
|
6 |
decord
|
7 |
einops
|
8 |
accelerate
|
9 |
+
open_clip_torch
|
10 |
+
av
|
11 |
git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
|