Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +210 -0
- adapter_config.json +41 -0
- added_tokens.json +24 -0
- app.py +149 -0
- chat_template.jinja +7 -0
- config.json +29 -0
- config.toml +15 -0
- inference.py +70 -0
- merges.txt +0 -0
- model_card.md +199 -0
- preprocessor_config.json +36 -0
- requirements.txt +7 -0
- space.yml +9 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +209 -0
- video_preprocessor_config.json +86 -0
- vocab.json +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,213 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- ko
|
5 |
+
- zh
|
6 |
license: apache-2.0
|
7 |
+
library_name: peft
|
8 |
+
pipeline_tag: visual-question-answering
|
9 |
+
tags:
|
10 |
+
- vision
|
11 |
+
- visual-question-answering
|
12 |
+
- multimodal
|
13 |
+
- qwen
|
14 |
+
- lora
|
15 |
+
- tcm
|
16 |
+
- traditional-chinese-medicine
|
17 |
+
- tongue-diagnosis
|
18 |
---
|
19 |
+
|
20 |
+
# ViTCM_LLM - Traditional Chinese Medicine Tongue Diagnosis Model
|
21 |
+
|
22 |
+
This is a LoRA (Low-Rank Adaptation) adapter for the Qwen2.5-VL-32B-Instruct model, fine-tuned specifically for Traditional Chinese Medicine (TCM) tongue diagnosis tasks.
|
23 |
+
|
24 |
+
## Model Details
|
25 |
+
|
26 |
+
### Model Description
|
27 |
+
|
28 |
+
- **Developed by:** Mark-CHAE
|
29 |
+
- **Model type:** LoRA Adapter for Qwen2.5-VL-32B-Instruct
|
30 |
+
- **Language(s) (NLP):** Chinese, Korean, English
|
31 |
+
- **License:** Apache-2.0
|
32 |
+
- **Finetuned from model:** Qwen/Qwen2.5-VL-32B-Instruct
|
33 |
+
- **Specialization:** Traditional Chinese Medicine Tongue Diagnosis
|
34 |
+
|
35 |
+
### Model Sources
|
36 |
+
|
37 |
+
- **Repository:** [Mark-CHAE/shezhen](https://huggingface.co/Mark-CHAE/shezhen)
|
38 |
+
- **Base Model:** [Qwen/Qwen2.5-VL-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-32B-Instruct)
|
39 |
+
|
40 |
+
## Uses
|
41 |
+
|
42 |
+
### Direct Use
|
43 |
+
|
44 |
+
This LoRA adapter can be used with the base Qwen2.5-VL-32B-Instruct model for multimodal vision-language tasks including:
|
45 |
+
|
46 |
+
- Traditional Chinese Medicine tongue diagnosis
|
47 |
+
- Tongue image analysis and interpretation
|
48 |
+
- Visual question answering for medical images
|
49 |
+
- Multimodal medical conversations
|
50 |
+
- Symptom analysis from tongue images
|
51 |
+
|
52 |
+
### Downstream Use
|
53 |
+
|
54 |
+
The adapter can be loaded with the base model for inference or further fine-tuning on specific TCM diagnosis tasks.
|
55 |
+
|
56 |
+
### Out-of-Scope Use
|
57 |
+
|
58 |
+
This model should not be used for:
|
59 |
+
|
60 |
+
- Generating harmful, offensive, or inappropriate content
|
61 |
+
- Creating deepfakes or misleading visual content
|
62 |
+
- Any illegal activities
|
63 |
+
- Making actual medical diagnoses without proper medical supervision
|
64 |
+
|
65 |
+
### Recommendations
|
66 |
+
|
67 |
+
Users should:
|
68 |
+
|
69 |
+
- Verify outputs for accuracy and appropriateness
|
70 |
+
- Be aware of potential biases in the model
|
71 |
+
- Use appropriate safety measures when deploying
|
72 |
+
- Not rely solely on this model for medical diagnosis
|
73 |
+
- Consult qualified medical professionals for actual diagnosis
|
74 |
+
|
75 |
+
## How to Get Started with the Model
|
76 |
+
|
77 |
+
### Using the Inference Widget
|
78 |
+
|
79 |
+
You can try the model directly in the browser using the Visual Question Answering widget above. Simply upload a tongue image and ask a question about it.
|
80 |
+
|
81 |
+
### Using the Model in Code
|
82 |
+
|
83 |
+
```python
|
84 |
+
from peft import PeftModel
|
85 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoProcessor
|
86 |
+
import torch
|
87 |
+
from PIL import Image
|
88 |
+
|
89 |
+
# Load base model and tokenizer
|
90 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
91 |
+
"Qwen/Qwen2.5-VL-32B-Instruct",
|
92 |
+
torch_dtype=torch.float16,
|
93 |
+
device_map="auto"
|
94 |
+
)
|
95 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
96 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
97 |
+
|
98 |
+
# Load LoRA adapter
|
99 |
+
model = PeftModel.from_pretrained(base_model, "Mark-CHAE/shezhen")
|
100 |
+
|
101 |
+
# Prepare inputs
|
102 |
+
image = Image.open("tongue_image.jpg")
|
103 |
+
question = "根据图片判断舌诊内容"
|
104 |
+
|
105 |
+
prompt = f"<|im_start|>user\n<image>\n{question}<|im_end|>\n<|im_start|>assistant\n"
|
106 |
+
|
107 |
+
inputs = processor(
|
108 |
+
text=prompt,
|
109 |
+
images=image,
|
110 |
+
return_tensors="pt"
|
111 |
+
)
|
112 |
+
|
113 |
+
# Generate response
|
114 |
+
with torch.no_grad():
|
115 |
+
outputs = model.generate(
|
116 |
+
**inputs,
|
117 |
+
max_length=512,
|
118 |
+
temperature=0.7,
|
119 |
+
top_p=0.9,
|
120 |
+
do_sample=True,
|
121 |
+
pad_token_id=tokenizer.eos_token_id
|
122 |
+
)
|
123 |
+
|
124 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
125 |
+
answer = response.split("<|im_start|>assistant")[-1].strip()
|
126 |
+
print(answer)
|
127 |
+
```
|
128 |
+
|
129 |
+
## Training Details
|
130 |
+
|
131 |
+
### Training Data
|
132 |
+
|
133 |
+
The model was fine-tuned on multimodal vision-language data including Chinese, Korean, and English content, with specific focus on Traditional Chinese Medicine tongue diagnosis scenarios.
|
134 |
+
|
135 |
+
### Training Procedure
|
136 |
+
|
137 |
+
#### Training Hyperparameters
|
138 |
+
|
139 |
+
- **Training regime:** LoRA fine-tuning
|
140 |
+
- **LoRA rank:** 64
|
141 |
+
- **LoRA alpha:** 128
|
142 |
+
- **Target modules:** v_proj, qkv, attn.proj, q_proj, gate_proj, down_proj, up_proj, o_proj, k_proj
|
143 |
+
- **Training steps:** 2700
|
144 |
+
- **Epochs:** ~8.9
|
145 |
+
|
146 |
+
#### Speeds, Sizes, Times
|
147 |
+
|
148 |
+
- **Adapter size:** 2.2GB
|
149 |
+
- **Base model:** Qwen2.5-VL-32B-Instruct (32B parameters)
|
150 |
+
|
151 |
+
## Evaluation
|
152 |
+
|
153 |
+
### Testing Data, Factors & Metrics
|
154 |
+
|
155 |
+
#### Testing Data
|
156 |
+
|
157 |
+
Evaluation was performed on multimodal vision-language benchmarks with focus on medical image understanding and TCM tongue diagnosis.
|
158 |
+
|
159 |
+
#### Metrics
|
160 |
+
|
161 |
+
Standard vision-language evaluation metrics including accuracy, BLEU, and human evaluation scores.
|
162 |
+
|
163 |
+
### Results
|
164 |
+
|
165 |
+
[Evaluation results to be added]
|
166 |
+
|
167 |
+
#### Summary
|
168 |
+
|
169 |
+
This LoRA adapter provides an efficient way to adapt the Qwen2.5-VL-32B-Instruct model for Traditional Chinese Medicine tongue diagnosis tasks while maintaining the base model's capabilities.
|
170 |
+
|
171 |
+
## Technical Specifications
|
172 |
+
|
173 |
+
### Model Architecture and Objective
|
174 |
+
|
175 |
+
- **Architecture:** LoRA adapter for Qwen2.5-VL-32B-Instruct
|
176 |
+
- **Objective:** Multimodal vision-language understanding and generation, specialized for TCM tongue diagnosis
|
177 |
+
|
178 |
+
### Compute Infrastructure
|
179 |
+
|
180 |
+
#### Hardware
|
181 |
+
|
182 |
+
[To be specified]
|
183 |
+
|
184 |
+
#### Software
|
185 |
+
|
186 |
+
- PEFT 0.15.2
|
187 |
+
- Transformers library
|
188 |
+
- PyTorch
|
189 |
+
|
190 |
+
## Citation
|
191 |
+
|
192 |
+
**BibTeX:**
|
193 |
+
|
194 |
+
```bibtex
|
195 |
+
@misc{vitcm-llm,
|
196 |
+
author = {Mark-CHAE},
|
197 |
+
title = {ViTCM_LLM: Traditional Chinese Medicine Tongue Diagnosis Model},
|
198 |
+
year = {2024},
|
199 |
+
url = {https://huggingface.co/Mark-CHAE/shezhen}
|
200 |
+
}
|
201 |
+
```
|
202 |
+
|
203 |
+
**APA:**
|
204 |
+
|
205 |
+
Mark-CHAE. (2024). ViTCM_LLM: Traditional Chinese Medicine Tongue Diagnosis Model. Hugging Face. https://huggingface.co/Mark-CHAE/shezhen
|
206 |
+
|
207 |
+
## Model Card Contact
|
208 |
+
|
209 |
+
For questions about this model, please contact the model author.
|
210 |
+
|
211 |
+
### Framework versions
|
212 |
+
|
213 |
+
- PEFT 0.15.2
|
adapter_config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "Qwen/Qwen2.5-VL-32B-Instruct",
|
5 |
+
"bias": "none",
|
6 |
+
"corda_config": null,
|
7 |
+
"eva_config": null,
|
8 |
+
"exclude_modules": null,
|
9 |
+
"fan_in_fan_out": false,
|
10 |
+
"inference_mode": true,
|
11 |
+
"init_lora_weights": true,
|
12 |
+
"layer_replication": null,
|
13 |
+
"layers_pattern": null,
|
14 |
+
"layers_to_transform": null,
|
15 |
+
"loftq_config": {},
|
16 |
+
"lora_alpha": 128,
|
17 |
+
"lora_bias": false,
|
18 |
+
"lora_dropout": 0,
|
19 |
+
"megatron_config": null,
|
20 |
+
"megatron_core": "megatron.core",
|
21 |
+
"modules_to_save": null,
|
22 |
+
"peft_type": "LORA",
|
23 |
+
"r": 64,
|
24 |
+
"rank_pattern": {},
|
25 |
+
"revision": null,
|
26 |
+
"target_modules": [
|
27 |
+
"v_proj",
|
28 |
+
"qkv",
|
29 |
+
"attn.proj",
|
30 |
+
"q_proj",
|
31 |
+
"gate_proj",
|
32 |
+
"down_proj",
|
33 |
+
"up_proj",
|
34 |
+
"o_proj",
|
35 |
+
"k_proj"
|
36 |
+
],
|
37 |
+
"task_type": "CAUSAL_LM",
|
38 |
+
"trainable_token_indices": null,
|
39 |
+
"use_dora": false,
|
40 |
+
"use_rslora": false
|
41 |
+
}
|
added_tokens.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"</tool_call>": 151658,
|
3 |
+
"<tool_call>": 151657,
|
4 |
+
"<|box_end|>": 151649,
|
5 |
+
"<|box_start|>": 151648,
|
6 |
+
"<|endoftext|>": 151643,
|
7 |
+
"<|file_sep|>": 151664,
|
8 |
+
"<|fim_middle|>": 151660,
|
9 |
+
"<|fim_pad|>": 151662,
|
10 |
+
"<|fim_prefix|>": 151659,
|
11 |
+
"<|fim_suffix|>": 151661,
|
12 |
+
"<|im_end|>": 151645,
|
13 |
+
"<|im_start|>": 151644,
|
14 |
+
"<|image_pad|>": 151655,
|
15 |
+
"<|object_ref_end|>": 151647,
|
16 |
+
"<|object_ref_start|>": 151646,
|
17 |
+
"<|quad_end|>": 151651,
|
18 |
+
"<|quad_start|>": 151650,
|
19 |
+
"<|repo_name|>": 151663,
|
20 |
+
"<|video_pad|>": 151656,
|
21 |
+
"<|vision_end|>": 151653,
|
22 |
+
"<|vision_pad|>": 151654,
|
23 |
+
"<|vision_start|>": 151652
|
24 |
+
}
|
app.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoProcessor
|
4 |
+
from peft import PeftModel
|
5 |
+
from PIL import Image
|
6 |
+
import io
|
7 |
+
|
8 |
+
# Page configuration
|
9 |
+
st.set_page_config(
|
10 |
+
page_title="ViTCM_LLM Tongue Diagnosis",
|
11 |
+
page_icon="🖼️",
|
12 |
+
layout="wide"
|
13 |
+
)
|
14 |
+
|
15 |
+
# Title
|
16 |
+
st.title("🖼️ ViTCM_LLM Tongue Diagnosis")
|
17 |
+
st.markdown("**ViTCM_LLM - Traditional Chinese Medicine Tongue Diagnosis Model**")
|
18 |
+
|
19 |
+
# Model loading
|
20 |
+
@st.cache_resource
|
21 |
+
def load_model():
|
22 |
+
"""Load the ViTCM_LLM model for TCM tongue diagnosis."""
|
23 |
+
try:
|
24 |
+
# Tokenizer and processor
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
26 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
27 |
+
|
28 |
+
# Base model
|
29 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
30 |
+
"Qwen/Qwen2.5-VL-32B-Instruct",
|
31 |
+
torch_dtype=torch.float16,
|
32 |
+
device_map="auto"
|
33 |
+
)
|
34 |
+
|
35 |
+
# LoRA adapter
|
36 |
+
model = PeftModel.from_pretrained(base_model, "Mark-CHAE/shezhen")
|
37 |
+
|
38 |
+
return model, tokenizer, processor
|
39 |
+
except Exception as e:
|
40 |
+
st.error(f"Model loading failed: {e}")
|
41 |
+
return None, None, None
|
42 |
+
|
43 |
+
# Sidebar
|
44 |
+
with st.sidebar:
|
45 |
+
st.header("⚙️ Settings")
|
46 |
+
|
47 |
+
# Inference parameters
|
48 |
+
max_length = st.slider("Max tokens", 100, 1024, 512)
|
49 |
+
temperature = st.slider("Temperature", 0.1, 2.0, 0.7, 0.1)
|
50 |
+
top_p = st.slider("Top-p", 0.1, 1.0, 0.9, 0.05)
|
51 |
+
|
52 |
+
# Model load button
|
53 |
+
if st.button("🚀 Load Model", type="primary"):
|
54 |
+
with st.spinner("Loading ViTCM_LLM model..."):
|
55 |
+
model, tokenizer, processor = load_model()
|
56 |
+
if model is not None:
|
57 |
+
st.session_state.model = model
|
58 |
+
st.session_state.tokenizer = tokenizer
|
59 |
+
st.session_state.processor = processor
|
60 |
+
st.session_state.model_loaded = True
|
61 |
+
st.success("✅ ViTCM_LLM model loaded successfully!")
|
62 |
+
|
63 |
+
# Main content
|
64 |
+
if not st.session_state.get('model_loaded', False):
|
65 |
+
st.info("👈 Click 'Load Model' button in the sidebar to start tongue diagnosis.")
|
66 |
+
st.stop()
|
67 |
+
|
68 |
+
# Image upload
|
69 |
+
st.header("📸 Tongue Image Upload")
|
70 |
+
uploaded_file = st.file_uploader(
|
71 |
+
"Upload a tongue image for TCM diagnosis",
|
72 |
+
type=['png', 'jpg', 'jpeg']
|
73 |
+
)
|
74 |
+
|
75 |
+
if uploaded_file is not None:
|
76 |
+
# Display image
|
77 |
+
image = Image.open(uploaded_file)
|
78 |
+
st.image(image, caption="Uploaded tongue image", use_column_width=True)
|
79 |
+
|
80 |
+
# Question input
|
81 |
+
st.header("❓ Tongue Diagnosis Question")
|
82 |
+
question = st.text_area(
|
83 |
+
"Ask a question about the tongue image for TCM diagnosis",
|
84 |
+
placeholder="e.g., 根据图片判断舌诊内容",
|
85 |
+
height=100
|
86 |
+
)
|
87 |
+
|
88 |
+
# Analyze button
|
89 |
+
if st.button("🔍 Analyze Tongue", type="primary") and question.strip():
|
90 |
+
with st.spinner("Analyzing tongue for TCM diagnosis..."):
|
91 |
+
try:
|
92 |
+
# Construct prompt
|
93 |
+
prompt = f"<|im_start|>user\n<image>\n{question}<|im_end|>\n<|im_start|>assistant\n"
|
94 |
+
|
95 |
+
# Process inputs
|
96 |
+
inputs = st.session_state.processor(
|
97 |
+
text=prompt,
|
98 |
+
images=image,
|
99 |
+
return_tensors="pt"
|
100 |
+
)
|
101 |
+
|
102 |
+
# Inference
|
103 |
+
with torch.no_grad():
|
104 |
+
outputs = st.session_state.model.generate(
|
105 |
+
**inputs,
|
106 |
+
max_length=max_length,
|
107 |
+
temperature=temperature,
|
108 |
+
top_p=top_p,
|
109 |
+
do_sample=True,
|
110 |
+
pad_token_id=st.session_state.tokenizer.eos_token_id
|
111 |
+
)
|
112 |
+
|
113 |
+
# Process results
|
114 |
+
response = st.session_state.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
115 |
+
answer = response.split("<|im_start|>assistant")[-1].strip()
|
116 |
+
|
117 |
+
# Display results
|
118 |
+
st.header("💡 TCM Tongue Diagnosis")
|
119 |
+
st.markdown(f"**Question:** {question}")
|
120 |
+
st.markdown(f"**Diagnosis:** {answer}")
|
121 |
+
|
122 |
+
except Exception as e:
|
123 |
+
st.error(f"Error occurred during tongue analysis: {e}")
|
124 |
+
|
125 |
+
# Usage examples
|
126 |
+
with st.expander("📚 Tongue Diagnosis Examples"):
|
127 |
+
st.markdown("""
|
128 |
+
### Tongue Diagnosis Questions:
|
129 |
+
- 根据图片判断舌诊内容
|
130 |
+
- 分析舌头的颜色和形状
|
131 |
+
- 判断舌苔的厚薄和颜色
|
132 |
+
- 分析舌头的裂纹和斑点
|
133 |
+
- 评估舌头的整体健康状况
|
134 |
+
""")
|
135 |
+
|
136 |
+
# Model information
|
137 |
+
with st.expander("ℹ️ Model Information"):
|
138 |
+
st.markdown("""
|
139 |
+
### ViTCM_LLM - Traditional Chinese Medicine Tongue Diagnosis Model
|
140 |
+
|
141 |
+
- **Base Model**: Qwen/Qwen2.5-VL-32B-Instruct
|
142 |
+
- **Adapter**: Mark-CHAE/shezhen (ViTCM_LLM)
|
143 |
+
- **Language**: Chinese
|
144 |
+
- **License**: Apache-2.0
|
145 |
+
- **Specialization**: Traditional Chinese Medicine Tongue Diagnosis
|
146 |
+
""")
|
147 |
+
|
148 |
+
st.markdown("---")
|
149 |
+
st.markdown("**ViTCM_LLM Tongue Diagnosis** | Powered by Qwen2.5-VL-32B-Instruct")
|
chat_template.jinja
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system
|
2 |
+
You are a helpful assistant.<|im_end|>
|
3 |
+
{% endif %}<|im_start|>{{ message['role'] }}
|
4 |
+
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
5 |
+
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
6 |
+
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
7 |
+
{% endif %}
|
config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"task": "visual-question-answering",
|
3 |
+
"model": {
|
4 |
+
"framework": "pytorch",
|
5 |
+
"type": "causal-lm"
|
6 |
+
},
|
7 |
+
"inference": {
|
8 |
+
"max_length": 512,
|
9 |
+
"temperature": 0.7,
|
10 |
+
"top_p": 0.9
|
11 |
+
},
|
12 |
+
"inputs": {
|
13 |
+
"question": {
|
14 |
+
"type": "string",
|
15 |
+
"description": "The question about the tongue image for TCM diagnosis (e.g., '根据图片判断舌诊内容')"
|
16 |
+
},
|
17 |
+
"image": {
|
18 |
+
"type": "string",
|
19 |
+
"description": "Base64 encoded tongue image"
|
20 |
+
}
|
21 |
+
},
|
22 |
+
"outputs": {
|
23 |
+
"answer": {
|
24 |
+
"type": "string",
|
25 |
+
"description": "The TCM tongue diagnosis analysis"
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"description": "ViTCM_LLM - Traditional Chinese Medicine Tongue Diagnosis Model"
|
29 |
+
}
|
config.toml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
primaryColor = "#FF6B6B"
|
3 |
+
backgroundColor = "#FFFFFF"
|
4 |
+
secondaryBackgroundColor = "#F0F2F6"
|
5 |
+
textColor = "#262730"
|
6 |
+
font = "sans serif"
|
7 |
+
|
8 |
+
[server]
|
9 |
+
headless = true
|
10 |
+
port = 8501
|
11 |
+
enableCORS = false
|
12 |
+
enableXsrfProtection = false
|
13 |
+
|
14 |
+
[browser]
|
15 |
+
gatherUsageStats = false
|
inference.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoProcessor
|
3 |
+
from peft import PeftModel
|
4 |
+
from PIL import Image
|
5 |
+
import base64
|
6 |
+
import io
|
7 |
+
|
8 |
+
# Load model and tokenizer
|
9 |
+
@torch.no_grad()
|
10 |
+
def load_model():
|
11 |
+
"""Load the ViTCM_LLM model for Traditional Chinese Medicine Tongue diagnosis."""
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
13 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
14 |
+
|
15 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
16 |
+
"Qwen/Qwen2.5-VL-32B-Instruct",
|
17 |
+
torch_dtype=torch.float16,
|
18 |
+
device_map="auto"
|
19 |
+
)
|
20 |
+
|
21 |
+
model = PeftModel.from_pretrained(base_model, "Mark-CHAE/shezhen")
|
22 |
+
return model, tokenizer, processor
|
23 |
+
|
24 |
+
# Initialize model
|
25 |
+
model, tokenizer, processor = load_model()
|
26 |
+
|
27 |
+
def query(question: str, image: str) -> str:
|
28 |
+
"""
|
29 |
+
Analyze tongue image for Traditional Chinese Medicine diagnosis.
|
30 |
+
|
31 |
+
Args:
|
32 |
+
question: The question about the tongue image (e.g., "根据图片判断舌诊内容")
|
33 |
+
image: Base64 encoded image string
|
34 |
+
|
35 |
+
Returns:
|
36 |
+
The TCM diagnosis analysis of the tongue
|
37 |
+
"""
|
38 |
+
try:
|
39 |
+
# Decode base64 image
|
40 |
+
image_data = base64.b64decode(image)
|
41 |
+
image_pil = Image.open(io.BytesIO(image_data))
|
42 |
+
|
43 |
+
# Construct prompt for TCM tongue diagnosis
|
44 |
+
prompt = f"<|im_start|>user\n<image>\n{question}<|im_end|>\n<|im_start|>assistant\n"
|
45 |
+
|
46 |
+
# Process inputs
|
47 |
+
inputs = processor(
|
48 |
+
text=prompt,
|
49 |
+
images=image_pil,
|
50 |
+
return_tensors="pt"
|
51 |
+
)
|
52 |
+
|
53 |
+
# Generate response
|
54 |
+
outputs = model.generate(
|
55 |
+
**inputs,
|
56 |
+
max_length=512,
|
57 |
+
temperature=0.7,
|
58 |
+
top_p=0.9,
|
59 |
+
do_sample=True,
|
60 |
+
pad_token_id=tokenizer.eos_token_id
|
61 |
+
)
|
62 |
+
|
63 |
+
# Decode response
|
64 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
65 |
+
answer = response.split("<|im_start|>assistant")[-1].strip()
|
66 |
+
|
67 |
+
return answer
|
68 |
+
|
69 |
+
except Exception as e:
|
70 |
+
return f"Error processing request: {str(e)}"
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model_card.md
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- ko
|
5 |
+
license: apache-2.0
|
6 |
+
library_name: peft
|
7 |
+
pipeline_tag: visual-question-answering
|
8 |
+
tags:
|
9 |
+
- vision
|
10 |
+
- visual-question-answering
|
11 |
+
- multimodal
|
12 |
+
- qwen
|
13 |
+
- lora
|
14 |
+
- tcm
|
15 |
+
- traditional-chinese-medicine
|
16 |
+
---
|
17 |
+
|
18 |
+
# ViTCM_LLM - Traditional Chinese Medicine Diagnosis Model
|
19 |
+
|
20 |
+
This is a LoRA (Low-Rank Adaptation) adapter for the Qwen2.5-VL-32B-Instruct model, fine-tuned specifically for Traditional Chinese Medicine (TCM) diagnosis tasks.
|
21 |
+
|
22 |
+
## Model Details
|
23 |
+
|
24 |
+
### Model Description
|
25 |
+
|
26 |
+
- **Developed by:** Mark-CHAE
|
27 |
+
- **Model type:** LoRA Adapter for Qwen2.5-VL-32B-Instruct
|
28 |
+
- **Language(s) (NLP):** English, Korean
|
29 |
+
- **License:** Apache-2.0
|
30 |
+
- **Finetuned from model:** Qwen/Qwen2.5-VL-32B-Instruct
|
31 |
+
- **Specialization:** Traditional Chinese Medicine Diagnosis
|
32 |
+
|
33 |
+
### Model Sources
|
34 |
+
|
35 |
+
- **Repository:** [Mark-CHAE/shezhen](https://huggingface.co/Mark-CHAE/shezhen)
|
36 |
+
- **Base Model:** [Qwen/Qwen2.5-VL-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-32B-Instruct)
|
37 |
+
|
38 |
+
## Uses
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
This LoRA adapter can be used with the base Qwen2.5-VL-32B-Instruct model for multimodal vision-language tasks including:
|
43 |
+
|
44 |
+
- Image understanding and description
|
45 |
+
- Visual question answering
|
46 |
+
- Image-text generation
|
47 |
+
- Multimodal conversations
|
48 |
+
- Traditional Chinese Medicine diagnosis
|
49 |
+
- Symptom analysis from medical images
|
50 |
+
|
51 |
+
### Downstream Use
|
52 |
+
|
53 |
+
The adapter can be loaded with the base model for inference or further fine-tuning on specific TCM diagnosis tasks.
|
54 |
+
|
55 |
+
### Out-of-Scope Use
|
56 |
+
|
57 |
+
This model should not be used for:
|
58 |
+
|
59 |
+
- Generating harmful, offensive, or inappropriate content
|
60 |
+
- Creating deepfakes or misleading visual content
|
61 |
+
- Any illegal activities
|
62 |
+
- Making actual medical diagnoses without proper medical supervision
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
Users should:
|
67 |
+
|
68 |
+
- Verify outputs for accuracy and appropriateness
|
69 |
+
- Be aware of potential biases in the model
|
70 |
+
- Use appropriate safety measures when deploying
|
71 |
+
- Not rely solely on this model for medical diagnosis
|
72 |
+
- Consult qualified medical professionals for actual diagnosis
|
73 |
+
|
74 |
+
## How to Get Started with the Model
|
75 |
+
|
76 |
+
### Using the Inference Widget
|
77 |
+
|
78 |
+
You can try the model directly in the browser using the Visual Question Answering widget above. Simply upload an image and ask a question about it.
|
79 |
+
|
80 |
+
### Using the Model in Code
|
81 |
+
|
82 |
+
```python
|
83 |
+
from peft import PeftModel
|
84 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoProcessor
|
85 |
+
import torch
|
86 |
+
from PIL import Image
|
87 |
+
|
88 |
+
# Load base model and tokenizer
|
89 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
90 |
+
"Qwen/Qwen2.5-VL-32B-Instruct",
|
91 |
+
torch_dtype=torch.float16,
|
92 |
+
device_map="auto"
|
93 |
+
)
|
94 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
95 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
|
96 |
+
|
97 |
+
# Load LoRA adapter
|
98 |
+
model = PeftModel.from_pretrained(base_model, "Mark-CHAE/shezhen")
|
99 |
+
|
100 |
+
# Prepare inputs
|
101 |
+
image = Image.open("your_image.jpg")
|
102 |
+
question = "根据图片判断舌诊内容"
|
103 |
+
|
104 |
+
prompt = f"<|im_start|>user\n<image>\n{question}<|im_end|>\n<|im_start|>assistant\n"
|
105 |
+
|
106 |
+
inputs = processor(
|
107 |
+
text=prompt,
|
108 |
+
images=image,
|
109 |
+
return_tensors="pt"
|
110 |
+
)
|
111 |
+
|
112 |
+
# Generate response
|
113 |
+
with torch.no_grad():
|
114 |
+
outputs = model.generate(
|
115 |
+
**inputs,
|
116 |
+
max_length=512,
|
117 |
+
temperature=0.7,
|
118 |
+
top_p=0.9,
|
119 |
+
do_sample=True,
|
120 |
+
pad_token_id=tokenizer.eos_token_id
|
121 |
+
)
|
122 |
+
|
123 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
124 |
+
answer = response.split("<|im_start|>assistant")[-1].strip()
|
125 |
+
print(answer)
|
126 |
+
```
|
127 |
+
|
128 |
+
## Training Details
|
129 |
+
|
130 |
+
### Training Data
|
131 |
+
|
132 |
+
The model was fine-tuned on multimodal vision-language data including English and Korean content, with specific focus on Traditional Chinese Medicine diagnosis scenarios.
|
133 |
+
|
134 |
+
### Training Procedure
|
135 |
+
|
136 |
+
#### Training Hyperparameters
|
137 |
+
|
138 |
+
- **Training regime:** LoRA fine-tuning
|
139 |
+
- **LoRA rank:** 64
|
140 |
+
- **LoRA alpha:** 128
|
141 |
+
- **Target modules:** v_proj, qkv, attn.proj, q_proj, gate_proj, down_proj, up_proj, o_proj, k_proj
|
142 |
+
|
143 |
+
#### Speeds, Sizes, Times
|
144 |
+
|
145 |
+
- **Adapter size:** 2.2GB
|
146 |
+
- **Base model:** Qwen2.5-VL-32B-Instruct (32B parameters)
|
147 |
+
|
148 |
+
## Evaluation
|
149 |
+
|
150 |
+
### Testing Data, Factors & Metrics
|
151 |
+
|
152 |
+
#### Testing Data
|
153 |
+
|
154 |
+
Evaluation was performed on multimodal vision-language benchmarks with focus on medical image understanding.
|
155 |
+
|
156 |
+
#### Metrics
|
157 |
+
|
158 |
+
Standard vision-language evaluation metrics including accuracy, BLEU, and human evaluation scores.
|
159 |
+
|
160 |
+
### Results
|
161 |
+
|
162 |
+
[Evaluation results to be added]
|
163 |
+
|
164 |
+
#### Summary
|
165 |
+
|
166 |
+
This LoRA adapter provides an efficient way to adapt the Qwen2.5-VL-32B-Instruct model for Traditional Chinese Medicine diagnosis tasks while maintaining the base model's capabilities.
|
167 |
+
|
168 |
+
|
169 |
+
## Technical Specifications
|
170 |
+
|
171 |
+
### Model Architecture and Objective
|
172 |
+
|
173 |
+
- **Architecture:** LoRA adapter for Qwen2.5-VL-32B-Instruct
|
174 |
+
- **Objective:** Multimodal vision-language understanding and generation, specialized for TCM Tongue diagnosis
|
175 |
+
|
176 |
+
### Compute Infrastructure
|
177 |
+
|
178 |
+
#### Hardware
|
179 |
+
|
180 |
+
[To be specified]
|
181 |
+
|
182 |
+
#### Software
|
183 |
+
|
184 |
+
- PEFT 0.15.2
|
185 |
+
- Transformers library
|
186 |
+
- PyTorch
|
187 |
+
|
188 |
+
|
189 |
+
**APA:**
|
190 |
+
|
191 |
+
Mark-CHAE. (2024). ViTCM_LLM: Traditional Chinese Medicine Diagnosis Model. Hugging Face. https://huggingface.co/Mark-CHAE/shezhen
|
192 |
+
|
193 |
+
## Model Card Contact
|
194 |
+
|
195 |
+
For questions about this model, please contact the model author.
|
196 |
+
|
197 |
+
### Framework versions
|
198 |
+
|
199 |
+
- PEFT 0.15.2
|
preprocessor_config.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"crop_size": null,
|
3 |
+
"data_format": "channels_first",
|
4 |
+
"default_to_square": true,
|
5 |
+
"device": null,
|
6 |
+
"do_center_crop": null,
|
7 |
+
"do_convert_rgb": true,
|
8 |
+
"do_normalize": true,
|
9 |
+
"do_rescale": true,
|
10 |
+
"do_resize": true,
|
11 |
+
"image_mean": [
|
12 |
+
0.48145466,
|
13 |
+
0.4578275,
|
14 |
+
0.40821073
|
15 |
+
],
|
16 |
+
"image_processor_type": "Qwen2VLImageProcessorFast",
|
17 |
+
"image_std": [
|
18 |
+
0.26862954,
|
19 |
+
0.26130258,
|
20 |
+
0.27577711
|
21 |
+
],
|
22 |
+
"input_data_format": null,
|
23 |
+
"max_pixels": 12845056,
|
24 |
+
"merge_size": 2,
|
25 |
+
"min_pixels": 3136,
|
26 |
+
"patch_size": 14,
|
27 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
28 |
+
"resample": 3,
|
29 |
+
"rescale_factor": 0.00392156862745098,
|
30 |
+
"return_tensors": null,
|
31 |
+
"size": {
|
32 |
+
"longest_edge": 12845056,
|
33 |
+
"shortest_edge": 3136
|
34 |
+
},
|
35 |
+
"temporal_patch_size": 2
|
36 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit>=1.28.0
|
2 |
+
torch>=2.0.0
|
3 |
+
transformers>=4.35.0
|
4 |
+
peft>=0.7.0
|
5 |
+
Pillow>=9.0.0
|
6 |
+
accelerate>=0.20.0
|
7 |
+
safetensors>=0.3.0
|
space.yml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
title: ViTCM_LLM Tongue Diagnosis
|
2 |
+
emoji: 🖼️
|
3 |
+
colorFrom: blue
|
4 |
+
colorTo: purple
|
5 |
+
sdk: streamlit
|
6 |
+
sdk_version: 1.28.0
|
7 |
+
app_file: app.py
|
8 |
+
pinned: false
|
9 |
+
license: apache-2.0
|
special_tokens_map.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|im_start|>",
|
4 |
+
"<|im_end|>",
|
5 |
+
"<|object_ref_start|>",
|
6 |
+
"<|object_ref_end|>",
|
7 |
+
"<|box_start|>",
|
8 |
+
"<|box_end|>",
|
9 |
+
"<|quad_start|>",
|
10 |
+
"<|quad_end|>",
|
11 |
+
"<|vision_start|>",
|
12 |
+
"<|vision_end|>",
|
13 |
+
"<|vision_pad|>",
|
14 |
+
"<|image_pad|>",
|
15 |
+
"<|video_pad|>"
|
16 |
+
],
|
17 |
+
"eos_token": {
|
18 |
+
"content": "<|im_end|>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": false,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
},
|
24 |
+
"pad_token": {
|
25 |
+
"content": "<|endoftext|>",
|
26 |
+
"lstrip": false,
|
27 |
+
"normalized": false,
|
28 |
+
"rstrip": false,
|
29 |
+
"single_word": false
|
30 |
+
}
|
31 |
+
}
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:826c64105c507ac95e21ca8febaa9296b699bbd97820f7589c6148d912639205
|
3 |
+
size 11422100
|
tokenizer_config.json
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"151643": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"151644": {
|
14 |
+
"content": "<|im_start|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"151645": {
|
22 |
+
"content": "<|im_end|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
},
|
29 |
+
"151646": {
|
30 |
+
"content": "<|object_ref_start|>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": true
|
36 |
+
},
|
37 |
+
"151647": {
|
38 |
+
"content": "<|object_ref_end|>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false,
|
43 |
+
"special": true
|
44 |
+
},
|
45 |
+
"151648": {
|
46 |
+
"content": "<|box_start|>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": false,
|
50 |
+
"single_word": false,
|
51 |
+
"special": true
|
52 |
+
},
|
53 |
+
"151649": {
|
54 |
+
"content": "<|box_end|>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": false,
|
58 |
+
"single_word": false,
|
59 |
+
"special": true
|
60 |
+
},
|
61 |
+
"151650": {
|
62 |
+
"content": "<|quad_start|>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": false,
|
66 |
+
"single_word": false,
|
67 |
+
"special": true
|
68 |
+
},
|
69 |
+
"151651": {
|
70 |
+
"content": "<|quad_end|>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": false,
|
74 |
+
"single_word": false,
|
75 |
+
"special": true
|
76 |
+
},
|
77 |
+
"151652": {
|
78 |
+
"content": "<|vision_start|>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": false,
|
82 |
+
"single_word": false,
|
83 |
+
"special": true
|
84 |
+
},
|
85 |
+
"151653": {
|
86 |
+
"content": "<|vision_end|>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": false,
|
90 |
+
"single_word": false,
|
91 |
+
"special": true
|
92 |
+
},
|
93 |
+
"151654": {
|
94 |
+
"content": "<|vision_pad|>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": false,
|
98 |
+
"single_word": false,
|
99 |
+
"special": true
|
100 |
+
},
|
101 |
+
"151655": {
|
102 |
+
"content": "<|image_pad|>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": false,
|
106 |
+
"single_word": false,
|
107 |
+
"special": true
|
108 |
+
},
|
109 |
+
"151656": {
|
110 |
+
"content": "<|video_pad|>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": false,
|
114 |
+
"single_word": false,
|
115 |
+
"special": true
|
116 |
+
},
|
117 |
+
"151657": {
|
118 |
+
"content": "<tool_call>",
|
119 |
+
"lstrip": false,
|
120 |
+
"normalized": false,
|
121 |
+
"rstrip": false,
|
122 |
+
"single_word": false,
|
123 |
+
"special": false
|
124 |
+
},
|
125 |
+
"151658": {
|
126 |
+
"content": "</tool_call>",
|
127 |
+
"lstrip": false,
|
128 |
+
"normalized": false,
|
129 |
+
"rstrip": false,
|
130 |
+
"single_word": false,
|
131 |
+
"special": false
|
132 |
+
},
|
133 |
+
"151659": {
|
134 |
+
"content": "<|fim_prefix|>",
|
135 |
+
"lstrip": false,
|
136 |
+
"normalized": false,
|
137 |
+
"rstrip": false,
|
138 |
+
"single_word": false,
|
139 |
+
"special": false
|
140 |
+
},
|
141 |
+
"151660": {
|
142 |
+
"content": "<|fim_middle|>",
|
143 |
+
"lstrip": false,
|
144 |
+
"normalized": false,
|
145 |
+
"rstrip": false,
|
146 |
+
"single_word": false,
|
147 |
+
"special": false
|
148 |
+
},
|
149 |
+
"151661": {
|
150 |
+
"content": "<|fim_suffix|>",
|
151 |
+
"lstrip": false,
|
152 |
+
"normalized": false,
|
153 |
+
"rstrip": false,
|
154 |
+
"single_word": false,
|
155 |
+
"special": false
|
156 |
+
},
|
157 |
+
"151662": {
|
158 |
+
"content": "<|fim_pad|>",
|
159 |
+
"lstrip": false,
|
160 |
+
"normalized": false,
|
161 |
+
"rstrip": false,
|
162 |
+
"single_word": false,
|
163 |
+
"special": false
|
164 |
+
},
|
165 |
+
"151663": {
|
166 |
+
"content": "<|repo_name|>",
|
167 |
+
"lstrip": false,
|
168 |
+
"normalized": false,
|
169 |
+
"rstrip": false,
|
170 |
+
"single_word": false,
|
171 |
+
"special": false
|
172 |
+
},
|
173 |
+
"151664": {
|
174 |
+
"content": "<|file_sep|>",
|
175 |
+
"lstrip": false,
|
176 |
+
"normalized": false,
|
177 |
+
"rstrip": false,
|
178 |
+
"single_word": false,
|
179 |
+
"special": false
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"additional_special_tokens": [
|
183 |
+
"<|im_start|>",
|
184 |
+
"<|im_end|>",
|
185 |
+
"<|object_ref_start|>",
|
186 |
+
"<|object_ref_end|>",
|
187 |
+
"<|box_start|>",
|
188 |
+
"<|box_end|>",
|
189 |
+
"<|quad_start|>",
|
190 |
+
"<|quad_end|>",
|
191 |
+
"<|vision_start|>",
|
192 |
+
"<|vision_end|>",
|
193 |
+
"<|vision_pad|>",
|
194 |
+
"<|image_pad|>",
|
195 |
+
"<|video_pad|>"
|
196 |
+
],
|
197 |
+
"bos_token": null,
|
198 |
+
"clean_up_tokenization_spaces": false,
|
199 |
+
"eos_token": "<|im_end|>",
|
200 |
+
"errors": "replace",
|
201 |
+
"extra_special_tokens": {},
|
202 |
+
"model_max_length": 131072,
|
203 |
+
"pad_token": "<|endoftext|>",
|
204 |
+
"padding_side": "right",
|
205 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
206 |
+
"split_special_tokens": false,
|
207 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
208 |
+
"unk_token": null
|
209 |
+
}
|
video_preprocessor_config.json
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_valid_kwargs_names": [
|
3 |
+
"do_convert_rgb",
|
4 |
+
"do_resize",
|
5 |
+
"size",
|
6 |
+
"size_divisor",
|
7 |
+
"default_to_square",
|
8 |
+
"resample",
|
9 |
+
"do_rescale",
|
10 |
+
"rescale_factor",
|
11 |
+
"do_normalize",
|
12 |
+
"image_mean",
|
13 |
+
"image_std",
|
14 |
+
"do_pad",
|
15 |
+
"do_center_crop",
|
16 |
+
"crop_size",
|
17 |
+
"data_format",
|
18 |
+
"input_data_format",
|
19 |
+
"device",
|
20 |
+
"min_pixels",
|
21 |
+
"max_pixels",
|
22 |
+
"patch_size",
|
23 |
+
"temporal_patch_size",
|
24 |
+
"merge_size"
|
25 |
+
],
|
26 |
+
"crop_size": null,
|
27 |
+
"data_format": "channels_first",
|
28 |
+
"default_to_square": true,
|
29 |
+
"device": null,
|
30 |
+
"do_center_crop": null,
|
31 |
+
"do_convert_rgb": true,
|
32 |
+
"do_normalize": true,
|
33 |
+
"do_pad": null,
|
34 |
+
"do_rescale": true,
|
35 |
+
"do_resize": true,
|
36 |
+
"image_mean": [
|
37 |
+
0.48145466,
|
38 |
+
0.4578275,
|
39 |
+
0.40821073
|
40 |
+
],
|
41 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
42 |
+
"image_std": [
|
43 |
+
0.26862954,
|
44 |
+
0.26130258,
|
45 |
+
0.27577711
|
46 |
+
],
|
47 |
+
"input_data_format": null,
|
48 |
+
"max_pixels": 12845056,
|
49 |
+
"merge_size": 2,
|
50 |
+
"min_pixels": 3136,
|
51 |
+
"model_valid_processing_keys": [
|
52 |
+
"do_convert_rgb",
|
53 |
+
"do_resize",
|
54 |
+
"size",
|
55 |
+
"size_divisor",
|
56 |
+
"default_to_square",
|
57 |
+
"resample",
|
58 |
+
"do_rescale",
|
59 |
+
"rescale_factor",
|
60 |
+
"do_normalize",
|
61 |
+
"image_mean",
|
62 |
+
"image_std",
|
63 |
+
"do_pad",
|
64 |
+
"do_center_crop",
|
65 |
+
"crop_size",
|
66 |
+
"data_format",
|
67 |
+
"input_data_format",
|
68 |
+
"device",
|
69 |
+
"min_pixels",
|
70 |
+
"max_pixels",
|
71 |
+
"patch_size",
|
72 |
+
"temporal_patch_size",
|
73 |
+
"merge_size"
|
74 |
+
],
|
75 |
+
"patch_size": 14,
|
76 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
77 |
+
"resample": 3,
|
78 |
+
"rescale_factor": 0.00392156862745098,
|
79 |
+
"size": {
|
80 |
+
"longest_edge": 12845056,
|
81 |
+
"shortest_edge": 3136
|
82 |
+
},
|
83 |
+
"size_divisor": null,
|
84 |
+
"temporal_patch_size": 2,
|
85 |
+
"video_processor_type": "Qwen2VLVideoProcessor"
|
86 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|