Downloads · 30 days
13
1% of all-time downloads
lokibots/vit-patch16-1280-gpt2-large-image-summary
vit-patch16-1280-gpt2-large-image-summary is a image-to-text model from lokibots. Use it when you need a caption or text from an image. It is set up for transformers.
This model generates a summary from a given chart image. The model accepts an image of size 1280x768 (or less) and generates a summary describing the contents of the image. However, training is still required.
Downloads · 30 days
13
1% of all-time downloads
All-time downloads
1.7K
Public
Repo size
10.3 GB
Likes
0
Public
Click a slice to open those files.
.bin5.2 GB · 100%
From the Hugging Face model README
This model generates a summary from a given chart image. The model accepts an image of size 1280x768 (or less) and generates a summary describing the contents of the image. However, training is still required.
from transformers import VisionEncoderDecoderModel, ViTFeatureExtractor, GPT2Tokenizer
from PIL import Image
model = VisionEncoderDecoderModel.from_pretrained("lokibots/vit-patch16-1280-gpt2-large-image-summary")
feature_extractor = ViTFeatureExtractor.from_pretrained("lokibots/vit-patch16-1280-gpt2-large-image-summary")
tokenizer = GPT2Tokenizer.from_pretrained('gpt2-large')
image = Image.open("image_file").convert("RGB")
pixel_values = feature_extractor(images=image, return_tensors="pt").pixel_values
gen_kwargs = {"max_length": 1024, "num_beams": 4}
output_ids = model.generate(pixel_values, **gen_kwargs)
preds = tokenizer.batch_decode(output_ids, skip_special_tokens=True)