Views
No views yet
1import requests
2from PIL import Image
3from transformers import BlipProcessor, BlipForConditionalGeneration
4import torch
5
6device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
7processor = BlipProcessor.from_pretrained("noamrot/FuseCap")
8model = BlipForConditionalGeneration.from_pretrained("noamrot/FuseCap").to(device)
9
10img_url = 'https://huggingface.co/spaces/noamrot/FuseCap/resolve/main/bike.jpg'
11raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
12
13text = "a picture of "
14inputs = processor(raw_image, text, return_tensors="pt").to(device)
15
16out = model.generate(**inputs, num_beams = 3)
17print(processor.decode(out[0], skip_special_tokens=True))1@inproceedings{rotstein2024fusecap,
2 title={Fusecap: Leveraging large language models for enriched fused image captions},
3 author={Rotstein, Noam and Bensa{\"\i}d, David and Brody, Shaked and Ganz, Roy and Kimmel, Ron},
4 booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision},
5 pages={5689--5700},
6 year={2024}
7}