Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
-
from transformers import Qwen2VLForConditionalGeneration,
|
5 |
from qwen_vl_utils import process_vision_info
|
6 |
import re
|
7 |
|
@@ -18,8 +18,8 @@ def model_inference(images):
|
|
18 |
|
19 |
images = [{"type": "image", "image": Image.open(image[0])} for image in images]
|
20 |
|
21 |
-
messages = [{"role": "user", "content": images}]
|
22 |
-
|
23 |
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
24 |
image_inputs, video_inputs = process_vision_info(messages)
|
25 |
inputs = processor(
|
@@ -73,7 +73,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
73 |
extract_button = gr.Button("Extract Text and Search", variant="primary")
|
74 |
|
75 |
with gr.Row():
|
76 |
-
raw_output = gr.Textbox(label="
|
77 |
highlighted_output = gr.Markdown(label="Highlighted Search Results")
|
78 |
|
79 |
extract_button.click(extract_and_search, inputs=[output_gallery, keywords], outputs=[raw_output, highlighted_output])
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
+
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
|
5 |
from qwen_vl_utils import process_vision_info
|
6 |
import re
|
7 |
|
|
|
18 |
|
19 |
images = [{"type": "image", "image": Image.open(image[0])} for image in images]
|
20 |
|
21 |
+
messages = [{"role": "user", "content": "Please extract only the text from the following image."}, {"role": "user", "content": images}]
|
22 |
+
|
23 |
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
24 |
image_inputs, video_inputs = process_vision_info(messages)
|
25 |
inputs = processor(
|
|
|
73 |
extract_button = gr.Button("Extract Text and Search", variant="primary")
|
74 |
|
75 |
with gr.Row():
|
76 |
+
raw_output = gr.Textbox(label="Extracted Text")
|
77 |
highlighted_output = gr.Markdown(label="Highlighted Search Results")
|
78 |
|
79 |
extract_button.click(extract_and_search, inputs=[output_gallery, keywords], outputs=[raw_output, highlighted_output])
|