Views
No views yet
marks_obtainedQwen/Qwen2-VL-2B-Instruct for reading the handwritten marks_obtained field from cropped Part-C cells of an OMR answer sheet.Read the handwritten value. Output only the value.| Base model | Qwen/Qwen2-VL-2B-Instruct |
| Method | PEFT LoRA |
Rank (r) | 16 |
lora_alpha | 32 |
lora_dropout | 0.05 |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Task type | CAUSAL_LM |
| Data | OMR Part-C cell crops, JSONL splits (80/20 train/eval) |
| Starting adapter | Earlier Part-D LoRA (continued fine-tune) |
1from peft import PeftModel
2from transformers import AutoProcessor, Qwen2VLForConditionalGeneration
3from PIL import Image
4import torch
5
6BASE = "Qwen/Qwen2-VL-2B-Instruct"
7ADAPTER = "kshitizjangra/qwen2vl-omr-lora-partc"
8
9processor = AutoProcessor.from_pretrained(BASE)
10model = Qwen2VLForConditionalGeneration.from_pretrained(BASE, torch_dtype=torch.float16, device_map="auto")
11model = PeftModel.from_pretrained(model, ADAPTER)
12model.eval()
13
14image = Image.open("crop.jpg").convert("RGB")
15messages = [{
16 "role": "user",
17 "content": [
18 {"type": "image", "image": image},
19 {"type": "text", "text": "Read the handwritten value. Output only the value."},
20 ],
21}]
22text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
23inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
24
25with torch.no_grad():
26 out = model.generate(**inputs, max_new_tokens=16, do_sample=False)
27print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0].strip())| File | Purpose |
|---|---|
adapter_model.safetensors | LoRA weights |
adapter_config.json | PEFT config |
tokenizer.json, tokenizer_config.json, chat_template.jinja | Tokenizer + chat template |
processor_config.json | Image/text processor |
marks_obtained cells. Other handwriting domains (full-page free-form, non-English script, very long sequences) are out of scope.