Downloads · 30 days
0
netprtony/Llama-3.2-11B-Vision-PokemonCard-OCR-LoRA
Llama-3.2-11B-Vision-PokemonCard-OCR-LoRA is a image-to-text model from netprtony. Use it when you need a caption or text from an image. It is set up for transformers. The card lists the license as llama3.2.
This is a Vision-Language Model (VLM) fine-tuned from Llama-3.2-11B-Vision-Instruct to perform Optical Character Recognition (OCR) on Pokémon trading cards. The model is trained to extract card names and card numbers…
Downloads · 30 days
0
Access
Public
Updated Dec 1, 2025
Repo size
286 MB
Likes
0
Public
Click a slice to open those files.
.safetensors269 MB · 94%
From the Hugging Face model README
This is a Vision-Language Model (VLM) fine-tuned from Llama-3.2-11B-Vision-Instruct to perform Optical Character Recognition (OCR) on Pokémon trading cards. The model is trained to extract card names and card numbers in JSON format.
This model specializes in:
unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit- LoRA r: 16
- LoRA alpha: 16
- LoRA dropout: 0.05
- Target modules: Vision layers + Language layers + Attention + MLP
- Learning rate: 2e-4
- Batch size: 2 (per device)
- Gradient accumulation: 8 steps
- Total training steps: 100
- Optimizer: AdamW 8-bit
| Metric | Value |
|---|---|
| Training Loss (step 50) | 0.0127 |
| Validation Loss (step 50) | 0.0125 |
| Training Loss (step 100) | 0.0267 |
| Validation Loss (step 100) | 0.0105 |
| Training Time | ~1h 43m |
pip install unsloth datasets transformers accelerate trl bitsandbytes pillow tqdm
pip install pyarrow==19.0.0
from unsloth import FastVisionModel
import torch
# Load base model
model_id = "unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit"
model, tokenizer = FastVisionModel.from_pretrained(
model_id,
load_in_4bit=True,
use_gradient_checkpointing="unsloth",
)
# Load LoRA adapter
lora_model_path = "lora_pokemon_model"
model.load_adapter(lora_model_path, adapter_name="default")
FastVisionModel.for_inference(model)
from transformers import TextStreamer
# Path to card image
image_path = "path/to/pokemon_card.jpg"
# Instruction prompt
instruction = "You are an OCR expert specialized in Pokémon cards. Extract the card name and card number in JSON format."
# Prepare input
messages = [
{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": instruction}
]}
]
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
inputs = tokenizer(
image_path,
input_text,
add_special_tokens=False,
return_tensors="pt",
).to("cuda" if torch.cuda.is_available() else "cpu")
# Generate
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
outputs = model.generate(
**inputs,
streamer=text_streamer,
max_new_tokens=128,
temperature=0.7,
top_p=0.9,
use_cache=True,
)
# Decode result
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
Input: Pokémon card image
Output:
{
"gt_parse": {
"card_details": [
{"name_en": "Sableye"},
{"card_number": "61/113"}
]
}
}
datasets/
├── images/ # Card images (.jpg)
└── ground_truth/ # JSON ground truth files
├── card1.json
├── card2.json
└── ...
Ground Truth Format:
{
"gt_parse": {
"card_details": [
{"name_en": "Card Name"},
{"card_number": "XX/YYY"}
]
}
}
To retrain the model:
fineture_pokemon_card.ipynblora_pokemon_model/Contributions to improve the model are welcome! Please create an issue or pull request.
This model inherits the license from Llama 3.2 (Meta) and Unsloth.
Note: This model is optimized for research and learning purposes. For production use, further evaluation of accuracy and robustness is required.