Update README.md
Browse files
README.md
CHANGED
@@ -8,35 +8,21 @@ pipeline_tag: image-text-to-text
|
|
8 |
We trained a TinyLLaVA model with 3.1B parameters, employing the same training settings as [TinyLLaVA](https://github.com/DLCV-BUAA/TinyLLaVABench). For the Language and Vision models, we chose [Phi-2](microsoft/phi-2) and [siglip-so400m-patch14-384](https://huggingface.co/google/siglip-so400m-patch14-384), respectively. The Connector was configured with a 2-layer MLP. The dataset used for training is the [ShareGPT4V](https://github.com/InternLM/InternLM-XComposer/blob/main/projects/ShareGPT4V/docs/Data.md) dataset.
|
9 |
|
10 |
### Usage
|
11 |
-
|
12 |
-
1. you need to download the generate file "generate_model.py".
|
13 |
-
2. running the following command:
|
14 |
-
```bash
|
15 |
-
python generate_model --model tinyllava/TinyLLaVA-Phi-2-SigLIP-3.1B --prompt 'you want to ask' --image '/path/to/related/image'
|
16 |
-
```
|
17 |
-
or execute the following test code:
|
18 |
```python
|
19 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
20 |
-
from generate_model import *
|
21 |
|
22 |
hf_path = 'tinyllava/TinyLLaVA-Phi-2-SigLIP-3.1B'
|
23 |
model = AutoModelForCausalLM.from_pretrained(hf_path, trust_remote_code=True)
|
|
|
24 |
config = model.config
|
25 |
tokenizer = AutoTokenizer.from_pretrained(hf_path, use_fast=False, model_max_length = config.tokenizer_model_max_length,padding_side = config.tokenizer_padding_side)
|
26 |
-
prompt="
|
27 |
-
|
28 |
-
output_text, genertaion_time =
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
f'{"-" * os.get_terminal_size().columns}\r\n'
|
33 |
-
f'{output_text}\r\n'
|
34 |
-
f'{"-" * os.get_terminal_size().columns}\r\n'
|
35 |
-
'\r\nGeneration took'
|
36 |
-
f'\033[1m\033[92m {round(genertaion_time, 2)} \033[0m'
|
37 |
-
'seconds.\r\n'
|
38 |
-
)
|
39 |
-
print(print_txt)
|
40 |
```
|
41 |
### Result
|
42 |
|
|
|
8 |
We trained a TinyLLaVA model with 3.1B parameters, employing the same training settings as [TinyLLaVA](https://github.com/DLCV-BUAA/TinyLLaVABench). For the Language and Vision models, we chose [Phi-2](microsoft/phi-2) and [siglip-so400m-patch14-384](https://huggingface.co/google/siglip-so400m-patch14-384), respectively. The Connector was configured with a 2-layer MLP. The dataset used for training is the [ShareGPT4V](https://github.com/InternLM/InternLM-XComposer/blob/main/projects/ShareGPT4V/docs/Data.md) dataset.
|
9 |
|
10 |
### Usage
|
11 |
+
Execute the following test code:
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
```python
|
13 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
14 |
|
15 |
hf_path = 'tinyllava/TinyLLaVA-Phi-2-SigLIP-3.1B'
|
16 |
model = AutoModelForCausalLM.from_pretrained(hf_path, trust_remote_code=True)
|
17 |
+
model.cuda()
|
18 |
config = model.config
|
19 |
tokenizer = AutoTokenizer.from_pretrained(hf_path, use_fast=False, model_max_length = config.tokenizer_model_max_length,padding_side = config.tokenizer_padding_side)
|
20 |
+
prompt="What are these?"
|
21 |
+
image_url="http://images.cocodataset.org/val2017/000000039769.jpg"
|
22 |
+
output_text, genertaion_time = model.chat(prompt=prompt, image=image_url, model=model, tokenizer=tokenizer)
|
23 |
+
|
24 |
+
print('model output: ', output_text)
|
25 |
+
print('runing time: ', genertaion_time)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
```
|
27 |
### Result
|
28 |
|