Download test from Jayanath1987/Pytorch: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/Jayanath1987/Pytorch/resolve/main/test
- Command line
-
hf download hf://Jayanath1987/Pytorch/test
-
curl -L -o test https://huggingface.co/Jayanath1987/Pytorch/resolve/main/test
662 Bytes
| import requests | |
| from PIL import Image | |
| from transformers import BlipProcessor, BlipForQuestionAnswering | |
| processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-capfilt-large") | |
| model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-capfilt-large").to("cuda") | |
| img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg' | |
| raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB') | |
| question = "how many dogs are in the picture?" | |
| inputs = processor(raw_image, question, return_tensors="pt").to("cuda") | |
| out = model.generate(**inputs) | |
| print(processor.decode(out[0], skip_special_tokens=True)) | |
| >>> 1 | |