Views
No views yet
NOTE: The reproduced version of LLaVA has some different implementation details than the original LLaVA model.
- The reproduced LLaVA uses a different conversation template than the original LLaVA model.
- The initial model weights are loaded from Llama 3.1 8B Instruct model (meta-llama/Llama 3.1-8B-Instruct) rather than lmsys/vicuna-7b-v1.5.
1from transformers import (
2 LlavaForConditionalGeneration,
3 AutoProcessor,
4)
5from PIL import Image
6
7path = <path_to_model_dir>
8processor = AutoProcessor.from_pretrained(path)
9model = LlavaForConditionalGeneration.from_pretrained(path)
10
11prompt = "<|start_header_id|>user<|end_header_id|>: <image> Give an overview of what's in the image.\n<|start_header_id|>assistant<|end_header_id|>: "
12image_path = "align-anything/assets/test_image.webp"
13image = Image.open(image_path)
14
15inputs = processor(text=prompt, images=image, return_tensors="pt")
16outputs = model.generate(**inputs, max_new_tokens=1024)
17print(processor.decode(outputs[0], skip_special_tokens=True))