Downloads · 30 days
13
2% of all-time downloads
Natthaphon/thaicapgen-convnext-wangchan
thaicapgen-convnext-wangchan is a image-to-text model from Natthaphon. Use it when you need a caption or text from an image.
Encoder-decoder style image captioning model using ConvNeXt V2 and Wangchanberta. Trained on Thai language MSCOCO and IPU24 dataset.
Downloads · 30 days
13
2% of all-time downloads
All-time downloads
612
Public
Parameters
241M
966 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors965 MB · 100%
From the Hugging Face model README
Encoder-decoder style image captioning model using ConvNeXt V2 and Wangchanberta. Trained on Thai language MSCOCO and IPU24 dataset.
Use AutoModel to load it. Requires trust_remote_code=True.
from transformers import AutoModel, AutoImageProcessor, AutoTokenizer
device = 'cuda'
gen_kwargs = {"max_length": 120, "num_beams": 4}
model_path = 'Natthaphon/thaicapgen-clip-gpt2'
feature_extractor = AutoImageProcessor.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(device)
pixel_values = feature_extractor(images=[Image.open(image_path)], return_tensors="pt").pixel_values
pixel_values = pixel_values.to(device)
output_ids = model.generate(pixel_values, **gen_kwargs)
preds = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
This work is partially supported by the Program Management Unit for Human Resources & Institutional Development, Research and Innovation (PMU-B) [Grant number B04G640107]