Spaces:
Runtime error
Runtime error
import gradio as gr | |
from PIL import Image | |
# Define the prediction function for Gradio | |
def predict(image, question): | |
inputs = processor(text=[question], images=[image], return_tensors="pt", padding=True).to(device) | |
outputs = model.generate(**inputs) | |
return processor.tokenizer.decode(outputs[0], skip_special_tokens=True) | |
# Create the Gradio interface | |
interface = gr.Interface( | |
fn=predict, | |
inputs=["image", "text"], | |
outputs="text", | |
title="Florence 2 VQA - Engineering Drawings", | |
description="Upload an engineering drawing and ask a related question." | |
) | |
# Launch the Gradio interface | |
interface.launch() | |