Spaces:
Runtime error
Runtime error
File size: 636 Bytes
555e655 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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()
|