Didier commited on
Commit
f62e7b9
·
verified ·
1 Parent(s): c1f96a9

Create module_vision.py

Browse files
Files changed (1) hide show
  1. module_vision.py +39 -0
module_vision.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: module_chat.py
3
+ Description: A module for chat using video/image + text with a multimodal interface.
4
+ Author: Didier Guillevic
5
+ Date: 2025-04-02
6
+ """
7
+
8
+ import gradio as gr
9
+ import vlm
10
+
11
+ def process(message, history):
12
+ """Generate the model response given message and history
13
+ """
14
+ messages = vlm.build_messages(message, history)
15
+ yield from vlm.stream_response(messages)
16
+
17
+ examples=[
18
+ [{"text": "What is happening in the video?", "files": ["samples/Usain_Bolt_floats_to_victory.mp4"]}],
19
+ ]
20
+
21
+ #
22
+ # User interface
23
+ #
24
+ with gr.Blocks() as demo:
25
+ chat_interface = gr.ChatInterface(
26
+ fn=process,
27
+ description="Chat with text / text+image / text+video.",
28
+ examples=examples,
29
+ cache_examples=False,
30
+ textbox=gr.MultimodalTextbox(
31
+ label="Query Input",
32
+ file_types=["image", ".mp4"],
33
+ file_count="multiple"
34
+ ),
35
+ stop_btn="Stop Generation",
36
+ multimodal=True,
37
+ type="messages"
38
+ )
39
+