File size: 715 Bytes
9396cb5
 
 
 
 
 
 
 
 
 
 
 
fab32c2
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import joblib
from huggingface_hub import hf_hub_download

obj = joblib.load(hf_hub_download("SentilyticsOPJ/SVM_model", "svm_model.joblib"))
model = obj["model"]
vectorizer = obj["vectorizer"]

def predict(text):
    features = vectorizer.transform([text])
    return str(model.predict(features)[0])

demo = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(lines=3, placeholder="Unesi tekst...", label="Text"),
    outputs=gr.Label(num_top_classes=1, label="Sentiment"),
    title="Sentiment Analysis (SVM, TF-IDF)",
    description="Five-class sentiment: mixed, negative, neutral, positive, sarcastic.",
    examples=["Volim kavu", "Ovaj doktor je loš", "Dan je bio ok"],
)
 
demo.launch()