Spaces:
Sleeping
Sleeping
Download app.py from SentilyticsOPJ/SVM_model: direct link, hf CLI and curl.
- Browser
- Download file 715 Bytes
-
https://huggingface.co/spaces/SentilyticsOPJ/SVM_model/resolve/main/app.py
- Command line
-
hf download hf://spaces/SentilyticsOPJ/SVM_model/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SentilyticsOPJ/SVM_model/resolve/main/app.py
715 Bytes
| 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() |