Image-to-Text
Transformers
Safetensors
Indonesian
English
vision-encoder-decoder
image-text-to-text
image-captioning
vision-transformer
ViT-B/16
Instructions to use evlinzxxx/my_model_ViTB-16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use evlinzxxx/my_model_ViTB-16 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="evlinzxxx/my_model_ViTB-16")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("evlinzxxx/my_model_ViTB-16") model = AutoModelForImageTextToText.from_pretrained("evlinzxxx/my_model_ViTB-16") - Notebooks
- Google Colab
- Kaggle
Sample running code
from transformers import VisionEncoderDecoderModel, ViTImageProcessor, GPT2Tokenizer
import torch
from PIL import Image
model = VisionEncoderDecoderModel.from_pretrained("evlinzxxx/my_model_ViTB-16")
feature_extractor = ViTImageProcessor.from_pretrained("evlinzxxx/my_model_ViTB-16")
tokenizer = GPT2Tokenizer.from_pretrained("evlinzxxx/my_model_ViTB-16")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
def show_image_and_captions(url):
# get the image and display it
display(load_image(url))
# get the captions on various models
our_caption = get_caption(model, image_processor, tokenizer, url)
# print the captions
print(f"Our caption: {our_caption}")
show_image_and_captions("/content/drive/MyDrive/try/test_400/gl_16.jpg") # ['navigate around the obstacle ahead adjusting your route to bypass the parked car.']
- Downloads last month
- 6