Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,62 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- FreedomIntelligence/ALLaVA-4V
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: text-generation
|
8 |
---
|
9 |
+
|
10 |
+
Quick start:
|
11 |
+
|
12 |
+
```shell
|
13 |
+
from transformers import AutoModelForCausalLM
|
14 |
+
from transformers import AutoTokenizer
|
15 |
+
import torch
|
16 |
+
import pdb
|
17 |
+
|
18 |
+
dir = "FreedomIntelligence/ALLaVA-3B-Longer"
|
19 |
+
|
20 |
+
device = 'cuda'
|
21 |
+
model = AutoModelForCausalLM.from_pretrained(dir, trust_remote_code=True, device_map=device, torch_dtype=torch.bfloat16)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(dir)
|
23 |
+
model.tokenizer = tokenizer
|
24 |
+
|
25 |
+
gen_kwargs = {
|
26 |
+
'min_new_tokens': 20,
|
27 |
+
'max_new_tokens': 100,
|
28 |
+
'do_sample': False,
|
29 |
+
'eos_token_id': tokenizer.eos_token_id
|
30 |
+
}
|
31 |
+
|
32 |
+
response, history = model.chat(
|
33 |
+
texts='What is in the image?',
|
34 |
+
images=['https://cdn-icons-png.flaticon.com/256/6028/6028690.png'],
|
35 |
+
return_history=True,
|
36 |
+
**gen_kwargs
|
37 |
+
)
|
38 |
+
|
39 |
+
# response:
|
40 |
+
# The image contains a large, stylized "HI!" in a bright pink color with yellow outlines. The "HI!" is placed within a speech bubble shape.
|
41 |
+
|
42 |
+
# history:
|
43 |
+
# [['What is in the image?', 'The image contains a large, stylized "HI!" in a bright pink color with yellow outlines. The "HI!" is placed within a speech bubble shape.']]
|
44 |
+
|
45 |
+
print(response)
|
46 |
+
|
47 |
+
response, history = model.chat(
|
48 |
+
texts='Are you sure?',
|
49 |
+
images=['https://cdn-icons-png.flaticon.com/256/6028/6028690.png'], # images need to be passed again in multi-round conversations
|
50 |
+
history=history,
|
51 |
+
return_history=True,
|
52 |
+
**gen_kwargs
|
53 |
+
)
|
54 |
+
|
55 |
+
print(response)
|
56 |
+
# response:
|
57 |
+
# Yes, I'm certain. The image is a graphic representation of the word "HI!" in a speech bubble.
|
58 |
+
|
59 |
+
# history:
|
60 |
+
# [['What is in the image?', 'The image contains a large, stylized "HI!" in a bright pink color with yellow outlines. The "HI!" is placed within a speech bubble shape.'], ['Are you sure?', 'Yes, I\'m certain. The image is a graphic representation of the word "HI!" in a speech bubble.']]
|
61 |
+
|
62 |
+
```
|