Update README.md
Browse files
README.md
CHANGED
@@ -7,6 +7,7 @@ tags:
|
|
7 |
- image-text-to-text
|
8 |
language:
|
9 |
- en
|
|
|
10 |
---
|
11 |
|
12 |
# LLaVa-Next Model Card
|
@@ -35,10 +36,6 @@ other versions on a task that interests you.
|
|
35 |
|
36 |
### How to use
|
37 |
|
38 |
-
Here's the prompt template for this model:
|
39 |
-
```
|
40 |
-
"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:"
|
41 |
-
```
|
42 |
You can load and use the model like following:
|
43 |
```python
|
44 |
from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
|
@@ -52,7 +49,20 @@ model = LlavaNextForConditionalGeneration.from_pretrained("llava-hf/llava-next-7
|
|
52 |
# prepare image and text prompt, using the appropriate prompt template
|
53 |
url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
|
54 |
image = Image.open(requests.get(url, stream=True).raw)
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
inputs = processor(prompt, image, return_tensors="pt").to(model.device)
|
58 |
|
|
|
7 |
- image-text-to-text
|
8 |
language:
|
9 |
- en
|
10 |
+
pipeline_tag: image-text-to-text
|
11 |
---
|
12 |
|
13 |
# LLaVa-Next Model Card
|
|
|
36 |
|
37 |
### How to use
|
38 |
|
|
|
|
|
|
|
|
|
39 |
You can load and use the model like following:
|
40 |
```python
|
41 |
from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration
|
|
|
49 |
# prepare image and text prompt, using the appropriate prompt template
|
50 |
url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
|
51 |
image = Image.open(requests.get(url, stream=True).raw)
|
52 |
+
|
53 |
+
# Define a chat histiry and use `apply_chat_template` to get correctly formatted prompt
|
54 |
+
# Each value in "content" has to be a list of dicts with types ("text", "image")
|
55 |
+
conversation = [
|
56 |
+
{
|
57 |
+
|
58 |
+
"role": "user",
|
59 |
+
"content": [
|
60 |
+
{"type": "text", "text": "What is shown in this image?"},
|
61 |
+
{"type": "image"},
|
62 |
+
],
|
63 |
+
},
|
64 |
+
]
|
65 |
+
prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
|
66 |
|
67 |
inputs = processor(prompt, image, return_tensors="pt").to(model.device)
|
68 |
|