Spaces:
Running
on
Zero
Running
on
Zero
BoboiAzumi
commited on
Commit
•
a744fab
1
Parent(s):
45e189a
fix
Browse files- app.py +9 -3
- process.py +1 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
from process import inference
|
4 |
|
5 |
@spaces.GPU
|
6 |
-
def clickit(video):
|
7 |
return inference(
|
8 |
-
video
|
|
|
9 |
)
|
10 |
|
11 |
with gr.Blocks() as blok:
|
@@ -14,13 +16,17 @@ with gr.Blocks() as blok:
|
|
14 |
video = gr.Video(
|
15 |
label="video input",
|
16 |
)
|
|
|
|
|
|
|
|
|
17 |
with gr.Column():
|
18 |
button = gr.Button("Caption it", variant="primary")
|
19 |
text = gr.Text(label="Output")
|
20 |
|
21 |
button.click(
|
22 |
fn=clickit,
|
23 |
-
inputs=[video],
|
24 |
outputs=[text]
|
25 |
)
|
26 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import spaces
|
3 |
|
4 |
from process import inference
|
5 |
|
6 |
@spaces.GPU
|
7 |
+
def clickit(video, prompt):
|
8 |
return inference(
|
9 |
+
video,
|
10 |
+
prompt
|
11 |
)
|
12 |
|
13 |
with gr.Blocks() as blok:
|
|
|
16 |
video = gr.Video(
|
17 |
label="video input",
|
18 |
)
|
19 |
+
prompt = gr.Text(
|
20 |
+
label="Prompt",
|
21 |
+
value="Please describe this video in detail."
|
22 |
+
)
|
23 |
with gr.Column():
|
24 |
button = gr.Button("Caption it", variant="primary")
|
25 |
text = gr.Text(label="Output")
|
26 |
|
27 |
button.click(
|
28 |
fn=clickit,
|
29 |
+
inputs=[video, prompt],
|
30 |
outputs=[text]
|
31 |
)
|
32 |
|
process.py
CHANGED
@@ -96,8 +96,7 @@ def predict(prompt, video_data, temperature):
|
|
96 |
return response
|
97 |
|
98 |
|
99 |
-
def inference(video):
|
100 |
-
prompt = "Please describe this video in detail."
|
101 |
temperature = 0.1
|
102 |
video_data = open(video, 'rb').read()
|
103 |
response = predict(prompt, video_data, temperature)
|
|
|
96 |
return response
|
97 |
|
98 |
|
99 |
+
def inference(video, prompt):
|
|
|
100 |
temperature = 0.1
|
101 |
video_data = open(video, 'rb').read()
|
102 |
response = predict(prompt, video_data, temperature)
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
argparse
|
2 |
numpy
|
3 |
decord
|
|
|
4 |
transformers==4.41.2
|
5 |
einops==0.8.0
|
6 |
torchvision==0.15.1
|
|
|
1 |
argparse
|
2 |
numpy
|
3 |
decord
|
4 |
+
spaces
|
5 |
transformers==4.41.2
|
6 |
einops==0.8.0
|
7 |
torchvision==0.15.1
|