czczup commited on
Commit
9d88fd9
1 Parent(s): 0348b61

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. modeling_internvl_chat.py +5 -2
modeling_internvl_chat.py CHANGED
@@ -375,7 +375,7 @@ class InternVLChatModel(PreTrainedModel):
375
  vit_embeds = self.mlp1(vit_embeds)
376
  return vit_embeds
377
 
378
- def chat(self, tokenizer, pixel_values, question, generation_config, history=None,
379
  IMG_START_TOKEN='<img>', IMG_END_TOKEN='</img>', IMG_CONTEXT_TOKEN='<IMG_CONTEXT>'):
380
 
381
  img_context_token_id = tokenizer.convert_tokens_to_ids(IMG_CONTEXT_TOKEN)
@@ -407,7 +407,10 @@ class InternVLChatModel(PreTrainedModel):
407
  )
408
  response = tokenizer.batch_decode(generation_output, skip_special_tokens=True)[0]
409
  history.append((question, response))
410
- return response, history
 
 
 
411
 
412
  @torch.no_grad()
413
  def generate(
 
375
  vit_embeds = self.mlp1(vit_embeds)
376
  return vit_embeds
377
 
378
+ def chat(self, tokenizer, pixel_values, question, generation_config, history=None, return_history=False,
379
  IMG_START_TOKEN='<img>', IMG_END_TOKEN='</img>', IMG_CONTEXT_TOKEN='<IMG_CONTEXT>'):
380
 
381
  img_context_token_id = tokenizer.convert_tokens_to_ids(IMG_CONTEXT_TOKEN)
 
407
  )
408
  response = tokenizer.batch_decode(generation_output, skip_special_tokens=True)[0]
409
  history.append((question, response))
410
+ if return_history:
411
+ return response, history
412
+ else:
413
+ return response
414
 
415
  @torch.no_grad()
416
  def generate(