rmdhirr commited on
Commit
120d185
1 Parent(s): 26ce0ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -36
app.py CHANGED
@@ -2,8 +2,6 @@ import gradio as gr
2
  import tensorflow as tf
3
  import pickle
4
  import numpy as np
5
- import requests
6
- from ProGPT import Conversation
7
  from sklearn.preprocessing import LabelEncoder
8
 
9
  # Load saved components
@@ -61,10 +59,6 @@ model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.0005),
61
  loss=ewc_loss,
62
  metrics=['accuracy', tf.keras.metrics.Precision(), tf.keras.metrics.Recall()])
63
 
64
- # Chatbot setup
65
- access_token = 'eyh-bc'
66
- chatbot = Conversation(access_token)
67
-
68
  # Function to preprocess input
69
  def preprocess_input(input_text, tokenizer, max_length):
70
  sequences = tokenizer.texts_to_sequences([input_text])
@@ -82,15 +76,6 @@ def get_prediction(input_text, input_type):
82
  prediction = model.predict([input_data, input_data])[0][0]
83
  return prediction
84
 
85
- # Function to fetch latest phishing sites from PhishTank
86
- def fetch_latest_phishing_sites():
87
- try:
88
- response = requests.get('https://data.phishtank.com/data/online-valid.json')
89
- data = response.json()
90
- return data[:5]
91
- except Exception as e:
92
- return []
93
-
94
  # Gradio UI
95
  def phishing_detection(input_text, input_type):
96
  prediction = get_prediction(input_text, input_type)
@@ -99,33 +84,15 @@ def phishing_detection(input_text, input_type):
99
  else:
100
  return f"Safe: This site is not likely a phishing site. ({prediction:.2f})"
101
 
102
- def latest_phishing_sites():
103
- sites = fetch_latest_phishing_sites()
104
- return [f"{site['url']}" for site in sites]
105
-
106
- def chatbot_response(user_input):
107
- response = chatbot.prompt(user_input)
108
- return response
109
-
110
- def interface(input_text, input_type):
111
- result = phishing_detection(input_text, input_type)
112
- latest_sites = latest_phishing_sites()
113
- chatbot_res = chatbot_response(input_text)
114
- return result, latest_sites, chatbot_res
115
-
116
  iface = gr.Interface(
117
- fn=interface,
118
  inputs=[
119
  gr.components.Textbox(lines=5, placeholder="Enter URL or HTML code"),
120
  gr.components.Radio(["URL", "HTML"], type="value", label="Input Type")
121
  ],
122
- outputs=[
123
- gr.components.Textbox(label="Phishing Detection Result"),
124
- gr.components.Textbox(label="Latest Phishing Sites"),
125
- gr.components.Textbox(label="Chatbot Response")
126
- ],
127
  title="Phishing Detection with Enhanced EWC Model",
128
- description="Check if a URL or HTML is Phishing. Latest phishing sites from PhishTank and a chatbot assistant for phishing issues.",
129
  theme="default"
130
  )
131
 
 
2
  import tensorflow as tf
3
  import pickle
4
  import numpy as np
 
 
5
  from sklearn.preprocessing import LabelEncoder
6
 
7
  # Load saved components
 
59
  loss=ewc_loss,
60
  metrics=['accuracy', tf.keras.metrics.Precision(), tf.keras.metrics.Recall()])
61
 
 
 
 
 
62
  # Function to preprocess input
63
  def preprocess_input(input_text, tokenizer, max_length):
64
  sequences = tokenizer.texts_to_sequences([input_text])
 
76
  prediction = model.predict([input_data, input_data])[0][0]
77
  return prediction
78
 
 
 
 
 
 
 
 
 
 
79
  # Gradio UI
80
  def phishing_detection(input_text, input_type):
81
  prediction = get_prediction(input_text, input_type)
 
84
  else:
85
  return f"Safe: This site is not likely a phishing site. ({prediction:.2f})"
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  iface = gr.Interface(
88
+ fn=phishing_detection,
89
  inputs=[
90
  gr.components.Textbox(lines=5, placeholder="Enter URL or HTML code"),
91
  gr.components.Radio(["URL", "HTML"], type="value", label="Input Type")
92
  ],
93
+ outputs=gr.components.Textbox(label="Phishing Detection Result"),
 
 
 
 
94
  title="Phishing Detection with Enhanced EWC Model",
95
+ description="Check if a URL or HTML is Phishing.",
96
  theme="default"
97
  )
98