chgrdj commited on
Commit
1a45114
·
verified ·
1 Parent(s): fde00ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -1,23 +1,27 @@
1
  import streamlit as st
2
  from sentence_transformers import CrossEncoder
3
 
4
- model_name = "./"
5
- model = CrossEncoder(model_name)
6
-
7
  st.title("Typosquatting Detection App")
8
  st.write("Enter two domains to check if one is a typosquatted variant of the other.")
9
 
 
 
 
 
 
10
  domain = st.text_input("Enter the legitimate domain name:")
11
  typosquat = st.text_input("Enter the potentially typosquatted domain name:")
12
  st.write("Recommended threshold for detection is 0.3.")
13
  threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.3)
14
 
15
-
16
  if st.button("Check Typosquatting"):
17
- inputs = [(typosquat,domain)]
18
  prediction = model.predict(inputs)[0]
19
- print(prediction)
 
20
  if prediction > threshold:
21
- st.success(f"The model predicts that '{typosquat}' is likely a typosquatted version of '{domain}' with a score of {prediction}.")
22
  else:
23
- st.warning(f"The model predicts that '{typosquat}' is NOT likely a typosquatted version of '{domain}' with a score of {prediction}.")
 
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}.")