Visual Question Answering
Transformers
Safetensors
English
Chinese
minicpmv
feature-extraction
custom_code
Eval Results
Instructions to use openbmb/MiniCPM-V-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM-V-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("visual-question-answering", model="openbmb/MiniCPM-V-2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openbmb/MiniCPM-V-2", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Update code
Browse files- modeling_minicpmv.py +8 -0
modeling_minicpmv.py
CHANGED
|
@@ -208,6 +208,14 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
|
|
| 208 |
result_text.append(tokenizer.decode(result).strip())
|
| 209 |
return result_text
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
def get_slice_image_placeholder(self, image, tokenizer):
|
| 212 |
image_placeholder = (
|
| 213 |
tokenizer.im_start
|
|
|
|
| 208 |
result_text.append(tokenizer.decode(result).strip())
|
| 209 |
return result_text
|
| 210 |
|
| 211 |
+
def slice_image(self, image):
|
| 212 |
+
return slice_image(
|
| 213 |
+
image,
|
| 214 |
+
self.config.max_slice_nums,
|
| 215 |
+
self.config.scale_resolution,
|
| 216 |
+
self.config.patch_size,
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
def get_slice_image_placeholder(self, image, tokenizer):
|
| 220 |
image_placeholder = (
|
| 221 |
tokenizer.im_start
|