Downloads · 30 days
6
6% of all-time downloads
MagiBoss/PaliGemma2-3b-224-COCO
PaliGemma2-3b-224-COCO is a image-to-text model from MagiBoss. Use it when you need a caption or text from an image. It is set up for peft. The card lists the license as gemma.
PaliGemma2-3b-224-COCO is a specialized Thai language image captioning model fine-tuned from google/paligemma2-3b-pt-224. This model represents a significant advancement in Thai language image understanding, demonstra…
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
100
Public
Repo size
415 MB
Likes
3
Public
Click a slice to open those files.
.safetensors190 MB · 85%
From the Hugging Face model README
PaliGemma2-3b-224-COCO is a specialized Thai language image captioning model fine-tuned from google/paligemma2-3b-pt-224. This model represents a significant advancement in Thai language image understanding, demonstrating superior performance compared to existing solutions, particularly our baseline model MagiBoss/Blip2-Typhoon1.5-COCO.
A comprehensive evaluation was conducted against MagiBoss/Blip2-Typhoon1.5-COCO. using identical test conditions and metrics. Both models were tested with max_new_tokens=25 to ensure fair comparison.
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.2182 | 1.0 | 4447 | 1.1568 |
| 1.1318 | 2.0 | 8894 | 1.0910 |
| 1.0837 | 3.0 | 13341 | 1.0724 |
| Model | BLEU-1 | BLEU-2 | BLEU-3 | BLEU-4 | BLEU (Cumulative) |
|---|---|---|---|---|---|
| THAI-BLIP-2 | 40.62 | 17.72 | 8.36 | 4.04 | 10.44 |
| Blip2-Typhoon1.5-COCO | 41.47 | 18.09 | 8.22 | 3.75 | 7.48 |
| PaliGemma2-3b-224-COCO | 42.03 | 19.11 | 9.29 | 4.80 | 12.42 |
Key Achievement: ~3.3x improvement in BLEU-1 score, indicating significantly better basic translation accuracy.
| Model | ROUGE-L |
|---|---|
| THAI-BLIP-2 | 1.93 |
| Blip2-Typhoon1.5-COCO | 0.93 |
| PaliGemma2-3b-224-COCO | 2.82 |
Notable Improvement: 2.5x enhancement in ROUGE-1 score, showing better content matching.
| Model | BERTScore (F1) |
|---|---|
| THAI-BLIP-2 | 78.18 |
| Blip2-Typhoon1.5-COCO | 77.00 |
| PaliGemma2-3b-224-COCO | 79.33 |
Significant Gain: 9.25 point improvement in BERTScore, validated using bert-base-multilingual-cased model.
| Model | METEOR |
|---|---|
| THAI-BLIP-2 | 27.18 |
| Blip2-Typhoon1.5-COCO | 21.90 |
| PaliGemma2-3b-224-COCO | 30.12 |
Outstanding Result: 4.2x improvement in METEOR score, demonstrating superior semantic accuracy.
import torch
from transformers import PaliGemmaProcessor, PaliGemmaForConditionalGeneration, BitsAndBytesConfig
from PIL import Image
# Optimized quantization configuration
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16
)
device = "cuda" if torch.cuda.is_available() else "cpu"
# Initialize model components
processor = PaliGemmaProcessor.from_pretrained("MagiBoss/PaliGemma2-3b-224-COCO")
model = PaliGemmaForConditionalGeneration.from_pretrained(
"MagiBoss/PaliGemma2-3b-224-COCO",
quantization_config=quantization_config,
torch_dtype=torch.bfloat16,
device_map="auto"
)
model.eval()
def generate_caption(image_path):
"""
Generate Thai caption for input image with optimized parameters.
Args:
image_path (str): Path to input image
Returns:
str: Generated Thai caption
"""
image = Image.open(image_path).convert("RGB")
question = "อธิบายภาพด้านล่างนี้ด้วยคำบรรยายที่ชัดเจนและละเอียดเป็นภาษาไทย"
prompt = f"<image> {question}"
model_inputs = processor(
text=[prompt],
images=[image],
padding="max_length",
return_tensors="pt"
).to(device)
with torch.inference_mode():
output = model.generate(
input_ids=model_inputs["input_ids"],
pixel_values=model_inputs["pixel_values"],
attention_mask=model_inputs["attention_mask"],
max_new_tokens=25, # Optimized token length
do_sample=False
)
return processor.decode(output[0], skip_special_tokens=True)
# Example usage
image_path = "example.jpg"
caption = generate_caption(image_path)
print("Generated Caption:", caption)
Dataset Expansion
Model Improvements
Evaluation Methods
Special thanks to:
@misc{PaliGemma2-3b-224-COCO,
author = {MagiBoss},
title = {PaliGemma2-3b-224-COCO},
year = {2025},
publisher = {Hugging Face},
note = {https://huggingface.co/MagiBoss/PaliGemma2-3b-224-COCO}
}