Jyotiyadav commited on
Commit
555e655
·
verified ·
1 Parent(s): 185f341

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+
4
+ # Define the prediction function for Gradio
5
+ def predict(image, question):
6
+ inputs = processor(text=[question], images=[image], return_tensors="pt", padding=True).to(device)
7
+ outputs = model.generate(**inputs)
8
+ return processor.tokenizer.decode(outputs[0], skip_special_tokens=True)
9
+
10
+ # Create the Gradio interface
11
+ interface = gr.Interface(
12
+ fn=predict,
13
+ inputs=["image", "text"],
14
+ outputs="text",
15
+ title="Florence 2 VQA - Engineering Drawings",
16
+ description="Upload an engineering drawing and ask a related question."
17
+ )
18
+
19
+ # Launch the Gradio interface
20
+ interface.launch()