Downloads · 30 days
22
1% of all-time downloads
dumperize/movie-picture-captioning
movie-picture-captioning is a image-to-text model from dumperize. 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.
The model generates descriptions of any photo in the style of movie descriptions. It learned from movie posters and descriptions. ... just for fun
Downloads · 30 days
22
1% of all-time downloads
All-time downloads
2.3K
Public
Repo size
2.3 GB
Likes
4
Public
Click a slice to open those files.
.bin1.2 GB · 100%
From the Hugging Face model README
The model generates descriptions of any photo in the style of movie descriptions. It learned from movie posters and descriptions. ... just for fun
This is an encoder-decoder model based on VisionEncoderDecoderModel. Google/vit-base-patch16-224-in21k was used as the encoder, DeepPavlov/rubert-base-cased as the decoder.
We refined the model on the dataset with descriptions and movie posters by the russian app Kinoposk. Now the model generates descriptions of the jargon of blockbusters =).
from PIL import Image
import torch
from transformers import AutoTokenizer, ViTFeatureExtractor, VisionEncoderDecoderModel
tokenizer = AutoTokenizer.from_pretrained("dumperize/movie-picture-captioning")
feature_extractor = ViTFeatureExtractor.from_pretrained("dumperize/movie-picture-captioning")
model = VisionEncoderDecoderModel.from_pretrained("dumperize/movie-picture-captioning")
max_length = 128
num_beams = 4
gen_kwargs = {"max_length": max_length, "num_beams": num_beams}
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
image_path = 'path/to/image.jpg';
image = Image.open(image_path)
image = image.resize([224,224])
if image.mode != "RGB":
image = image.convert(mode="RGB")
pixel_values = feature_extractor(images=[image], 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)
print([pred.strip() for pred in preds])
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased predictions.
We compiled a dataset from the open source of all Russian-language films for October 2022 - kinopoisk. Films with very short or very long descriptions were not included in the dataset, films with blank or very small images were excluded too.
The model was trained on 1x1080ti (11Gb) near 24 hours.
This model achieved the following results: sacrebleu 6.84
We used sacrebleu metric.