unable to evaluate qwen model on DocVQA dataset. #7403
Unanswered
ee22mtech14003
asked this question in
General
Replies: 1 comment
-
how did you solve the problem? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to test my peft lora on DocVQA (Qwen-2.5-VL-3B) but I am unable to do so. here is the code to reproduce error.
from datasets import load_dataset
from tqdm import tqdm
import torch
from collections import defaultdict
from PIL import Image
from peft import get_peft_model, PeftModel, LoraConfig, TaskType
from transformers import AutoProcessor, AutoModelForImageTextToText , BitsAndBytesConfig
from trl import SFTConfig, SFTTrainer
import torch
device = “cuda” if torch.cuda.is_available() else “cpu”
model_id = “Qwen/Qwen2.5-VL-3B-Instruct”
min_pixels = 2242828
max_pixels = 2242828
processor = AutoProcessor.from_pretrained(model_id, min_pixels=min_pixels, max_pixels=max_pixels)
processor.tokenizer.padding_side = “right”
base_model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype=torch.float16,
load_in_8bit=True, # Load in 8-bit precision
device_map=“auto”
)
from datasets import load_dataset
from tqdm import tqdm
import torch
from collections import defaultdict
from PIL import Image
Assuming base_model and processor are already loaded
model = base_model
processor = processor # Replace with the actual processor instance
def evaluate_docvqa(model, processor, num_samples=None, device="cuda"):
# Load the DocVQA dataset (test split)
dataset = load_dataset("lmms-lab/DocVQA", "DocVQA", split="test")
Call the function and print the results
accuracy, results = evaluate_docvqa(model, processor, num_samples=100, device="cuda")
print(f"Test Accuracy: {accuracy:.4f}")
Beta Was this translation helpful? Give feedback.
All reactions