Spaces:
Sleeping
Sleeping
Upload app and requirements
Browse files- app.py +27 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from smodel.llava_inference import LLaVAHelper
|
4 |
+
|
5 |
+
model = LLaVAHelper()
|
6 |
+
|
7 |
+
def answer_question(image, question):
|
8 |
+
if image is None or question.strip() == "":
|
9 |
+
return "Please upload an image and enter a question."
|
10 |
+
return model.generate_answer(image, question)
|
11 |
+
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=answer_question,
|
14 |
+
inputs=[
|
15 |
+
gr.Image(type="pil", label="Upload Public Transport Signage"),
|
16 |
+
gr.Textbox(label="Ask a question (e.g., 'When is the next train to London?')")
|
17 |
+
],
|
18 |
+
outputs=gr.Textbox(label="Answer"),
|
19 |
+
title="UK Public Transport Assistant",
|
20 |
+
description="Upload an image of UK public transport signage (like train timetables or metro maps), and ask a question related to it. Powered by LLaVA-1.5.",
|
21 |
+
examples=[
|
22 |
+
["assets/example.jpg", "Where is platform 3?"],
|
23 |
+
]
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
accelerate
|
4 |
+
gradio
|
5 |
+
llava
|