Update README.md
Browse files
README.md
CHANGED
@@ -3,6 +3,9 @@ license: apache-2.0
|
|
3 |
tags:
|
4 |
- vision
|
5 |
- image-text-to-text
|
|
|
|
|
|
|
6 |
---
|
7 |
|
8 |
# LLaVa-Next, leveraging [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) as LLM
|
@@ -47,7 +50,20 @@ model.to("cuda:0")
|
|
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 |
|
52 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
53 |
|
|
|
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, leveraging [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) as LLM
|
|
|
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 |
|