RaushanTurganbay HF staff commited on
Commit
982f7ce
1 Parent(s): ccd5c91

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -2
README.md CHANGED
@@ -2,6 +2,9 @@
2
  tags:
3
  - vision
4
  - image-text-to-text
 
 
 
5
  ---
6
 
7
  # LLaVa-Next, leveraging [NousResearch/Nous-Hermes-2-Yi-34B](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B) as LLM
@@ -29,8 +32,9 @@ other versions on a task that interests you.
29
 
30
  Here's the prompt template for this model:
31
  ```
32
- "<|im_start|>system\nAnswer the questions.<|im_end|><|im_start|>user\n<image>\n<your_text_prompt_here><|im_end|><|im_start|>assistant\n"
33
  ```
 
34
  You can load and use the model like following:
35
  ```python
36
  from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
@@ -46,7 +50,20 @@ model.to("cuda:0")
46
  # prepare image and text prompt, using the appropriate prompt template
47
  url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
48
  image = Image.open(requests.get(url, stream=True).raw)
49
- prompt = "<|im_start|>system\nAnswer the questions.<|im_end|><|im_start|>user\n<image>\nWhat is shown in this image?<|im_end|><|im_start|>assistant\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
52
 
 
2
  tags:
3
  - vision
4
  - image-text-to-text
5
+ language:
6
+ - en
7
+ pipeline_tag: image-text-to-text
8
  ---
9
 
10
  # LLaVa-Next, leveraging [NousResearch/Nous-Hermes-2-Yi-34B](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B) as LLM
 
32
 
33
  Here's the prompt template for this model:
34
  ```
35
+ "<|im_start|>system\n<your_system_prompt_here><|im_end|><|im_start|>user\n<image>\n<your_text_prompt_here><|im_end|><|im_start|>assistant\n"
36
  ```
37
+
38
  You can load and use the model like following:
39
  ```python
40
  from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
 
50
  # prepare image and text prompt, using the appropriate prompt template
51
  url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
52
  image = Image.open(requests.get(url, stream=True).raw)
53
+
54
+ # Define a chat histiry and use `apply_chat_template` to get correctly formatted prompt
55
+ # Each value in "content" has to be a list of dicts with types ("text", "image")
56
+ conversation = [
57
+ {
58
+
59
+ "role": "user",
60
+ "content": [
61
+ {"type": "text", "text": "What is shown in this image?"},
62
+ {"type": "image"},
63
+ ],
64
+ },
65
+ ]
66
+ prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
67
 
68
  inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
69