sprev21 commited on
Commit
9718136
·
verified ·
1 Parent(s): 0016cea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,23 +1,29 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load a pre-trained text classification model
5
- classifier = pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-phishing")
6
 
 
7
  def detect_phishing(email_text):
8
  result = classifier(email_text)[0]
9
  label = result['label']
10
- score = result['score']
11
- return f"Prediction: {label} (Confidence: {score:.2f})"
 
 
 
 
12
 
13
- # Gradio interface
14
  interface = gr.Interface(
15
  fn=detect_phishing,
16
- inputs=gr.Textbox(lines=15, placeholder="Paste the email content here..."),
17
  outputs="text",
18
  title="Phishing Email Detector",
19
- description="This app detects whether an email is a phishing attempt."
20
  )
21
 
 
22
  if __name__ == "__main__":
23
  interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load a publicly available text classification model
5
+ classifier = pipeline("text-classification", model="BaptisteDoyen/fake-news-bert-base-uncased")
6
 
7
+ # Function to classify input text
8
  def detect_phishing(email_text):
9
  result = classifier(email_text)[0]
10
  label = result['label']
11
+ confidence = result['score']
12
+ if label.lower() in ["fake", "FAKE"]:
13
+ verdict = "⚠️ This email looks suspicious or potentially phishing."
14
+ else:
15
+ verdict = "✅ This email looks legitimate."
16
+ return f"{verdict}\n\nPrediction: {label}\nConfidence: {confidence:.2f}"
17
 
18
+ # Build Gradio interface
19
  interface = gr.Interface(
20
  fn=detect_phishing,
21
+ inputs=gr.Textbox(lines=15, placeholder="Paste the email text here..."),
22
  outputs="text",
23
  title="Phishing Email Detector",
24
+ description="This tool uses a language model to help determine if an email is likely phishing or legitimate."
25
  )
26
 
27
+ # Launch the app
28
  if __name__ == "__main__":
29
  interface.launch()