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()