chgrdj commited on
Commit
b3240eb
1 Parent(s): 1a45114

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -1,27 +1,34 @@
1
  import streamlit as st
2
  from sentence_transformers import CrossEncoder
3
 
4
- # Model selection
5
  st.title("Typosquatting Detection App")
6
  st.write("Enter two domains to check if one is a typosquatted variant of the other.")
7
 
 
8
  model_choice = st.selectbox("Choose a model for detection:", ["CE-typosquat-detect-Canine", "CE-typosquat-detect"])
9
- model_path = f"./{model_choice}"
10
- model = CrossEncoder(model_path)
11
 
12
- # User inputs
 
 
 
 
 
13
  domain = st.text_input("Enter the legitimate domain name:")
14
  typosquat = st.text_input("Enter the potentially typosquatted domain name:")
15
  st.write("Recommended threshold for detection is 0.3.")
16
  threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.3)
17
 
18
- # Typosquatting detection
19
  if st.button("Check Typosquatting"):
20
- inputs = [(typosquat, domain)]
21
- prediction = model.predict(inputs)[0]
22
-
23
- # Display results
24
- if prediction > threshold:
25
- st.success(f"The model predicts that '{typosquat}' is likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
 
 
 
26
  else:
27
- st.warning(f"The model predicts that '{typosquat}' is NOT likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
 
1
  import streamlit as st
2
  from sentence_transformers import CrossEncoder
3
 
4
+ # Title and instructions
5
  st.title("Typosquatting Detection App")
6
  st.write("Enter two domains to check if one is a typosquatted variant of the other.")
7
 
8
+ # Model selection
9
  model_choice = st.selectbox("Choose a model for detection:", ["CE-typosquat-detect-Canine", "CE-typosquat-detect"])
 
 
10
 
11
+ # Load model after selection
12
+ if model_choice:
13
+ model_path = f"./{model_choice}"
14
+ model = CrossEncoder(model_path)
15
+
16
+ # User inputs for domains and threshold
17
  domain = st.text_input("Enter the legitimate domain name:")
18
  typosquat = st.text_input("Enter the potentially typosquatted domain name:")
19
  st.write("Recommended threshold for detection is 0.3.")
20
  threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.3)
21
 
22
+ # Typosquatting detection on button click
23
  if st.button("Check Typosquatting"):
24
+ if domain and typosquat:
25
+ inputs = [(typosquat, domain)]
26
+ prediction = model.predict(inputs)[0]
27
+
28
+ # Display result
29
+ if prediction > threshold:
30
+ st.success(f"The model predicts that '{typosquat}' is likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
31
+ else:
32
+ st.warning(f"The model predicts that '{typosquat}' is NOT likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
33
  else:
34
+ st.error("Please enter both a legitimate domain and a potentially typosquatted domain.")