Serhii228 commited on
Commit
2603d4f
·
verified ·
1 Parent(s): 42b852b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import TFAutoModelForSequenceClassification, AutoTokenizer
3
+ import tensorflow as tf
4
+
5
+ model = TFAutoModelForSequenceClassification.from_pretrained("Serhii228/ukrainian-question-statement-classifier")
6
+ tokenizer = AutoTokenizer.from_pretrained("Serhii228/ukrainian-question-statement-classifier")
7
+
8
+ def classify(text):
9
+ inputs = tokenizer(text, return_tensors="tf", truncation=True, padding=True)
10
+ outputs = model(**inputs)
11
+ prob = tf.nn.sigmoid(outputs.logits).numpy()[0][0]
12
+ label = "🟢 Питання (1)" if prob > 0.5 else "🔵 Твердження (0)"
13
+ return f"{label} — ймовірність: {prob:.2f}"
14
+
15
+ demo = gr.Interface(
16
+ fn=classify,
17
+ inputs=gr.Textbox(lines=2, placeholder="Введіть українське речення..."),
18
+ outputs="text",
19
+ title="🇺🇦 Ukrainian Question Classifier",
20
+ description="Визначає, чи є фраза питанням або твердженням."
21
+ )
22
+
23
+ demo.launch()