Spaces:
Sleeping
Sleeping
| 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() |