rmdhirr commited on
Commit
5a2dc73
·
verified ·
1 Parent(s): e5bfa3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
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\.', '', 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,18 +85,24 @@ def predict_phishing(url, html):
85
  interface = gr.Interface(
86
  fn=predict_phishing,
87
  inputs=[
88
- gr.components.Textbox(label="URL"),
89
- gr.components.Textbox(label="HTML Snippet", lines=10, placeholder="Paste HTML content here")
90
  ],
91
  outputs=[
92
- gr.components.Textbox(label="Predicted Category"),
93
- gr.components.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. It's recommended to provide both for accurate results.",
97
- theme="huggingface",
98
- live=True,
99
- css=".interface-container { border: 2px solid #4CAF50; border-radius: 10px; padding: 20px; }"
 
 
 
 
 
 
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