finalf0 commited on
Commit
688f720
1 Parent(s): 86cb267

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -0
README.md CHANGED
@@ -99,3 +99,29 @@ pipeline_tag: text-classification
99
 
100
  ## Demo
101
  Click here to try out the Demo of [MiniCPM-V](http://120.92.209.146:80).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  ## Demo
101
  Click here to try out the Demo of [MiniCPM-V](http://120.92.209.146:80).
102
+
103
+
104
+ ## Usage
105
+
106
+ ```python
107
+ import torch
108
+ from PIL import Image
109
+ from transformers import AutoModel, AutoTokenizer
110
+
111
+ model = AutoModel.from_pretrained('openbmb/MiniCPM-V/', trust_remote_code=True)
112
+ tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
113
+ model.eval().cuda()
114
+
115
+ image = Image.open('xx.jpg').convert('RGB')
116
+ question = '请描述一下该图像'
117
+
118
+ res, context, _ = model.chat(
119
+ image=image,
120
+ question=question,
121
+ context=None,
122
+ tokenizer=tokenizer,
123
+ sampling=True,
124
+ temperature=0.7
125
+ )
126
+ print(res)
127
+ ```