Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,28 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from inference import load_for_inference, predict
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|