Instructions to use Revrse/icon-captioning-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Revrse/icon-captioning-model 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="Revrse/icon-captioning-model")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Revrse/icon-captioning-model") model = AutoModelForMultimodalLM.from_pretrained("Revrse/icon-captioning-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Revrse/icon-captioning-model: direct link, hf CLI and curl.
- Browser
- Download file 920 Bytes
-
https://huggingface.co/Revrse/icon-captioning-model/resolve/main/README.md
- Command line
-
hf download hf://Revrse/icon-captioning-model/README.md
-
curl -L -o README.md https://huggingface.co/Revrse/icon-captioning-model/resolve/main/README.md
920 Bytes
| pipeline_tag: image-to-text | |
| tags: | |
| - image-captioning | |
| languages: | |
| - en | |
| license: bsd-3-clause | |
| ```python | |
| import requests | |
| from PIL import Image | |
| from transformers import BlipProcessor, BlipForConditionalGeneration | |
| processor = BlipProcessor.from_pretrained("Revrse/icon-captioning-model") | |
| model = BlipForConditionalGeneration.from_pretrained("Revrse/icon-captioning-model") | |
| 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') | |
| # conditional image captioning | |
| text = "a photography of" | |
| inputs = processor(raw_image, text, return_tensors="pt") | |
| out = model.generate(**inputs) | |
| print(processor.decode(out[0], skip_special_tokens=True)) | |
| # unconditional image captioning | |
| inputs = processor(raw_image, return_tensors="pt") | |
| out = model.generate(**inputs) | |
| print(processor.decode(out[0], skip_special_tokens=True)) | |
| ``` |