Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import joblib
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
|
|
|
| 8 |
def predict_headline(headline):
|
| 9 |
pred = model.predict(vectorizer.transform([headline]))[0]
|
| 10 |
return pred
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import joblib
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
|
| 5 |
+
# Download model + vectorizer from your HF repo (public repo)
|
| 6 |
+
model_path = hf_hub_download(
|
| 7 |
+
repo_id="Devishetty100/clickbait-detector",
|
| 8 |
+
filename="clickbait_detector.pkl",
|
| 9 |
+
token=None # None for public repo
|
| 10 |
+
)
|
| 11 |
+
vectorizer_path = hf_hub_download(
|
| 12 |
+
repo_id="Devishetty100/clickbait-detector",
|
| 13 |
+
filename="tfidf_vectorizer.pkl",
|
| 14 |
+
token=None
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
# Load them
|
| 18 |
+
model = joblib.load(model_path)
|
| 19 |
+
vectorizer = joblib.load(vectorizer_path)
|
| 20 |
|
| 21 |
+
# Prediction function
|
| 22 |
def predict_headline(headline):
|
| 23 |
pred = model.predict(vectorizer.transform([headline]))[0]
|
| 24 |
return pred
|