Views
No views yet
google/paligemma-3b-pt-224| Model | Setting | Test Samples | Normalized EM | ANLS | Token F1 | Empty Prediction Rate | Invalid Prediction Rate |
|---|---|---|---|---|---|---|---|
| PaliGemma-3B LoRA | Fine-tuned LoRA | 2000 | 0.7205 | 0.8745 | 0.7294 | 0.0000 | 0.0000 |
evaluation/.1import torch
2from PIL import Image
3from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
4from peft import PeftModel
5
6base_model = "google/paligemma-3b-pt-224"
7adapter_id = "omerfaksoy/trdocvqa-paligemma-3b-lora"
8
9processor = AutoProcessor.from_pretrained(adapter_id)
10model = PaliGemmaForConditionalGeneration.from_pretrained(
11 base_model,
12 torch_dtype=torch.bfloat16,
13 device_map="auto",
14)
15model = PeftModel.from_pretrained(model, adapter_id)
16model.eval()
17
18image = Image.open("document.png").convert("RGB")
19question = "Toplam tutar nedir?"
20prompt = f"answer tr {question}\n"
21
22inputs = processor(text=prompt, images=image, return_tensors="pt").to(model.device)
23with torch.inference_mode():
24 generated = model.generate(**inputs, max_new_tokens=64, do_sample=False, num_beams=1)
25
26prompt_len = inputs["input_ids"].shape[-1]
27answer = processor.batch_decode(generated[:, prompt_len:], skip_special_tokens=True)[0].strip()
28print(answer)google/paligemma-3b-pt-224Ethosoft/TR-DocVQA-Synthgoogle/paligemma-3b-pt-224.