Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the model pipeline
|
5 |
pipe = pipeline("image-text-to-text", model="deepseek-ai/deepseek-vl2-small", trust_remote_code=True)
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
response = pipe(messages)
|
13 |
-
|
14 |
-
if isinstance(response, list) and len(response) > 0:
|
15 |
-
return response[0]["generated_text"] # Extract response text
|
16 |
-
else:
|
17 |
-
return "No response received."
|
18 |
|
19 |
-
# Create
|
20 |
-
|
21 |
-
fn=
|
22 |
-
inputs=gr.Textbox(
|
23 |
-
outputs="
|
24 |
title="DeepSeek-VL2 Chatbot",
|
25 |
-
description="Ask
|
26 |
)
|
27 |
|
28 |
-
# Launch the
|
29 |
if __name__ == "__main__":
|
30 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the model pipeline with trust_remote_code=True
|
5 |
pipe = pipeline("image-text-to-text", model="deepseek-ai/deepseek-vl2-small", trust_remote_code=True)
|
6 |
|
7 |
+
# Define the Gradio function
|
8 |
+
def generate_response(message):
|
9 |
+
messages = [{"role": "user", "content": message}]
|
10 |
+
result = pipe(messages)
|
11 |
+
return result[0]["generated_text"] if isinstance(result, list) else result
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# Create the Gradio interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_response,
|
16 |
+
inputs=gr.Textbox(label="Enter your message"),
|
17 |
+
outputs=gr.Textbox(label="Model Response"),
|
18 |
title="DeepSeek-VL2 Chatbot",
|
19 |
+
description="Ask anything and get a response from the DeepSeek-VL2-Small model."
|
20 |
)
|
21 |
|
22 |
+
# Launch the app
|
23 |
if __name__ == "__main__":
|
24 |
+
iface.launch()
|