Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,12 @@ import gradio as gr
|
|
6 |
MODEL_ID = "Qwen/Qwen2-VL-7B-Instruct"
|
7 |
MODEL_FINETUNE_ID = "davidr99/qwen2.5-7b-instruct-blackjack"
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
11 |
from qwen_vl_utils import process_vision_info
|
@@ -15,9 +21,9 @@ model.load_adapter(MODEL_FINETUNE_ID)
|
|
15 |
processor = AutoProcessor.from_pretrained(MODEL_FINETUNE_ID)
|
16 |
|
17 |
@spaces.GPU(duration=30)
|
18 |
-
def blackjack_ai(image):
|
19 |
|
20 |
-
instruction =
|
21 |
|
22 |
messages = [
|
23 |
{"role": "system",
|
@@ -60,9 +66,11 @@ def blackjack_ai(image):
|
|
60 |
with gr.Blocks() as demo:
|
61 |
|
62 |
image = gr.Image(type="filepath")
|
|
|
63 |
submit = gr.Button("Submit")
|
64 |
output = gr.TextArea()
|
|
|
65 |
|
66 |
-
submit.click(blackjack_ai, inputs=[image], outputs=[output])
|
67 |
|
68 |
demo.launch()
|
|
|
6 |
MODEL_ID = "Qwen/Qwen2-VL-7B-Instruct"
|
7 |
MODEL_FINETUNE_ID = "davidr99/qwen2.5-7b-instruct-blackjack"
|
8 |
|
9 |
+
EXAMPLES = [
|
10 |
+
"examples/black_jack_screenshot_1737088587.png",
|
11 |
+
"examples/black_jack_screenshot_1737088629.png",
|
12 |
+
"examples/black_jack_screenshot_1737088648.png"
|
13 |
+
]
|
14 |
+
|
15 |
|
16 |
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
17 |
from qwen_vl_utils import process_vision_info
|
|
|
21 |
processor = AutoProcessor.from_pretrained(MODEL_FINETUNE_ID)
|
22 |
|
23 |
@spaces.GPU(duration=30)
|
24 |
+
def blackjack_ai(image, question):
|
25 |
|
26 |
+
instruction = question
|
27 |
|
28 |
messages = [
|
29 |
{"role": "system",
|
|
|
66 |
with gr.Blocks() as demo:
|
67 |
|
68 |
image = gr.Image(type="filepath")
|
69 |
+
question = gr.Textbox(value = "extract json from this image.")
|
70 |
submit = gr.Button("Submit")
|
71 |
output = gr.TextArea()
|
72 |
+
examples = gr.Examples(examples=EXAMPLES, inputs=[image])
|
73 |
|
74 |
+
submit.click(blackjack_ai, inputs=[image, question], outputs=[output])
|
75 |
|
76 |
demo.launch()
|