Instructions to use Zero-Vision/Llama-3-MixSense with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zero-Vision/Llama-3-MixSense with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zero-Vision/Llama-3-MixSense", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Zero-Vision/Llama-3-MixSense", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Zero-Vision/Llama-3-MixSense 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-MixSense" # 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-MixSense", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Zero-Vision/Llama-3-MixSense
- SGLang
How to use Zero-Vision/Llama-3-MixSense 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-MixSense" \ --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-MixSense", "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-MixSense" \ --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-MixSense", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Zero-Vision/Llama-3-MixSense with Docker Model Runner:
docker model run hf.co/Zero-Vision/Llama-3-MixSense
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Introduction
MixSense is a series of models based on the widely adopted vision encoder-projector-LLM architecture. In this resource, we release Llama-3-MixSense checkpoint,which is Built with Meta Llama 3 as the text encoder,and SigLIP 400M as the vision encoder . We have developed an innovative data processing method that complements the training process, reducing training costs while improving training effectiveness.,The models are trained on our restructured dataset. Details of the data organization and related research papers will be available soon.
QuickStart
Requirements
conda create -n mixsense python==3.10 -y
conda activate mixsense
pip install torch transformers==4.37.2 accelerate pillow
Usage
Llama-3-Mixsense/demo.py
import torch
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
import warnings
import os
# 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-MixSense",
torch_dtype=torch.float16, # float32 for cpu
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
"Zero-Vision/Llama-3-MixSense",
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())
Eval
We offer Llama-3-Mixsense/llama3mixsense.py for VLMEvalKit.
License
This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses.including but not limited to Llama3 and SigLIP. Meta Llama 3 is licensed under the Meta Llama 3 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved. And Apache LICENSE 2.0 for SigLIP model. The project itself is licensed under the Apache LICENSE 2.0 .
Acknowledgement
Our code is largely borrowed from LLaVA We bulid this demo according to bunny
- Downloads last month
- 3