Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ lemmatizer = WordNetLemmatizer()
|
|
23 |
def preprocess_url(url):
|
24 |
url = url.lower() # Convert to lowercase
|
25 |
url = re.sub(r'https?://', '', url) # Remove http or https
|
26 |
-
url = re.sub(r'www
|
27 |
url = re.sub(r'[^a-zA-Z0-9]', ' ', url) # Remove special characters
|
28 |
url = re.sub(r'\s+', ' ', url).strip() # Remove extra spaces
|
29 |
tokens = word_tokenize(url) # Tokenize
|
@@ -85,18 +85,24 @@ def predict_phishing(url, html):
|
|
85 |
interface = gr.Interface(
|
86 |
fn=predict_phishing,
|
87 |
inputs=[
|
88 |
-
gr.
|
89 |
-
gr.
|
90 |
],
|
91 |
outputs=[
|
92 |
-
gr.
|
93 |
-
gr.
|
94 |
],
|
95 |
title="Phishing Detection Model",
|
96 |
-
description="Enter a URL and its HTML content to predict if it's spam or legitimate.
|
97 |
-
theme="
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
)
|
101 |
|
102 |
# Launch the Gradio interface
|
|
|
23 |
def preprocess_url(url):
|
24 |
url = url.lower() # Convert to lowercase
|
25 |
url = re.sub(r'https?://', '', url) # Remove http or https
|
26 |
+
url = re.sub(r'www.', '', url) # Remove www
|
27 |
url = re.sub(r'[^a-zA-Z0-9]', ' ', url) # Remove special characters
|
28 |
url = re.sub(r'\s+', ' ', url).strip() # Remove extra spaces
|
29 |
tokens = word_tokenize(url) # Tokenize
|
|
|
85 |
interface = gr.Interface(
|
86 |
fn=predict_phishing,
|
87 |
inputs=[
|
88 |
+
gr.inputs.Textbox(label="URL"),
|
89 |
+
gr.inputs.Textbox(label="HTML Snippet")
|
90 |
],
|
91 |
outputs=[
|
92 |
+
gr.outputs.Textbox(label="Predicted Category"),
|
93 |
+
gr.outputs.Textbox(label="Predicted Probability")
|
94 |
],
|
95 |
title="Phishing Detection Model",
|
96 |
+
description="Enter a URL and its HTML content to predict if it's spam or legitimate.",
|
97 |
+
theme="compact", # Use a more modern theme
|
98 |
+
layout="vertical", # Arrange inputs and outputs vertically
|
99 |
+
allow_flagging=True, # Allow users to flag inappropriate content
|
100 |
+
allow_screenshot=True, # Allow users to take a screenshot
|
101 |
+
allow_replay=True, # Allow users to replay their inputs
|
102 |
+
allow_download=True, # Allow users to download inputs/outputs
|
103 |
+
allow_share=True, # Allow users to share the interface
|
104 |
+
show_comment=True, # Show comment section
|
105 |
+
comment_text="Note: It's recommended to input both URL and HTML for better accuracy." # Custom comment text
|
106 |
)
|
107 |
|
108 |
# Launch the Gradio interface
|