File size: 931 Bytes
75da6e0
 
f6b66fb
75da6e0
f6b66fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75da6e0
f6b66fb
75da6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
import joblib
from huggingface_hub import hf_hub_download

# Download model + vectorizer from your HF repo (public repo)
model_path = hf_hub_download(
    repo_id="Devishetty100/clickbait-detector",
    filename="clickbait_detector.pkl",
    token=None  # None for public repo
)
vectorizer_path = hf_hub_download(
    repo_id="Devishetty100/clickbait-detector",
    filename="tfidf_vectorizer.pkl",
    token=None
)

# Load them
model = joblib.load(model_path)
vectorizer = joblib.load(vectorizer_path)

# Prediction function
def predict_headline(headline):
    pred = model.predict(vectorizer.transform([headline]))[0]
    return pred

# Gradio Interface
iface = gr.Interface(
    fn=predict_headline,
    inputs=gr.Textbox(lines=2, placeholder="Enter a headline..."),
    outputs="text",
    title="📰 Clickbait Detector",
    description="Classifies headlines as clickbait or real news."
)

iface.launch()