jiangbop commited on
Commit
9854493
·
verified ·
1 Parent(s): 4dbb7f4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -56
README.md CHANGED
@@ -222,66 +222,11 @@ question = 'Can you explain quantum mechanics to me?'
222
  response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
223
  print(f'User: {question}\nAssistant: {response}')
224
 
225
- # single-image single-round conversation (单张图片单轮对话)
226
  question = '<image>\nWhat do you see in this image?'
227
  response = model.chat(tokenizer, pixel_values, question, generation_config)
228
  print(f'User: {question}\nAssistant: {response}')
229
 
230
- # single-image multi-round conversation (单张图片多轮对话)
231
- question = '<image>\nCan you provide a detailed description of the image?'
232
- response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
233
- print(f'User: {question}\nAssistant: {response}')
234
-
235
- question = 'Based on the image, can you create a short story?'
236
- response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
237
- print(f'User: {question}\nAssistant: {response}')
238
-
239
- # multi-image multi-round conversation, combined images (多张图片多轮对话, 拼接图片)
240
- pixel_values1 = load_image('./demo/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
241
- pixel_values2 = load_image('./demo/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
242
- pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
243
-
244
- question = '<image>\nDescribe the two images in detail.'
245
- response, history = model.chat(tokenizer, pixel_values, question, generation_config,
246
- history=None, return_history=True)
247
- print(f'User: {question}\nAssistant: {response}')
248
-
249
- question = 'What are the main differences between these two images?'
250
- response, history = model.chat(tokenizer, pixel_values, question, generation_config,
251
- history=history, return_history=True)
252
- print(f'User: {question}\nAssistant: {response}')
253
-
254
- # multi-image multi-round conversation, separate images (多张图片多轮对话, 分割图片)
255
- pixel_values1 = load_image('./demo/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
256
- pixel_values2 = load_image('./demo/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
257
- pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
258
- num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
259
-
260
- question = 'Image-1: <image>\nImage-2: <image>\nDescribe the two images in detail.'
261
- response, history = model.chat(tokenizer, pixel_values, question, generation_config,
262
- num_patches_list=num_patches_list,
263
- history=None, return_history=True)
264
- print(f'User: {question}\nAssistant: {response}')
265
-
266
- question = 'What are the similarities between these two images?'
267
- response, history = model.chat(tokenizer, pixel_values, question, generation_config,
268
- num_patches_list=num_patches_list,
269
- history=history, return_history=True)
270
- print(f'User: {question}\nAssistant: {response}')
271
-
272
- # batch inference, single image per sample (批量推理, 每条数据一张图片)
273
- pixel_values1 = load_image('./demo/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
274
- pixel_values2 = load_image('./demo/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
275
- num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
276
- pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
277
-
278
- questions = ['<image>\nDescribe the image in detail.'] * len(num_patches_list)
279
- responses = model.batch_chat(tokenizer, pixel_values,
280
- num_patches_list=num_patches_list,
281
- questions=questions,
282
- generation_config=generation_config)
283
- for question, response in zip(questions, responses):
284
- print(f'User: {question}\nAssistant: {response}')
285
  ```
286
 
287
  ## Citation
 
222
  response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
223
  print(f'User: {question}\nAssistant: {response}')
224
 
225
+ # image-text conversation (图文对话)
226
  question = '<image>\nWhat do you see in this image?'
227
  response = model.chat(tokenizer, pixel_values, question, generation_config)
228
  print(f'User: {question}\nAssistant: {response}')
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  ```
231
 
232
  ## Citation