How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
# Warning: Pipeline type "image-to-text" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline

pipe = pipeline("image-to-text", model="kkatiz/THAI-BLIP-2")
# Load model directly
from transformers import AutoProcessor, AutoModelForVisualQuestionAnswering

processor = AutoProcessor.from_pretrained("kkatiz/THAI-BLIP-2")
model = AutoModelForVisualQuestionAnswering.from_pretrained("kkatiz/THAI-BLIP-2")
Quick Links

THAI-BLIP-2

fine-tuned for image captioning task from blip2-opt-2.7b-coco with MSCOCO2017 thai caption.

How to use:

from transformers import Blip2ForConditionalGeneration, Blip2Processor
from PIL import Image
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"

processor = Blip2Processor.from_pretrained("kkatiz/THAI-BLIP-2")
model = Blip2ForConditionalGeneration.from_pretrained("kkatiz/THAI-BLIP-2", device_map=device, torch_dtype=torch.bfloat16)

img = Image.open("Your image...")
inputs = processor(images=img, return_tensors="pt").to(device, torch.bfloat16)

# Adjust your `max_length`
generated_ids = model.generate(**inputs, max_length=20)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_text)
Downloads last month
84
Safetensors
Model size
10B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kkatiz/THAI-BLIP-2

Finetuned
(4)
this model