Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,13 @@ import gradio as gr
|
|
5 |
from PIL import Image
|
6 |
import torch
|
7 |
from transformers import BlipProcessor, BlipForQuestionAnswering
|
8 |
-
from concurrent.futures import ThreadPoolExecutor
|
9 |
|
10 |
# Initialize the model and processor
|
11 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
|
12 |
model = BlipForQuestionAnswering.from_pretrained("ManishThota/InstructBlip-VQA")
|
13 |
|
14 |
-
executor = ThreadPoolExecutor(max_workers=4)
|
15 |
|
16 |
|
17 |
def predict_answer(image, question):
|
@@ -27,13 +27,13 @@ def predict_answer(image, question):
|
|
27 |
return generated_text
|
28 |
|
29 |
|
30 |
-
# def gradio_predict(image, question):
|
31 |
-
# answer = predict_answer(image, question)
|
32 |
-
# return answer
|
33 |
-
|
34 |
def gradio_predict(image, question):
|
35 |
-
|
36 |
-
return
|
|
|
|
|
|
|
|
|
37 |
|
38 |
|
39 |
# Define the Gradio interface
|
|
|
5 |
from PIL import Image
|
6 |
import torch
|
7 |
from transformers import BlipProcessor, BlipForQuestionAnswering
|
8 |
+
# from concurrent.futures import ThreadPoolExecutor
|
9 |
|
10 |
# Initialize the model and processor
|
11 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
|
12 |
model = BlipForQuestionAnswering.from_pretrained("ManishThota/InstructBlip-VQA")
|
13 |
|
14 |
+
# executor = ThreadPoolExecutor(max_workers=4)
|
15 |
|
16 |
|
17 |
def predict_answer(image, question):
|
|
|
27 |
return generated_text
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
30 |
def gradio_predict(image, question):
|
31 |
+
answer = predict_answer(image, question)
|
32 |
+
return answer
|
33 |
+
|
34 |
+
# def gradio_predict(image, question):
|
35 |
+
# future = executor.submit(predict_answer, image, question)
|
36 |
+
# return future.result()
|
37 |
|
38 |
|
39 |
# Define the Gradio interface
|