Spaces:
Running
on
Zero
Running
on
Zero
Update demo style.
Browse files
app.py
CHANGED
@@ -1,12 +1,9 @@
|
|
1 |
import spaces
|
2 |
|
3 |
import os
|
4 |
-
import shutil
|
5 |
|
6 |
import torch
|
7 |
-
import tempfile
|
8 |
import gradio as gr
|
9 |
-
from PIL import Image
|
10 |
|
11 |
import sys
|
12 |
sys.path.append('./')
|
@@ -30,9 +27,9 @@ title_markdown = ("""
|
|
30 |
|
31 |
<div align="center">
|
32 |
<div style="display:flex; gap: 0.25rem;" align="center">
|
33 |
-
<a href=
|
34 |
<a href="https://arxiv.org/pdf/2406.07476.pdf"><img src="https://img.shields.io/badge/Arxiv-2406.07476-red"></a>
|
35 |
-
<a href=
|
36 |
</div>
|
37 |
</div>
|
38 |
""")
|
@@ -158,8 +155,9 @@ def generate(image, video, first_run, state, state_, textbox_in, dtype=torch.flo
|
|
158 |
if not os.path.exists(image) and os.path.exists(video):
|
159 |
text_en_in = text_en_in.replace(DEFAULT_MMODAL_TOKEN['VIDEO'], '').strip()
|
160 |
text_en_in = DEFAULT_MMODAL_TOKEN['VIDEO'] + '\n' + text_en_in
|
161 |
-
|
162 |
-
|
|
|
163 |
text_en_out, state_ = handler.generate(tensor, modals, text_en_in, first_run=first_run, state=state_)
|
164 |
state_.messages[-1] = (state_.roles[1], text_en_out)
|
165 |
|
@@ -211,7 +209,7 @@ handler = Chat(model_path, conv_mode=conv_mode, load_8bit=False, load_4bit=True)
|
|
211 |
|
212 |
textbox = gr.Textbox(show_label=False, placeholder="Enter text and press ENTER", container=False)
|
213 |
|
214 |
-
with gr.Blocks(title='VideoLLaMA 2 π₯ππ₯', theme=gr.themes.
|
215 |
gr.Markdown(title_markdown)
|
216 |
state = gr.State()
|
217 |
state_ = gr.State()
|
|
|
1 |
import spaces
|
2 |
|
3 |
import os
|
|
|
4 |
|
5 |
import torch
|
|
|
6 |
import gradio as gr
|
|
|
7 |
|
8 |
import sys
|
9 |
sys.path.append('./')
|
|
|
27 |
|
28 |
<div align="center">
|
29 |
<div style="display:flex; gap: 0.25rem;" align="center">
|
30 |
+
<a href="https://github.com/DAMO-NLP-SG/VideoLLaMA2"><img src='https://img.shields.io/badge/Github-VideoLLaMA2-9C276A'></a>
|
31 |
<a href="https://arxiv.org/pdf/2406.07476.pdf"><img src="https://img.shields.io/badge/Arxiv-2406.07476-red"></a>
|
32 |
+
<a href="https://github.com/DAMO-NLP-SG/VideoLLaMA2/stargazers"><img src="https://img.shields.io/github/stars/DAMO-NLP-SG/VideoLLaMA2.svg?style=social"></a>
|
33 |
</div>
|
34 |
</div>
|
35 |
""")
|
|
|
155 |
if not os.path.exists(image) and os.path.exists(video):
|
156 |
text_en_in = text_en_in.replace(DEFAULT_MMODAL_TOKEN['VIDEO'], '').strip()
|
157 |
text_en_in = DEFAULT_MMODAL_TOKEN['VIDEO'] + '\n' + text_en_in
|
158 |
+
if os.path.exists(image) and os.path.exists(video):
|
159 |
+
text_en_in = text_en_in.replace(DEFAULT_MMODAL_TOKEN['VIDEO'], '').strip()
|
160 |
+
text_en_in = DEFAULT_MMODAL_TOKEN['VIDEO'] + '\n' + text_en_in
|
161 |
text_en_out, state_ = handler.generate(tensor, modals, text_en_in, first_run=first_run, state=state_)
|
162 |
state_.messages[-1] = (state_.roles[1], text_en_out)
|
163 |
|
|
|
209 |
|
210 |
textbox = gr.Textbox(show_label=False, placeholder="Enter text and press ENTER", container=False)
|
211 |
|
212 |
+
with gr.Blocks(title='VideoLLaMA 2 π₯ππ₯', theme=gr.themes.Soft(primary_hue=gr.themes.colors.violet), css=block_css) as demo:
|
213 |
gr.Markdown(title_markdown)
|
214 |
state = gr.State()
|
215 |
state_ = gr.State()
|