RaushanTurganbay HF staff commited on
Commit
9fefcad
1 Parent(s): 2c1ee53

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -5
README.md CHANGED
@@ -3,6 +3,9 @@ license: llama3
3
  tags:
4
  - vision
5
  - image-text-to-text
 
 
 
6
  ---
7
 
8
  # LLaVa-Next Model Card
@@ -31,10 +34,6 @@ other versions on a task that interests you.
31
 
32
  ### How to use
33
 
34
- Here's the prompt template for this model:
35
- ```
36
- "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. USER: <image>\nWhat is shown in this image? ASSISTANT:"
37
- ```
38
  You can load and use the model like following:
39
  ```python
40
  from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
@@ -48,7 +47,20 @@ model = LlavaNextForConditionalGeneration.from_pretrained("llava-hf/llama3-llava
48
  # prepare image and text prompt, using the appropriate prompt template
49
  url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
50
  image = Image.open(requests.get(url, stream=True).raw)
51
- prompt = "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. USER: <image>\nWhat is shown in this image? ASSISTANT:"
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  inputs = processor(prompt, image, return_tensors="pt").to(model.device)
54
 
 
3
  tags:
4
  - vision
5
  - image-text-to-text
6
+ language:
7
+ - en
8
+ pipeline_tag: image-text-to-text
9
  ---
10
 
11
  # LLaVa-Next Model Card
 
34
 
35
  ### How to use
36
 
 
 
 
 
37
  You can load and use the model like following:
38
  ```python
39
  from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
 
47
  # prepare image and text prompt, using the appropriate prompt template
48
  url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
49
  image = Image.open(requests.get(url, stream=True).raw)
50
+
51
+ # Define a chat histiry and use `apply_chat_template` to get correctly formatted prompt
52
+ # Each value in "content" has to be a list of dicts with types ("text", "image")
53
+ conversation = [
54
+ {
55
+
56
+ "role": "user",
57
+ "content": [
58
+ {"type": "text", "text": "What is shown in this image?"},
59
+ {"type": "image"},
60
+ ],
61
+ },
62
+ ]
63
+ prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
64
 
65
  inputs = processor(prompt, image, return_tensors="pt").to(model.device)
66