ENTUM-AI commited on
Commit
e809d1d
·
verified ·
1 Parent(s): 11ed07b

Upload Gradio UI for Clickbait Classifier

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -7,15 +7,15 @@ MODEL_NAME = "ENTUM-AI/distilbert-clickbait-classifier"
7
  try:
8
  classifier = pipeline("text-classification", model=MODEL_NAME)
9
  except Exception as e:
10
- print(f"Ошибка загрузки модели: {e}")
11
  classifier = None
12
 
13
  def predict(text):
14
  if not text.strip():
15
- return "Пожалуйста, введите текст."
16
 
17
  if classifier is None:
18
- return "Модель еще не загрузилась или произошла ошибка."
19
 
20
  result = classifier(text)[0]
21
  label = result['label']
@@ -23,9 +23,9 @@ def predict(text):
23
 
24
  # Форматируем красивый вывод
25
  if label == "Clickbait":
26
- return f"🚨 Это КЛИКБЕЙТ! (Уверенность: {score:.1%})"
27
  else:
28
- return f"📰 Нормальная новость (Уверенность: {score:.1%})"
29
 
30
  # Настраиваем красивый интерфейс Gradio
31
  theme = gr.themes.Soft(
@@ -38,25 +38,25 @@ with gr.Blocks(theme=theme, title="Clickbait Detector 🎣") as demo:
38
  """
39
  # 🎣 Clickbait Headline Detector
40
 
41
- Эта модель на базе **DistilBERT** предсказывает, является ли заголовок новости или статьи "кликбейтом".
42
- Она была обучена на десятках тысяч реальных заголовков СМИ.
43
 
44
- *Введите любой заголовок на английском языке ниже, чтобы проверить его!*
45
  """
46
  )
47
 
48
  with gr.Row():
49
  with gr.Column(scale=2):
50
  input_text = gr.Textbox(
51
- label="Введите заголовок (English)",
52
- placeholder="Например: 10 Things You Won't Believe About AI!...",
53
  lines=3
54
  )
55
- submit_btn = gr.Button("Проверить заголовок 🔍", variant="primary")
56
 
57
  with gr.Column(scale=1):
58
  output_text = gr.Textbox(
59
- label="Вердикт модели",
60
  lines=3,
61
  interactive=False
62
  )
 
7
  try:
8
  classifier = pipeline("text-classification", model=MODEL_NAME)
9
  except Exception as e:
10
+ print(f"Error loading model: {e}")
11
  classifier = None
12
 
13
  def predict(text):
14
  if not text.strip():
15
+ return "Please enter a headline."
16
 
17
  if classifier is None:
18
+ return "Model has not loaded yet or an error occurred."
19
 
20
  result = classifier(text)[0]
21
  label = result['label']
 
23
 
24
  # Форматируем красивый вывод
25
  if label == "Clickbait":
26
+ return f"🚨 CLICKBAIT! (Confidence: {score:.1%})"
27
  else:
28
+ return f"📰 NORMAL NEWS (Confidence: {score:.1%})"
29
 
30
  # Настраиваем красивый интерфейс Gradio
31
  theme = gr.themes.Soft(
 
38
  """
39
  # 🎣 Clickbait Headline Detector
40
 
41
+ This model, based on **DistilBERT**, predicts whether a news headline or article title is "clickbait".
42
+ It was trained on tens of thousands of real media headlines.
43
 
44
+ *Enter any English headline below to check it!*
45
  """
46
  )
47
 
48
  with gr.Row():
49
  with gr.Column(scale=2):
50
  input_text = gr.Textbox(
51
+ label="Enter headline",
52
+ placeholder="Example: 10 Bizarre Facts About Apples...",
53
  lines=3
54
  )
55
+ submit_btn = gr.Button("Check Headline 🔍", variant="primary")
56
 
57
  with gr.Column(scale=1):
58
  output_text = gr.Textbox(
59
+ label="Model Verdict",
60
  lines=3,
61
  interactive=False
62
  )