yujingfeng commited on
Commit
b97863a
·
verified ·
1 Parent(s): 1cc5901

Upload modeling_qwen2_5_vl.py

Browse files
Files changed (1) hide show
  1. modeling_qwen2_5_vl.py +9 -0
modeling_qwen2_5_vl.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM
2
+ import torch
3
+
4
+ class QWenVLChatModel(AutoModelForCausalLM):
5
+ def chat(self, tokenizer, query: str, image=None, history=None, **kwargs):
6
+ inputs = tokenizer(query, return_tensors="pt").to(self.device)
7
+ with torch.no_grad():
8
+ outputs = self.generate(**inputs, max_new_tokens=512)
9
+ return tokenizer.decode(outputs[0], skip_special_tokens=True), history