Downloads · 30 days
19
4% of all-time downloads
atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased
vit-tiny-patch16-224-turkish-small-bert-uncased is a image-to-text model from atasoglu. Use it when you need a caption or text from an image. It is set up for transformers. The card lists the license as apache-2.0.
This vision encoder-decoder model utilizes the WinKawaks/vit-tiny-patch16-224 as the encoder and ytu-ce-cosmos/turkish-small-bert-uncased as the decoder, and it has been fine-tuned on the flickr8k-turkish dataset to g…
Downloads · 30 days
19
4% of all-time downloads
All-time downloads
464
Public
Parameters
39.4M
158 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors158 MB · 100%
From the Hugging Face model README
This vision encoder-decoder model utilizes the WinKawaks/vit-tiny-patch16-224 as the encoder and ytu-ce-cosmos/turkish-small-bert-uncased as the decoder, and it has been fine-tuned on the flickr8k-turkish dataset to generate image captions in Turkish.
import torch
from transformers import VisionEncoderDecoderModel, ViTImageProcessor, AutoTokenizer
from PIL import Image
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_id = "atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased"
img = Image.open("example.jpg")
feature_extractor = ViTImageProcessor.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = VisionEncoderDecoderModel.from_pretrained(model_id)
model.to(device)
features = feature_extractor(images=[img], return_tensors="pt")
pixel_values = features.pixel_values.to(device)
generated_captions = tokenizer.batch_decode(
model.generate(pixel_values, max_new_tokens=20),
skip_special_tokens=True,
)
print(generated_captions)