sks01dev commited on
Commit
e23b8f4
·
1 Parent(s): 54a886d

Production Deploy: Minimal Gradio app with final configuration.

Browse files
Files changed (3) hide show
  1. README.md +4 -11
  2. app.py +39 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,14 +1,7 @@
 
1
  ---
2
- title: Clickbait Prediction
3
- emoji: 👁
4
- colorFrom: gray
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 5.49.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- short_description: A lightweight and efficient NLP project
12
  ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: Clickbait Prediction Model
4
+ emoji: 🚨
 
 
5
  sdk: gradio
6
+ python_version: 3.11 # CRITICAL FIX for TypeError: code expected 16, got 18
 
 
 
 
7
  ---
 
 
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ CLASSIFIER_MODEL_ID = "sks01dev/clickbait-classifier"
6
+
7
+ # The pipeline loads assets directly from the Hub and handles pre/post-processing.
8
+ classifier = pipeline(
9
+ "sentiment-analysis",
10
+ model=CLASSIFIER_MODEL_ID,
11
+ tokenizer=CLASSIFIER_MODEL_ID,
12
+ return_all_scores=True
13
+ )
14
+
15
+ def predict(headline):
16
+ # Runs inference and formats the output dictionary for Gradio Label
17
+ results = classifier(headline)[0]
18
+
19
+ # Map generic LABEL_X to clear, human-readable output
20
+ # NOTE: results[0] is typically LABEL_0, results[1] is LABEL_1
21
+ formatted_output = {
22
+ "NOT CLICKBAIT (0)": results[0]['score'],
23
+ "CLICKBAIT (1)": results[1]['score']
24
+ }
25
+ return formatted_output
26
+
27
+ # Gradio Interface Setup
28
+ gr.Interface(
29
+ fn=predict,
30
+ inputs=gr.Textbox(lines=2, label="Enter News Headline"),
31
+ outputs=gr.Label(num_top_classes=2, title="Prediction Confidence"),
32
+ title="World-Class Clickbait Predictor",
33
+ description="DeBERTa-v3-small model deployed for high-confidence headline analysis.",
34
+ examples=[
35
+ ["10 Ways To Instantly Improve Your Mood"],
36
+ ["Government Releases New Economic Policy Report"],
37
+ ["You Won't Believe What Happened When We Tested This!"],
38
+ ]
39
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ gradio
3
+ transformers
4
+ torch