Elffuss BraidHub

kikocis/mlx-vlm public

Update readme
Changeset840f8c6cca3351c92dfbae4f16ddcdc330b7a6bc0dbcc7caeb7068a7b4b4eaa8
AuthorPrince Canuma <prince.gdt@gmail.com> · 2024-04-16 17:28 +02:00
CommitterPrince Canuma <prince.gdt@gmail.com> · 2024-04-16 17:28 +02:00
Parentsff49c567c0d4

Browse the files at this changeset

1 file changed

added src/models/llava/README.md +61 −0
@@ -0,0 +1,61 @@
1+# LLaVA
2+
3+An example of LLaVA: Large Language and Vision Assistant in MLX.[^1] LLlava is
4+a multimodal model that can generate text given combined image and text inputs.
5+
6+## Setup
7+
8+Install the dependencies:
9+
10+```bash
11+pip install -r requirements.txt
12+```
13+
14+## Run
15+
16+You can use LLaVA to ask questions about images.
17+
18+For example, using the command line:
19+
20+```bash
21+python generate.py \
22+ --model llava-hf/llava-1.5-7b-hf \
23+ --image "http://images.cocodataset.org/val2017/000000039769.jpg" \
24+ --prompt "USER: <image>\nWhat are these?\nASSISTANT:" \
25+ --max-tokens 128 \
26+ --temp 0
27+```
28+
29+This uses the following image:
30+
31+![alt text](http://images.cocodataset.org/val2017/000000039769.jpg)
32+
33+And generates the output:
34+
35+```
36+These are two cats lying on a pink couch.
37+```
38+
39+You can also use LLaVA in Python:
40+
41+```python
42+from generate import load_model, prepare_inputs, generate_text
43+
44+processor, model = load_model("llava-hf/llava-1.5-7b-hf")
45+
46+max_tokens, temperature = 128, 0.0
47+
48+prompt = "USER: <image>\nWhat are these?\nASSISTANT:"
49+image = "http://images.cocodataset.org/val2017/000000039769.jpg"
50+input_ids, pixel_values = prepare_inputs(processor, image, prompt)
51+
52+reply = generate_text(
53+ input_ids, pixel_values, model, processor, max_tokens, temperature
54+)
55+
56+print(reply)
57+```
58+
59+[^1]:
60+ Refer to [LLaVA project webpage](https://llava-vl.github.io/) for more
61+ information.