Instructions to use openbmb/MiniCPM-V with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM-V with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("visual-question-answering", model="openbmb/MiniCPM-V", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openbmb/MiniCPM-V", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
fix bug
#5
by baymax591 - opened
For detailed information on the error, please refer to https://huggingface.co/openbmb/MiniCPM-V/discussions/4.
The inference with MiniCPM-V is flawless, but issues arise during the fine-tuning process. The fine-tuning code used is from https://github.com/OpenBMB/MiniCPM-V/tree/main.
issue
patch_size
AttributeError: 'MiniCPMVConfig' object has no attribute 'patch_size'
scale_resolution
File "path/MiniCPM-V/finetune/dataset.py", line 307, in preprocess
assert "scale_resolution" in slice_config
AssertionError
RuntimeError
In the resampler.py file, inside the get_abs_pos function, after using sqrt to calculate the square root, the resulting size does not match the original size.
File "/root/.cache/huggingface/modules/transformers_modules/MiniCPM-V/resampler.py", line 154, in forward
x + pos_embed.unsqueeze(1),
RuntimeError: The size of tensor a (1014) must match the size of tensor b (961) at non-singleton dimension 0
bug fix
patch_size
Add "patch_size": 14, to the config.py file.
scale_resolution
Add "scale_resolution": 448, to the config.py file.
RuntimeError
This bug is fixed in MiniCPM-V-2.