Spaces:
Sleeping
Sleeping
Infinitode Pty Ltd
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib
|
3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
+
from sklearn.calibration import CalibratedClassifierCV
|
5 |
+
|
6 |
+
def predict_password_strength(model, vectorizer, password_input):
|
7 |
+
password_tfidf = vectorizer.transform([password_input])
|
8 |
+
|
9 |
+
# Make predictions
|
10 |
+
predicted_proba = model.predict_proba(password_tfidf)
|
11 |
+
predicted_class = int(model.predict(password_tfidf)[0]) # Convert to Python integer
|
12 |
+
output = ''
|
13 |
+
if predicted_class == 0:
|
14 |
+
output = "The password is very weak..."
|
15 |
+
elif predicted_class == 1:
|
16 |
+
output = "The password is average."
|
17 |
+
else:
|
18 |
+
output = "The password is strong. But alas, it is not unbreakable."
|
19 |
+
|
20 |
+
confidence = float(predicted_proba.max())
|
21 |
+
|
22 |
+
return password_input, output, confidence
|
23 |
+
|
24 |
+
model = joblib.load("helix-psa.pkl")
|
25 |
+
vectorizer = joblib.load("helix-psa-vectorizer.pkl")
|
26 |
+
|
27 |
+
demo = gr.Interface(
|
28 |
+
fn=generateNames,
|
29 |
+
inputs=[gr.Textbox('Hello123', label='Password', info='The password to check the strength of', max_lines=1)],
|
30 |
+
outputs=[gr.Dataframe(row_count = (2, "dynamic"), col_count=(3, "fixed"), label="Generated Names", headers=["Password", "Prediction", "Confidence"])],
|
31 |
+
title='Helix - Password Strength Analyzer',
|
32 |
+
description='A password strength analyzer, trained on over 10 million different passwords.'
|
33 |
+
)
|
34 |
+
|
35 |
+
demo.launch()
|