Spaces:
Runtime error
Runtime error
File size: 788 Bytes
1a838e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
from transformers.utils import logging
logging.set_verbosity_error()
import warnings
warnings.filterwarnings("ignore", message="Using the model-agnostic default `max_length`")
from transformers import BlipForQuestionAnswering
from transformers import AutoProcessor
def qa(inputs):
model = BlipForQuestionAnswering.from_pretrained(
"./models/Salesforce/blip-vqa-base")
processor = AutoProcessor.from_pretrained(
"./models/Salesforce/blip-vqa-base")
inputs = processor(image, question, return_tensors="pt")
out = model.generate(**inputs)
return processor.decode(out[0], skip_special_tokens=True)
# def greet(name):
# return "Hello " + name + "!!"
iface = gr.Interface(fn=qa, inputs=["image","text"], outputs="text")
iface.launch()
|