mirror of
https://github.com/RYDE-WORK/MiniCPM.git
synced 2026-02-04 14:19:58 +08:00
update README-en
This commit is contained in:
parent
9acaa0bda8
commit
68d4f27840
29
README-en.md
29
README-en.md
@ -103,6 +103,8 @@ python inference.py --model_path <vllmcpm_repo_path> --prompt_path prompts/promp
|
|||||||
|
|
||||||
#### Huggingface
|
#### Huggingface
|
||||||
|
|
||||||
|
##### MiniCPM-2B
|
||||||
|
|
||||||
* Install `transformers>=4.36.0` and `accelerate`,run the following python code.
|
* Install `transformers>=4.36.0` and `accelerate`,run the following python code.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -124,10 +126,31 @@ print(responds)
|
|||||||
The capital city of China is Beijing. Beijing is not only the political center of China but also a cultural and economic hub. It is known for its rich history and numerous landmarks, such as the Great Wall, the Forbidden City, and the Temple of Heaven. The city is also home to the National Stadium, also known as the "Bird's Nest," and the National Aquatics Center, or "Water Cube." Beijing is a significant city in China, with a population of over 21 million people.
|
The capital city of China is Beijing. Beijing is not only the political center of China but also a cultural and economic hub. It is known for its rich history and numerous landmarks, such as the Great Wall, the Forbidden City, and the Temple of Heaven. The city is also home to the National Stadium, also known as the "Bird's Nest," and the National Aquatics Center, or "Water Cube." Beijing is a significant city in China, with a population of over 21 million people.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p id="3"></p>
|
##### MiniCPM-V
|
||||||
|
|
||||||
Update soon.
|
```python
|
||||||
|
import torch
|
||||||
|
from PIL import Image
|
||||||
|
from transformers import AutoModel, AutoTokenizer
|
||||||
|
|
||||||
|
model = AutoModel.from_pretrained('openbmb/MiniCPM-V/', trust_remote_code=True)
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
|
||||||
|
model.eval().cuda()
|
||||||
|
|
||||||
|
image = Image.open('xx.jpg').convert('RGB')
|
||||||
|
question = 'What is in the image?'
|
||||||
|
msgs = [{'role': 'user', 'content': question}]
|
||||||
|
|
||||||
|
res, context, _ = model.chat(
|
||||||
|
image=image,
|
||||||
|
msgs=msgs,
|
||||||
|
context=None,
|
||||||
|
tokenizer=tokenizer,
|
||||||
|
sampling=True,
|
||||||
|
temperature=0.7
|
||||||
|
)
|
||||||
|
print(res)
|
||||||
|
```
|
||||||
|
|
||||||
<p id="3"></p>
|
<p id="3"></p>
|
||||||
|
|
||||||
@ -315,7 +338,7 @@ Update soon.
|
|||||||
* Support MiniCPM-2B-SFT-INT4、MiniCPM-2B-DPO-INT4.
|
* Support MiniCPM-2B-SFT-INT4、MiniCPM-2B-DPO-INT4.
|
||||||
* [Compile and Installation Guide](https://github.com/OpenBMB/LLMFarm)
|
* [Compile and Installation Guide](https://github.com/OpenBMB/LLMFarm)
|
||||||
|
|
||||||
### Performance
|
#### Performance
|
||||||
|
|
||||||
* We did not conduct in-depth optimization and system testing on the mobile inference model, only verifying the feasibility of MiniCPM using mobile phone chips for inference.
|
* We did not conduct in-depth optimization and system testing on the mobile inference model, only verifying the feasibility of MiniCPM using mobile phone chips for inference.
|
||||||
* There have been no previous attempts to deploy multimodal models on mobile phones. We have verified the feasibility of deploying MiniCPM-V on mobile phones based on MLC-LLM this time, and it can input and output normally. However, there also exist a problem of long image processing time, which needs further optimization :)
|
* There have been no previous attempts to deploy multimodal models on mobile phones. We have verified the feasibility of deploying MiniCPM-V on mobile phones based on MLC-LLM this time, and it can input and output normally. However, there also exist a problem of long image processing time, which needs further optimization :)
|
||||||
|
|||||||
13
README.md
13
README.md
@ -126,22 +126,23 @@ print(responds)
|
|||||||
```
|
```
|
||||||
|
|
||||||
##### MiniCPM-V
|
##### MiniCPM-V
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import torch
|
import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from transformers import AutoModel, AutoTokenizer
|
from transformers import AutoModel, AutoTokenizer
|
||||||
|
|
||||||
model_path='openbmb/MiniCPM-V'
|
model = AutoModel.from_pretrained('openbmb/MiniCPM-V/', trust_remote_code=True)
|
||||||
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.bfloat16)
|
tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
|
||||||
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
|
||||||
model.eval().cuda()
|
model.eval().cuda()
|
||||||
|
|
||||||
image = Image.open('./assets/COCO_test2015_000000262144.jpg').convert('RGB')
|
image = Image.open('xx.jpg').convert('RGB')
|
||||||
|
question = 'What is in the image?'
|
||||||
|
msgs = [{'role': 'user', 'content': question}]
|
||||||
|
|
||||||
question = '请描述一下该图像'
|
|
||||||
res, context, _ = model.chat(
|
res, context, _ = model.chat(
|
||||||
image=image,
|
image=image,
|
||||||
question=question,
|
msgs=msgs,
|
||||||
context=None,
|
context=None,
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
sampling=True,
|
sampling=True,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user