Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from transformers import BlipProcessor, BlipForQuestionAnswering
|
|
5 |
|
6 |
# Initialize the model and processor
|
7 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
|
8 |
-
model = BlipForQuestionAnswering.from_pretrained("ManishThota/InstructBlip-VQA")
|
9 |
# model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
|
10 |
|
11 |
def predict_answer(image, question):
|
@@ -13,7 +13,7 @@ def predict_answer(image, question):
|
|
13 |
image = image.convert("RGB")
|
14 |
|
15 |
# Prepare inputs
|
16 |
-
encoding = processor(image, question, return_tensors="pt")
|
17 |
|
18 |
out = model.generate(**encoding)
|
19 |
generated_text = processor.decode(out[0], skip_special_tokens=True)
|
|
|
5 |
|
6 |
# Initialize the model and processor
|
7 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
|
8 |
+
model = BlipForQuestionAnswering.from_pretrained("ManishThota/InstructBlip-VQA").to("cuda")
|
9 |
# model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
|
10 |
|
11 |
def predict_answer(image, question):
|
|
|
13 |
image = image.convert("RGB")
|
14 |
|
15 |
# Prepare inputs
|
16 |
+
encoding = processor(image, question, return_tensors="pt").to("cuda:0", torch.float16)
|
17 |
|
18 |
out = model.generate(**encoding)
|
19 |
generated_text = processor.decode(out[0], skip_special_tokens=True)
|