Spaces:
Running
Running
Commit
·
6b849c6
1
Parent(s):
de423bd
Updated to resolve error for apply_chat_template
Browse files
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 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 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, ""
|