Instructions to use Zero-Vision/Llama-3-MixSenseV1_1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zero-Vision/Llama-3-MixSenseV1_1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zero-Vision/Llama-3-MixSenseV1_1", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Zero-Vision/Llama-3-MixSenseV1_1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Zero-Vision/Llama-3-MixSenseV1_1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Zero-Vision/Llama-3-MixSenseV1_1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Zero-Vision/Llama-3-MixSenseV1_1
- SGLang
How to use Zero-Vision/Llama-3-MixSenseV1_1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Zero-Vision/Llama-3-MixSenseV1_1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Zero-Vision/Llama-3-MixSenseV1_1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Zero-Vision/Llama-3-MixSenseV1_1 with Docker Model Runner:
docker model run hf.co/Zero-Vision/Llama-3-MixSenseV1_1
Download demo.py from Zero-Vision/Llama-3-MixSenseV1_1: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/Zero-Vision/Llama-3-MixSenseV1_1/resolve/main/demo.py
- Command line
-
hf download hf://Zero-Vision/Llama-3-MixSenseV1_1/demo.py
-
curl -L -o demo.py https://huggingface.co/Zero-Vision/Llama-3-MixSenseV1_1/resolve/main/demo.py
1.28 kB
| import torch | |
| import transformers | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from PIL import Image | |
| import warnings | |
| import os | |
| os.environ["HF_ENDPOINT"] = "https://hf-mirror.com" | |
| # disable some warnings | |
| transformers.logging.set_verbosity_error() | |
| transformers.logging.disable_progress_bar() | |
| warnings.filterwarnings("ignore") | |
| # set device | |
| device = "cuda" # or cpu | |
| # create model | |
| model = AutoModelForCausalLM.from_pretrained( | |
| "Zero-Vision/Llama-3-MixSenseV1_1", | |
| torch_dtype=torch.float16, | |
| device_map="auto", | |
| trust_remote_code=True, | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| "Zero-Vision/Llama-3-MixSenseV1_1", | |
| trust_remote_code=True, | |
| ) | |
| qs = "describe the image detailly." | |
| input_ids = model.text_process(qs, tokenizer).to(device) | |
| image = Image.open("example.jpg") | |
| image_tensor = model.image_process([image]).to(dtype=model.dtype, device=device) | |
| # generate | |
| with torch.inference_mode(): | |
| output_ids = model.generate( | |
| input_ids, | |
| images=image_tensor, | |
| max_new_tokens=2048, | |
| use_cache=True, | |
| eos_token_id=[ | |
| tokenizer.eos_token_id, | |
| tokenizer.convert_tokens_to_ids(["<|eot_id|>"])[0], | |
| ], | |
| ) | |
| print(tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip()) |