multimodalart HF Staff commited on
Commit
3faec92
·
verified ·
1 Parent(s): e4b3b16

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -4,17 +4,25 @@ import gradio as gr
4
  import re
5
  from PIL import Image
6
 
7
- from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
8
 
9
  MODEL_ID = "openbmb/EVisRAG-7B"
10
 
11
- processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True, padding_side="left")
 
 
 
 
12
  model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
13
  MODEL_ID,
14
  torch_dtype=torch.bfloat16,
15
  attn_implementation="sdpa",
16
  ).to("cuda").eval()
17
 
 
 
 
 
18
 
19
  def evidence_prompt(query: str) -> str:
20
  """Build the evidence-guided multi-image reasoning prompt used by EVisRAG."""
 
4
  import re
5
  from PIL import Image
6
 
7
+ from transformers import AutoTokenizer, AutoImageProcessor, Qwen2_5_VLForConditionalGeneration, AutoModelForVision2Seq
8
 
9
  MODEL_ID = "openbmb/EVisRAG-7B"
10
 
11
+ # Use the model class directly (avoids AutoProcessor video-processor auto-detection bug in transformers 5.x)
12
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True, padding_side="left")
13
+ image_processor = AutoImageProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
14
+
15
+ # Construct the processor from the model class which knows how to combine them
16
  model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
17
  MODEL_ID,
18
  torch_dtype=torch.bfloat16,
19
  attn_implementation="sdpa",
20
  ).to("cuda").eval()
21
 
22
+ # Build a processor from the tokenizer + image_processor
23
+ from transformers import Qwen2_5_VLProcessor
24
+ processor = Qwen2_5_VLProcessor(image_processor=image_processor, tokenizer=tokenizer)
25
+
26
 
27
  def evidence_prompt(query: str) -> str:
28
  """Build the evidence-guided multi-image reasoning prompt used by EVisRAG."""