Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,34 +13,31 @@ st.markdown(
|
|
13 |
"Enter a legitimate URL and a potentially typosquatted URL to see the classifier's prediction."
|
14 |
)
|
15 |
|
16 |
-
|
17 |
-
model_path = "./URLGuardian" # Model repository on Hugging Face
|
18 |
-
st.markdown(model_path
|
19 |
-
)
|
20 |
classifier = load_classifier(model_path)
|
21 |
|
22 |
# URL inputs
|
23 |
url = st.text_input("Enter the URL:", value="https://example.com")
|
24 |
|
25 |
# Typosquatting detection on button click
|
26 |
-
if st.button("Check
|
27 |
-
if
|
28 |
-
|
29 |
result = classifier(url)[0]
|
30 |
-
label = result[
|
31 |
-
score = result[
|
32 |
-
|
33 |
-
#
|
34 |
-
#
|
35 |
-
if "
|
36 |
st.success(
|
37 |
-
f"The
|
38 |
-
f"with a confidence of {score * 100:.2f}%."
|
39 |
)
|
40 |
else:
|
41 |
-
st.
|
42 |
-
f"The
|
43 |
-
f"with a confidence of {score * 100:.2f}%."
|
44 |
)
|
|
|
|
|
45 |
else:
|
46 |
-
st.error("Please enter
|
|
|
13 |
"Enter a legitimate URL and a potentially typosquatted URL to see the classifier's prediction."
|
14 |
)
|
15 |
|
16 |
+
model_path = "./URLGuardian"
|
|
|
|
|
|
|
17 |
classifier = load_classifier(model_path)
|
18 |
|
19 |
# URL inputs
|
20 |
url = st.text_input("Enter the URL:", value="https://example.com")
|
21 |
|
22 |
# Typosquatting detection on button click
|
23 |
+
if st.button("Check Safety of the url"):
|
24 |
+
if url:
|
25 |
+
# Run the classifier on the input URL
|
26 |
result = classifier(url)[0]
|
27 |
+
label = result["label"]
|
28 |
+
score = result["score"]
|
29 |
+
|
30 |
+
# Display result based on the label
|
31 |
+
# Adjust the label checking logic based on the model's documentation.
|
32 |
+
if "safe" in label.lower():
|
33 |
st.success(
|
34 |
+
f"The URL '{url}' is considered safe with a confidence of {score * 100:.2f}%."
|
|
|
35 |
)
|
36 |
else:
|
37 |
+
st.error(
|
38 |
+
f"The URL '{url}' is considered suspicious with a confidence of {score * 100:.2f}%."
|
|
|
39 |
)
|
40 |
+
# Optionally, you can display the full result for debugging purposes:
|
41 |
+
st.write("Full classification output:", result)
|
42 |
else:
|
43 |
+
st.error("Please enter a URL.")
|