Spaces:
Running
on
Zero
Running
on
Zero
tanshaohui
commited on
Commit
•
98ca294
1
Parent(s):
be74681
feat: 支持输入url与text
Browse files
app.py
CHANGED
@@ -13,18 +13,23 @@ model = Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-7B-Instru
|
|
13 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
|
14 |
|
15 |
@spaces.GPU
|
16 |
-
def infer(
|
17 |
-
if len(
|
18 |
-
|
|
|
|
|
19 |
messages = [
|
20 |
{
|
21 |
"role": "user",
|
22 |
"content": [
|
23 |
{
|
24 |
"type": "image",
|
25 |
-
"image":
|
|
|
|
|
|
|
|
|
26 |
},
|
27 |
-
{"type": "text", "text": n},
|
28 |
],
|
29 |
}
|
30 |
]
|
@@ -50,5 +55,12 @@ def infer(n):
|
|
50 |
return output_text
|
51 |
|
52 |
|
53 |
-
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
demo.launch()
|
|
|
13 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
|
14 |
|
15 |
@spaces.GPU
|
16 |
+
def infer(u, t):
|
17 |
+
if len(u) < 1:
|
18 |
+
u = "https://lf3-static.bytednsdoc.com/obj/eden-cn/pbovhozuha/screenshot-20240923-164458.png"
|
19 |
+
if len(t) < 1:
|
20 |
+
t = "请将图里文字转成markdown"
|
21 |
messages = [
|
22 |
{
|
23 |
"role": "user",
|
24 |
"content": [
|
25 |
{
|
26 |
"type": "image",
|
27 |
+
"image": u,
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"type": "text",
|
31 |
+
"text": t,
|
32 |
},
|
|
|
33 |
],
|
34 |
}
|
35 |
]
|
|
|
55 |
return output_text
|
56 |
|
57 |
|
58 |
+
demo = gr.Interface(
|
59 |
+
fn=infer,
|
60 |
+
inputs=[
|
61 |
+
gr.Text(label="url"),
|
62 |
+
gr.Text(label="text"),
|
63 |
+
],
|
64 |
+
outputs=gr.Text(),
|
65 |
+
)
|
66 |
demo.launch()
|