atasoglu/flickr8k-turkish
Viewer โข Updated โข 8k โข 87 โข 4
Run atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased with Transformers:
# 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="atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased")
model = AutoModelForMultimodalLM.from_pretrained("atasoglu/vit-tiny-patch16-224-turkish-small-bert-uncased", device_map="auto")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)