Spaces:
Configuration error
Configuration error
Upload 4 files
Browse files- .gitignore +56 -0
- LICENCE +202 -0
- README.md +311 -13
- pyproject.toml +37 -0
.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# These are some examples of commonly ignored file patterns.
|
2 |
+
# You should customize this list as applicable to your project.
|
3 |
+
# Learn more about .gitignore:
|
4 |
+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
5 |
+
|
6 |
+
# Node artifact files
|
7 |
+
node_modules/
|
8 |
+
dist/
|
9 |
+
|
10 |
+
# Compiled Java class files
|
11 |
+
*.class
|
12 |
+
|
13 |
+
# Compiled Python bytecode
|
14 |
+
*.py[cod]
|
15 |
+
|
16 |
+
# Log files
|
17 |
+
*.log
|
18 |
+
|
19 |
+
# Package files
|
20 |
+
*.jar
|
21 |
+
|
22 |
+
# Maven
|
23 |
+
target/
|
24 |
+
dist/
|
25 |
+
|
26 |
+
# JetBrains IDE
|
27 |
+
.idea/
|
28 |
+
|
29 |
+
# Unit test reports
|
30 |
+
TEST*.xml
|
31 |
+
|
32 |
+
# Generated by MacOS
|
33 |
+
.DS_Store
|
34 |
+
|
35 |
+
Thumbs.db
|
36 |
+
|
37 |
+
# Applications
|
38 |
+
*.app
|
39 |
+
*.exe
|
40 |
+
*.war
|
41 |
+
|
42 |
+
# Large media files
|
43 |
+
*.mp4
|
44 |
+
*.tiff
|
45 |
+
*.avi
|
46 |
+
*.flv
|
47 |
+
*.mov
|
48 |
+
*.wmv
|
49 |
+
|
50 |
+
.ipynb_checkpoints
|
51 |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AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
202 |
+
|
README.md
CHANGED
@@ -1,13 +1,311 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h2 align="center"> <a href="https://arxiv.org/abs/2402.14289">TinyLLaVA: A Framework of Small-scale Large Multimodal Models</a>
|
2 |
+
|
3 |
+
<h5 align="center">
|
4 |
+
|
5 |
+
[![hf_space](https://img.shields.io/badge/π€-%20Open%20In%20HF-blue.svg)](https://huggingface.co/bczhou/TinyLLaVA-3.1B) [![arXiv](https://img.shields.io/badge/Arxiv-2402.14289-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2402.14289) [![License](https://img.shields.io/badge/License-Apache%202.0-yellow)](https://github.com/PKU-YuanGroup/MoE-LLaVA/blob/main/LICENSE)
|
6 |
+
|
7 |
+
|
8 |
+
## 🎉 News
|
9 |
+
* **[2024.03.10]** base recipe out!
|
10 |
+
* **[2024.03.10]** Finetune scripts out!
|
11 |
+
* **[2024.02.25]** Update evaluation scripts and docs!
|
12 |
+
* **[2024.02.25]** Data descriptions out. Release TinyLLaVA-1.5B and TinyLLaVA-2.0B!
|
13 |
+
* **[2024.02.24]** Example code on inference and model loading added!
|
14 |
+
* **[2024.02.23]** Evaluation code and scripts released!
|
15 |
+
* **[2024.02.21]** Creating the [TinyLLaVABench](https://github.com/DLCV-BUAA/TinyLLavaBench) repository on GitHub!
|
16 |
+
* **[2024.02.21]** Our paper: [TinyLLaVA: A Framework of Small-scale Large Multimodal Models](https://arxiv.org/abs/2402.14289) is out!
|
17 |
+
* **[2024.01.11]** Our fist model [TinyLLaVA-1.4B](https://huggingface.co/bczhou/tiny-llava-v1-hf) is out!
|
18 |
+
|
19 |
+
## ⌛ TODO
|
20 |
+
- [ ] Add support for Ollama and llama.cpp.
|
21 |
+
- [x] Developers' guide / How to build demo locally.
|
22 |
+
- [x] Training and custom finetuning docs.
|
23 |
+
- [x] Model Zoo descriptions.
|
24 |
+
- [x] Examples and inference.
|
25 |
+
- [x] Release code for training.
|
26 |
+
- [x] Add descriptions for evaluation.
|
27 |
+
- [x] Add descriptions for data preparation.
|
28 |
+
- [x] Release TinyLLaVA-1.5B and TinyLLaVA-2.0B.
|
29 |
+
- [x] Release TinyLLaVA-3.1B.
|
30 |
+
- [x] Release the evaluation code and weights today(2024.2.23).
|
31 |
+
### 🔥 High performance, but with fewer parameters
|
32 |
+
|
33 |
+
- Our best model, TinyLLaVA-3.1B, achieves better overall performance against existing 7B models such as LLaVA-1.5 and Qwen-VL.
|
34 |
+
|
35 |
+
## Contents
|
36 |
+
|
37 |
+
- [Install](#x1f527-requirements-and-installation)
|
38 |
+
- [Model Zoo](#x1f433-model-zoo)
|
39 |
+
- [Demo](#Demo)
|
40 |
+
- [Quick Start](#x1f527-quick-start)
|
41 |
+
- [Run Inference](#x1f527-run-inference)
|
42 |
+
- [Evaluation](#evaluation)
|
43 |
+
- [Data](#data-preparation)
|
44 |
+
- [Train](#train)
|
45 |
+
- [Custom Finetune](#custom-finetune)
|
46 |
+
|
47 |
+
|
48 |
+
## 🔧 Requirements and Installation
|
49 |
+
|
50 |
+
We recommend the requirements as follows.
|
51 |
+
|
52 |
+
1. Clone this repository and navigate to LLaVA folder
|
53 |
+
```bash
|
54 |
+
git clone https://github.com/DLCV-BUAA/TinyLLaVABench.git
|
55 |
+
cd TinyLLaVABench
|
56 |
+
```
|
57 |
+
|
58 |
+
2. Install Package
|
59 |
+
```Shell
|
60 |
+
conda create -n tinyllava python=3.10 -y
|
61 |
+
conda activate tinyllava
|
62 |
+
pip install --upgrade pip # enable PEP 660 support
|
63 |
+
pip install -e .
|
64 |
+
```
|
65 |
+
|
66 |
+
3. Install additional packages for training cases
|
67 |
+
```Shell
|
68 |
+
pip install -e ".[train]"
|
69 |
+
pip install flash-attn --no-build-isolation
|
70 |
+
```
|
71 |
+
### Upgrade to the latest code base
|
72 |
+
|
73 |
+
```Shell
|
74 |
+
git pull
|
75 |
+
pip install -e .
|
76 |
+
|
77 |
+
# if you see some import errors when you upgrade, please try running the command below (without #)
|
78 |
+
# pip install flash-attn --no-build-isolation --no-cache-dir
|
79 |
+
```
|
80 |
+
|
81 |
+
## 🐳 Model Zoo
|
82 |
+
### Legacy Model
|
83 |
+
- [tiny-llava-hf](https://huggingface.co/bczhou/tiny-llava-v1-hf)
|
84 |
+
|
85 |
+
### Pretrained Models
|
86 |
+
- [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B)
|
87 |
+
- [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B)
|
88 |
+
- [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B)
|
89 |
+
|
90 |
+
### Model Details
|
91 |
+
| Name | LLM | Checkpoint | LLaVA-Bench-Wild | MME | MMBench | MM-Vet | SQA-image | VQA-v2 | GQA | TextVQA |
|
92 |
+
|---------------|-------------------|------------------------------------------------|------------------|----------|---------|--------|-----------|--------|-------|---------|
|
93 |
+
| TinyLLaVA-3.1B | Phi-2 | [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B) | 75.8 | 1464.9 | 66.9 | 32.0 | 69.1 | 79.9 | 62.0 | 59.1 |
|
94 |
+
| TinyLLaVA-2.0B | StableLM-2-1.6B | [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B) | 66.4 | 1433.8 | 63.3 | 32.6 | 64.7 | 78.9 | 61.9 | 56.4 |
|
95 |
+
| TinyLLaVA-1.5B | TinyLlama | [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B) | 60.8 | 1276.5 | 55.2 | 25.8 | 60.3 | 76.9 | 60.3 | 51.7 |
|
96 |
+
|
97 |
+
|
98 |
+
## Demo
|
99 |
+
|
100 |
+
### Gradio Web Demo
|
101 |
+
|
102 |
+
Launch a local web demo by running:
|
103 |
+
```shell
|
104 |
+
python tinyllava/serve/app.py --model-path bczhou/TinyLLaVA-3.1B --model-name TinyLLaVA-3.1B
|
105 |
+
```
|
106 |
+
|
107 |
+
### CLI Inference
|
108 |
+
|
109 |
+
We also support running inference with CLI. To use our model, run:
|
110 |
+
```shell
|
111 |
+
python -m tinyllava.serve.cli \
|
112 |
+
--model-path bczhou/TinyLLaVA-3.1B \
|
113 |
+
--image-file "./tinyllava/serve/examples/extreme_ironing.jpg"
|
114 |
+
```
|
115 |
+
|
116 |
+
|
117 |
+
## 🔧 Quick Start
|
118 |
+
|
119 |
+
<details>
|
120 |
+
<summary>Load model</summary>
|
121 |
+
|
122 |
+
```Python
|
123 |
+
from tinyllava.model.builder import load_pretrained_model
|
124 |
+
from tinyllava.mm_utils import get_model_name_from_path
|
125 |
+
from tinyllava.eval.run_tiny_llava import eval_model
|
126 |
+
|
127 |
+
model_path = "bczhou/TinyLLaVA-3.1B"
|
128 |
+
|
129 |
+
tokenizer, model, image_processor, context_len = load_pretrained_model(
|
130 |
+
model_path=model_path,
|
131 |
+
model_base=None,
|
132 |
+
model_name=get_model_name_from_path(model_path)
|
133 |
+
)
|
134 |
+
```
|
135 |
+
</details>
|
136 |
+
|
137 |
+
## 🔧 Run Inference
|
138 |
+
Here's an example of running inference with [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B)
|
139 |
+
<details>
|
140 |
+
<summary>Run Inference</summary>
|
141 |
+
|
142 |
+
```Python
|
143 |
+
from tinyllava.model.builder import load_pretrained_model
|
144 |
+
from tinyllava.mm_utils import get_model_name_from_path
|
145 |
+
from tinyllava.eval.run_tiny_llava import eval_model
|
146 |
+
|
147 |
+
model_path = "bczhou/TinyLLaVA-3.1B"
|
148 |
+
prompt = "What are the things I should be cautious about when I visit here?"
|
149 |
+
image_file = "https://llava-vl.github.io/static/images/view.jpg"
|
150 |
+
|
151 |
+
args = type('Args', (), {
|
152 |
+
"model_path": model_path,
|
153 |
+
"model_base": None,
|
154 |
+
"model_name": get_model_name_from_path(model_path),
|
155 |
+
"query": prompt,
|
156 |
+
"conv_mode": "phi",
|
157 |
+
"image_file": image_file,
|
158 |
+
"sep": ",",
|
159 |
+
"temperature": 0,
|
160 |
+
"top_p": None,
|
161 |
+
"num_beams": 1,
|
162 |
+
"max_new_tokens": 512
|
163 |
+
})()
|
164 |
+
|
165 |
+
eval_model(args)
|
166 |
+
```
|
167 |
+
</details>
|
168 |
+
|
169 |
+
### Important
|
170 |
+
We use different `conv_mode` for different models. Replace the `conv_mode` in `args` according to this table:
|
171 |
+
| model | conv_mode |
|
172 |
+
|---------------- |----------- |
|
173 |
+
| TinyLLaVA-3.1B | phi |
|
174 |
+
| TinyLLaVA-2.0B | phi |
|
175 |
+
| TinyLLaVA-1.5B | v1 |
|
176 |
+
|
177 |
+
## Evaluation
|
178 |
+
To ensure the reproducibility, we evaluate the models with greedy decoding.
|
179 |
+
|
180 |
+
See [Evaluation.md](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/docs/Evaluation.md)
|
181 |
+
|
182 |
+
## Data Preparation
|
183 |
+
|
184 |
+
In our paper, we used two different datasets: the [LLaVA dataset](https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#pretrain-feature-alignment) and the [ShareGPT4V dataset](https://github.com/InternLM/InternLM-XComposer/blob/main/projects/ShareGPT4V/docs/Data.md), and compared their differences. In this section, we provide information on data preparation.
|
185 |
+
|
186 |
+
### Pretraining Images
|
187 |
+
* LLaVA: The pretraining images of LLaVA is from the 558K subset of the LAION-CC-SBU dataset.
|
188 |
+
* ShareGPT4V: The pretraining images of ShareGPT4V is a mixture of 558K LAION-CC-SBU subset, SAM dataset, and COCO dataset.
|
189 |
+
|
190 |
+
### Pretraining Annotations
|
191 |
+
* LLaVA: The pretraining annotations of LLaVA are [here](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain).
|
192 |
+
* ShareGPT4V: The pretraining annotations of ShareGPT4V are [here](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/share-captioner_coco_lcs_sam_1246k_1107.json).
|
193 |
+
|
194 |
+
|
195 |
+
### SFT Images & Annotations
|
196 |
+
The majority of the two SFT datasets are the same, with the exception that the 23K detailed description data in LLaVA-1.5-SFT being replaced with detailed captions randomly sampled from the [100K ShareGPT4V data](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/sharegpt4v_instruct_gpt4-vision_cap100k.json).
|
197 |
+
|
198 |
+
### Download data
|
199 |
+
|
200 |
+
1. Download relevant images
|
201 |
+
|
202 |
+
- LAION-CC-SBU-558K: [images.zip](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain/blob/main/images.zip)
|
203 |
+
- COCO: This dataset is from the [COCO2017 challenge](https://cocodataset.org/). Download: [train2017](http://images.cocodataset.org/zips/train2017.zip)
|
204 |
+
- WebData: This dataset is curated by the [ShareGPT4V project](https://github.com/InternLM/InternLM-XComposer/tree/main/projects/ShareGPT4V). Download: [images](https://drive.google.com/drive/folders/1tCUQ-sq6vdshZVkF0ZeF3K4eztkXJgax?usp=sharing). Only for academic usage.
|
205 |
+
- SAM: This dataset is collected by [Meta](https://ai.meta.com/datasets/segment-anything-downloads/). Download: [images](https://ai.meta.com/datasets/segment-anything-downloads/). We only use 000000~000050.tar for now. If you just want to use ShareGPT4V for SFT, you can quickly download 9K images from [here](https://drive.google.com/file/d/1dKumdOKSXtV7lIXdrG7jsIK_z2vZv2gs/view?usp=drive_link).
|
206 |
+
- GQA: [GQA project page](https://cs.stanford.edu/people/dorarad/gqa/about.html). Download: [images](https://downloads.cs.stanford.edu/nlp/data/gqa/images.zip)
|
207 |
+
- OCR-VQA: [OCR-VQA project page](https://ocr-vqa.github.io/). Download: [download script](https://drive.google.com/drive/folders/1_GYPY5UkUy7HIcR0zq3ZCFgeZN7BAfm_?usp=sharing). We save all files as `.jpg`
|
208 |
+
- TextVQA: [TextVQA project page](https://textvqa.org/). Download: [trainvalimages](https://dl.fbaipublicfiles.com/textvqa/images/train_val_images.zip)
|
209 |
+
- VisualGenome: [VisualGenome project page](https://homes.cs.washington.edu/~ranjay/visualgenome/index.html). Download: [part1](https://cs.stanford.edu/people/rak248/VG_100K_2/images.zip), [part2](https://cs.stanford.edu/people/rak248/VG_100K_2/images2.zip)
|
210 |
+
|
211 |
+
|
212 |
+
2. Download relevant annotations
|
213 |
+
|
214 |
+
- LLaVA's pretraining annotations: [blip_laion_cc_sbu_558k.json](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain)
|
215 |
+
- LLaVA's SFT annotations: [llava_v1_5_mix665k.json](https://huggingface.co/datasets/liuhaotian/LLaVA-Instruct-150K/blob/main/llava_v1_5_mix665k.json)
|
216 |
+
- ShareGPT4V's pretraining annotations: [share-captioner_coco_lcs_sam_1246k_1107.json](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/share-captioner_coco_lcs_sam_1246k_1107.json)
|
217 |
+
- ShareGPT4V's SFT annotations: [sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json)
|
218 |
+
|
219 |
+
|
220 |
+
### Organize Data
|
221 |
+
|
222 |
+
Organize the image files and annotation files as follows in `path/to/your/data`:
|
223 |
+
|
224 |
+
```none
|
225 |
+
data
|
226 |
+
βββ llava
|
227 |
+
β βββ llava_pretrain
|
228 |
+
β β βββ images
|
229 |
+
β β βββ blip_laion_cc_sbu_558k.json
|
230 |
+
βββ coco
|
231 |
+
β βββ train2017
|
232 |
+
βββ sam
|
233 |
+
β βββ images
|
234 |
+
βββ gqa
|
235 |
+
β βββ images
|
236 |
+
βββ ocr_vqa
|
237 |
+
β βββ images
|
238 |
+
βββ textvqa
|
239 |
+
β βββ train_images
|
240 |
+
βββ vg
|
241 |
+
β βββ VG_100K
|
242 |
+
β βββ VG_100K_2
|
243 |
+
βββ share_textvqa
|
244 |
+
β βββ images
|
245 |
+
βββ web-celebrity
|
246 |
+
β βββ images
|
247 |
+
βββ web-landmark
|
248 |
+
β βββ images
|
249 |
+
βββ wikiart
|
250 |
+
β βββ images
|
251 |
+
βββ text_files
|
252 |
+
β βββ llava_v1_5_mix665k.json
|
253 |
+
β βββ share-captioner_coco_lcs_sam_1246k_1107.json
|
254 |
+
β βββ sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json
|
255 |
+
```
|
256 |
+
|
257 |
+
## Train
|
258 |
+
|
259 |
+
**This section we describe the base recipe.**
|
260 |
+
### Hyperparameters
|
261 |
+
Both hyperparameters used in pretraining and finetuning are provided below.
|
262 |
+
|
263 |
+
1. Pretraining
|
264 |
+
|
265 |
+
| Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
|
266 |
+
|----------------| ---: | ---: | ---: |-----------:| ---: |
|
267 |
+
| TinyLLaVA-3.1B | 256 | 1e-3 | 1 | 3072 | 0 |
|
268 |
+
|
269 |
+
2. Finetuning
|
270 |
+
|
271 |
+
| Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
|
272 |
+
|----------------| ---: | ---: | ---: |-----------:| ---: |
|
273 |
+
| TinyLLaVA-3.1B | 128 | 2e-5 | 1 | 3072 | 0 |
|
274 |
+
|
275 |
+
### Pretrain
|
276 |
+
|
277 |
+
**Replace paths to your paths**
|
278 |
+
|
279 |
+
Training script with DeepSpeed ZeRO-2: [`pretrain.sh`](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/scripts/tiny_llava/pretrain.sh).
|
280 |
+
|
281 |
+
### Finetune
|
282 |
+
|
283 |
+
**Replace paths to your paths**
|
284 |
+
|
285 |
+
Training script with DeepSpeed ZeRO-3: [`finetune.sh`](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/scripts/tiny_llava/finetune.sh).
|
286 |
+
|
287 |
+
## Custom-Finetune
|
288 |
+
|
289 |
+
Check out our custom finetune using LoRA [here](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/dev/docs/CUTOM_FINETUNE.md).
|
290 |
+
|
291 |
+
|
292 |
+
## ✏ Citation
|
293 |
+
|
294 |
+
If you find our paper and code useful in your research, please consider giving a star :star: and citation :pencil:.
|
295 |
+
|
296 |
+
```BibTeX
|
297 |
+
@misc{zhou2024tinyllava,
|
298 |
+
title={TinyLLaVA: A Framework of Small-scale Large Multimodal Models},
|
299 |
+
author={Baichuan Zhou and Ying Hu and Xi Weng and Junlong Jia and Jie Luo and Xien Liu and Ji Wu and Lei Huang},
|
300 |
+
year={2024},
|
301 |
+
eprint={2402.14289},
|
302 |
+
archivePrefix={arXiv},
|
303 |
+
primaryClass={cs.LG}
|
304 |
+
}
|
305 |
+
```
|
306 |
+
|
307 |
+
|
308 |
+
## β€οΈ Community efforts
|
309 |
+
* Our codebase is built upon the [LLaVA](https://github.com/haotian-liu/LLaVA) project. Great work!
|
310 |
+
* Our project uses data from the [ShareGPT4V](https://github.com/InternLM/InternLM-XComposer/tree/main/projects/ShareGPT4V) project. Great work!
|
311 |
+
|
pyproject.toml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = ["setuptools>=61.0"]
|
3 |
+
build-backend = "setuptools.build_meta"
|
4 |
+
|
5 |
+
[project]
|
6 |
+
name = "tinyllava"
|
7 |
+
version = "1.0.0"
|
8 |
+
description = "A Framework of Small-scale Large Multimodal Models."
|
9 |
+
readme = "README.md"
|
10 |
+
requires-python = ">=3.9"
|
11 |
+
classifiers = [
|
12 |
+
"Programming Language :: Python :: 3",
|
13 |
+
"License :: OSI Approved :: Apache Software License",
|
14 |
+
]
|
15 |
+
dependencies = [
|
16 |
+
"torch==2.0.1", "torchvision==0.15.2", "tiktoken",
|
17 |
+
"transformers==4.37.2", "tokenizers==0.15.1", "sentencepiece==0.1.99", "shortuuid",
|
18 |
+
"accelerate==0.21.0", "peft==0.4.0", "bitsandbytes==0.41.0",
|
19 |
+
"pydantic<2,>=1", "markdown2[all]", "numpy", "scikit-learn==1.2.2",
|
20 |
+
"gradio==3.35.2", "gradio_client==0.2.9",
|
21 |
+
"requests", "httpx==0.23.3", "uvicorn", "fastapi",
|
22 |
+
"einops==0.6.1", "einops-exts==0.0.4", "timm==0.6.13",
|
23 |
+
]
|
24 |
+
|
25 |
+
[project.optional-dependencies]
|
26 |
+
train = ["deepspeed==0.9.5", "ninja", "wandb"]
|
27 |
+
|
28 |
+
[project.urls]
|
29 |
+
"Homepage" = "https://github.com/DLCV-BUAA/TinyLLaVABench"
|
30 |
+
"Bug Tracker" = "https://github.com/DLCV-BUAA/TinyLLaVABench/issues"
|
31 |
+
|
32 |
+
[tool.setuptools.packages.find]
|
33 |
+
exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"]
|
34 |
+
|
35 |
+
[tool.wheel]
|
36 |
+
exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"]
|
37 |
+
|