Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,50 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: ytu-ce-cosmos/Turkish-LLaVA-v0.1
|
3 |
+
license: mit
|
4 |
+
language:
|
5 |
+
- tr
|
6 |
+
tags:
|
7 |
+
- LLaVA
|
8 |
+
- llava_llama
|
9 |
+
---
|
10 |
+
|
11 |
+
## Usage
|
12 |
+
|
13 |
+
```py
|
14 |
+
from llama_cpp import Llama
|
15 |
+
from llama_cpp.llama_chat_format import Llama3VisionAlphaChatHandler
|
16 |
+
|
17 |
+
llm = Llama(
|
18 |
+
model_path="Turkish-LLaVA-v0.1-Q4_K_M.gguf", # path to language model
|
19 |
+
n_gpu_layers=-1, # -for running on GPU
|
20 |
+
chat_handler=Llama3VisionAlphaChatHandler(
|
21 |
+
# path to image encoder
|
22 |
+
clip_model_path="Turkish-LLaVA-v0.1-mmproj-F16.gguf",
|
23 |
+
),
|
24 |
+
seed=1337, # for reproducing same results
|
25 |
+
n_ctx=4096, # n_ctx should be increased to accommodate the image embedding
|
26 |
+
verbose=False, # disable the logging
|
27 |
+
)
|
28 |
+
|
29 |
+
# url for the input image
|
30 |
+
url = "https://huggingface.co/ytu-ce-cosmos/Turkish-LLaVA-v0.1/resolve/main/example.jpg"
|
31 |
+
|
32 |
+
messages = [
|
33 |
+
{"role": "system", "content": "Sen yardımsever bir asistansın."},
|
34 |
+
{
|
35 |
+
"role": "user",
|
36 |
+
"content": [
|
37 |
+
{"type" : "text", "text": "Bu resimde neler görüyorsun?"},
|
38 |
+
{"type": "image_url", "image_url": {"url": url}}
|
39 |
+
]
|
40 |
+
},
|
41 |
+
]
|
42 |
+
|
43 |
+
response = llm.create_chat_completion(
|
44 |
+
messages=messages,
|
45 |
+
max_tokens=64,
|
46 |
+
)
|
47 |
+
|
48 |
+
print(response["choices"][0]["message"]["content"])
|
49 |
+
# Output: Resimde, sarı çiçeklerle çevrili bir köpek yavrusu görülüyor.
|
50 |
+
```
|