Commit
·
f260439
1
Parent(s):
cadcb55
Update app.py
Browse files
app.py
CHANGED
@@ -33,19 +33,19 @@ def blip2_interface(image, prompted_caption_text, vqa_question, chat_context):
|
|
33 |
image_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
34 |
|
35 |
# Prompted Image Captioning
|
36 |
-
inputs = processor(image_input, text=prompted_caption_text, return_tensors="pt").to(device
|
37 |
generated_ids = model.generate(**inputs, max_new_tokens=20)
|
38 |
prompted_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
39 |
|
40 |
# Visual Question Answering (VQA)
|
41 |
prompt = f"Question: {vqa_question} Answer:"
|
42 |
-
inputs = processor(image_input, text=prompt, return_tensors="pt").to(device
|
43 |
generated_ids = model.generate(**inputs, max_new_tokens=10)
|
44 |
vqa_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
45 |
|
46 |
# Chat-based Prompting
|
47 |
prompt = chat_context + " Answer:"
|
48 |
-
inputs = processor(image_input, text=prompt, return_tensors="pt").to(device
|
49 |
generated_ids = model.generate(**inputs, max_new_tokens=10)
|
50 |
chat_response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
51 |
|
|
|
33 |
image_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
34 |
|
35 |
# Prompted Image Captioning
|
36 |
+
inputs = processor(image_input, text=prompted_caption_text, return_tensors="pt").to(device)
|
37 |
generated_ids = model.generate(**inputs, max_new_tokens=20)
|
38 |
prompted_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
39 |
|
40 |
# Visual Question Answering (VQA)
|
41 |
prompt = f"Question: {vqa_question} Answer:"
|
42 |
+
inputs = processor(image_input, text=prompt, return_tensors="pt").to(device)
|
43 |
generated_ids = model.generate(**inputs, max_new_tokens=10)
|
44 |
vqa_answer = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
45 |
|
46 |
# Chat-based Prompting
|
47 |
prompt = chat_context + " Answer:"
|
48 |
+
inputs = processor(image_input, text=prompt, return_tensors="pt").to(device)
|
49 |
generated_ids = model.generate(**inputs, max_new_tokens=10)
|
50 |
chat_response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
51 |
|