anhartit-chetan commited on
Commit
6b849c6
·
1 Parent(s): de423bd

Updated to resolve error for apply_chat_template

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -22,17 +22,11 @@ def analyze_palm(image, question, history):
22
  history.append((question, "Please provide both image and question."))
23
  return history, ""
24
 
25
- conversation = [
26
- {"role": "user", "content": [
27
- {"type": "text", "text": question},
28
- {"type": "image"}
29
- ]}
30
- ]
31
- prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
32
- inputs = processor(images=image, text=prompt, return_tensors="pt").to(model.device)
33
-
34
- output = model.generate(**inputs, max_new_tokens=512)
35
- response = processor.decode(output[0], skip_special_tokens=True)
36
 
37
  history.append((question, response))
38
  return history, ""
 
22
  history.append((question, "Please provide both image and question."))
23
  return history, ""
24
 
25
+ # Manual prompt construction (works for TinyLLaVA)
26
+ inputs = processor(text=question, images=image, return_tensors="pt").to(model.device)
27
+
28
+ outputs = model.generate(**inputs, max_new_tokens=512)
29
+ response = processor.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
 
 
30
 
31
  history.append((question, response))
32
  return history, ""