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
fix bug image_processing
Browse files
image_processing_minicpmv.py
CHANGED
|
@@ -52,6 +52,7 @@ class MiniCPMVBatchFeature(BatchFeature):
|
|
| 52 |
if not is_tensor(value):
|
| 53 |
tensor = as_tensor(value)
|
| 54 |
return tensor
|
|
|
|
| 55 |
except: # noqa E722
|
| 56 |
if key == "overflowing_values":
|
| 57 |
raise ValueError("Unable to create tensor returning overflowing values of different lengths. ")
|
|
@@ -71,6 +72,8 @@ class MiniCPMVBatchFeature(BatchFeature):
|
|
| 71 |
|
| 72 |
def cast_tensor(v):
|
| 73 |
# check if v is a floating point
|
|
|
|
|
|
|
| 74 |
if torch.is_floating_point(v):
|
| 75 |
# cast and send to device
|
| 76 |
return v.to(*args, **kwargs)
|
|
|
|
| 52 |
if not is_tensor(value):
|
| 53 |
tensor = as_tensor(value)
|
| 54 |
return tensor
|
| 55 |
+
return value
|
| 56 |
except: # noqa E722
|
| 57 |
if key == "overflowing_values":
|
| 58 |
raise ValueError("Unable to create tensor returning overflowing values of different lengths. ")
|
|
|
|
| 72 |
|
| 73 |
def cast_tensor(v):
|
| 74 |
# check if v is a floating point
|
| 75 |
+
if v is None:
|
| 76 |
+
return None
|
| 77 |
if torch.is_floating_point(v):
|
| 78 |
# cast and send to device
|
| 79 |
return v.to(*args, **kwargs)
|