Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,51 +38,7 @@ if example_dir is not None:
|
|
| 38 |
video_examples.append([example_file])
|
| 39 |
|
| 40 |
|
| 41 |
-
|
| 42 |
-
gr.Markdown(HEADER)
|
| 43 |
-
with gr.Row():
|
| 44 |
-
chatbot = gr.Chatbot(type="messages", elem_id="chatbot", height=710)
|
| 45 |
-
|
| 46 |
-
with gr.Column():
|
| 47 |
-
with gr.Tab(label="Input"):
|
| 48 |
-
|
| 49 |
-
with gr.Row():
|
| 50 |
-
input_video = gr.Video(sources=["upload"], label="Upload Video")
|
| 51 |
-
input_image = gr.Image(sources=["upload"], type="filepath", label="Upload Image")
|
| 52 |
-
|
| 53 |
-
if len(image_examples):
|
| 54 |
-
gr.Examples(image_examples, inputs=[input_image], label="Example Images")
|
| 55 |
-
if len(video_examples):
|
| 56 |
-
gr.Examples(video_examples, inputs=[input_video], label="Example Videos")
|
| 57 |
-
|
| 58 |
-
input_text = gr.Textbox(label="Input Text", placeholder="Type your message here and press enter to submit")
|
| 59 |
-
|
| 60 |
-
submit_button = gr.Button("Generate")
|
| 61 |
-
|
| 62 |
-
with gr.Tab(label="Configure"):
|
| 63 |
-
with gr.Accordion("Generation Config", open=True):
|
| 64 |
-
do_sample = gr.Checkbox(value=True, label="Do Sample")
|
| 65 |
-
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.2, label="Temperature")
|
| 66 |
-
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.9, label="Top P")
|
| 67 |
-
max_new_tokens = gr.Slider(minimum=0, maximum=4096, value=2048, step=1, label="Max New Tokens")
|
| 68 |
-
|
| 69 |
-
with gr.Accordion("Video Config", open=True):
|
| 70 |
-
fps = gr.Slider(minimum=0.0, maximum=10.0, value=1, label="FPS")
|
| 71 |
-
max_frames = gr.Slider(minimum=0, maximum=256, value=180, step=1, label="Max Frames")
|
| 72 |
-
|
| 73 |
-
input_video.change(_on_video_upload, [chatbot, input_video], [chatbot, input_video])
|
| 74 |
-
input_image.change(_on_image_upload, [chatbot, input_image], [chatbot, input_image])
|
| 75 |
-
input_text.submit(_on_text_submit, [chatbot, input_text], [chatbot, input_text])
|
| 76 |
-
submit_button.click(
|
| 77 |
-
_predict,
|
| 78 |
-
[
|
| 79 |
-
chatbot, input_text, do_sample, temperature, top_p, max_new_tokens,
|
| 80 |
-
fps, max_frames
|
| 81 |
-
],
|
| 82 |
-
[chatbot],
|
| 83 |
-
)
|
| 84 |
-
|
| 85 |
-
def _on_video_upload(messages, video):
|
| 86 |
if video is not None:
|
| 87 |
# messages.append({"role": "user", "content": gr.Video(video)})
|
| 88 |
messages.append({"role": "user", "content": {"path": video}})
|
|
@@ -162,5 +118,50 @@ with gr.Blocks() as interface:
|
|
| 162 |
yield messages
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
if __name__ == "__main__":
|
| 166 |
interface.launch()
|
|
|
|
| 38 |
video_examples.append([example_file])
|
| 39 |
|
| 40 |
|
| 41 |
+
def _on_video_upload(messages, video):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
if video is not None:
|
| 43 |
# messages.append({"role": "user", "content": gr.Video(video)})
|
| 44 |
messages.append({"role": "user", "content": {"path": video}})
|
|
|
|
| 118 |
yield messages
|
| 119 |
|
| 120 |
|
| 121 |
+
with gr.Blocks() as interface:
|
| 122 |
+
gr.Markdown(HEADER)
|
| 123 |
+
with gr.Row():
|
| 124 |
+
chatbot = gr.Chatbot(type="messages", elem_id="chatbot", height=710)
|
| 125 |
+
|
| 126 |
+
with gr.Column():
|
| 127 |
+
with gr.Tab(label="Input"):
|
| 128 |
+
|
| 129 |
+
with gr.Row():
|
| 130 |
+
input_video = gr.Video(sources=["upload"], label="Upload Video")
|
| 131 |
+
input_image = gr.Image(sources=["upload"], type="filepath", label="Upload Image")
|
| 132 |
+
|
| 133 |
+
if len(image_examples):
|
| 134 |
+
gr.Examples(image_examples, inputs=[input_image], label="Example Images")
|
| 135 |
+
if len(video_examples):
|
| 136 |
+
gr.Examples(video_examples, inputs=[input_video], label="Example Videos")
|
| 137 |
+
|
| 138 |
+
input_text = gr.Textbox(label="Input Text", placeholder="Type your message here and press enter to submit")
|
| 139 |
+
|
| 140 |
+
submit_button = gr.Button("Generate")
|
| 141 |
+
|
| 142 |
+
with gr.Tab(label="Configure"):
|
| 143 |
+
with gr.Accordion("Generation Config", open=True):
|
| 144 |
+
do_sample = gr.Checkbox(value=True, label="Do Sample")
|
| 145 |
+
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.2, label="Temperature")
|
| 146 |
+
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.9, label="Top P")
|
| 147 |
+
max_new_tokens = gr.Slider(minimum=0, maximum=4096, value=2048, step=1, label="Max New Tokens")
|
| 148 |
+
|
| 149 |
+
with gr.Accordion("Video Config", open=True):
|
| 150 |
+
fps = gr.Slider(minimum=0.0, maximum=10.0, value=1, label="FPS")
|
| 151 |
+
max_frames = gr.Slider(minimum=0, maximum=256, value=180, step=1, label="Max Frames")
|
| 152 |
+
|
| 153 |
+
input_video.change(_on_video_upload, [chatbot, input_video], [chatbot, input_video])
|
| 154 |
+
input_image.change(_on_image_upload, [chatbot, input_image], [chatbot, input_image])
|
| 155 |
+
input_text.submit(_on_text_submit, [chatbot, input_text], [chatbot, input_text])
|
| 156 |
+
submit_button.click(
|
| 157 |
+
_predict,
|
| 158 |
+
[
|
| 159 |
+
chatbot, input_text, do_sample, temperature, top_p, max_new_tokens,
|
| 160 |
+
fps, max_frames
|
| 161 |
+
],
|
| 162 |
+
[chatbot],
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
|
| 166 |
if __name__ == "__main__":
|
| 167 |
interface.launch()
|