Instructions to use Leonardo6/llava-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Leonardo6/llava-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Leonardo6/llava-7b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Leonardo6/llava-7b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download processing_vlm.py from Leonardo6/llava-7b: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/Leonardo6/llava-7b/resolve/main/processing_vlm.py
- Command line
-
hf download hf://Leonardo6/llava-7b/processing_vlm.py
-
curl -L -o processing_vlm.py https://huggingface.co/Leonardo6/llava-7b/resolve/main/processing_vlm.py
1.33 kB
| from typing import Any | |
| from transformers import AutoImageProcessor, AutoProcessor, AutoTokenizer, ProcessorMixin | |
| from .configuration_vlm import VLMConfig | |
| class VLMProcessor(ProcessorMixin): | |
| attributes: list[str] = ["image_processor", "tokenizer"] | |
| image_processor_class: str = "AutoImageProcessor" | |
| tokenizer_class: str = "AutoTokenizer" | |
| def __init__( | |
| self, | |
| image_processor: AutoImageProcessor = None, | |
| tokenizer: AutoTokenizer = None, | |
| **kwargs: Any, | |
| ): | |
| super().__init__(image_processor, tokenizer, **kwargs) | |
| def from_names(cls, image_processor_name: str, tokenizer_name: str, **kwargs: Any): | |
| image_processor_args = { | |
| k: v for k, v in kwargs.items() if k in ["trust_remote_code", "use_fast"] | |
| } | |
| tokenizer_args = { | |
| k: v | |
| for k, v in kwargs.items() | |
| if k in ["trust_remote_code", "use_fast", "model_max_length", "padding_side"] | |
| } | |
| tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, **tokenizer_args) | |
| image_processor = AutoImageProcessor.from_pretrained( | |
| image_processor_name, **image_processor_args | |
| ) | |
| return cls(image_processor=image_processor, tokenizer=tokenizer) | |
| AutoProcessor.register(VLMConfig, VLMProcessor) |