Mueris commited on
Commit
69a3efa
·
verified ·
1 Parent(s): 3662ec7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -1,19 +1,28 @@
1
- import gradio as gr
2
- from inference import load_for_inference, predict
3
-
4
- REPO_ID = "MUERIS/TurkishVLMTAMGA"
5
-
6
- model, tokenizer, device = load_for_inference(REPO_ID)
7
-
8
- def answer(image, question):
9
- return predict(model, tokenizer, device, image, question)
10
-
11
- gr.Interface(
12
- fn=answer,
13
- inputs=[
14
- gr.Image(type="pil"),
15
- gr.Textbox(label="Question")
16
- ],
17
- outputs="text",
18
- title="CLIP2MT5 Visual Question Answering"
19
- ).launch()
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from inference import load_for_inference, predict
3
+ from PIL import Image
4
+
5
+ REPO_ID = "Mueris/TurkishVLMTAMGA"
6
+
7
+ # Load the model only once
8
+ model, tokenizer, device = load_for_inference(REPO_ID)
9
+
10
+ def answer(image, question):
11
+ if image is None or not question.strip():
12
+ return "Lütfen bir görsel ve soru girin."
13
+
14
+ image = Image.fromarray(image)
15
+ return predict(model, tokenizer, device, image, question)
16
+
17
+ demo = gr.Interface(
18
+ fn=answer,
19
+ inputs=[
20
+ gr.Image(type="numpy", label="Görsel Yükle"),
21
+ gr.Textbox(label="Soru (Türkçe VQA)")
22
+ ],
23
+ outputs="text",
24
+ title="🇹🇷 TAMGA - Türk Savunma Sanayii VLM",
25
+ description="Görsel yükleyin, savunma sanayii odaklı bir soru sorun."
26
+ )
27
+
28
+ demo.launch()