Ismael1-2-3 commited on
Commit
68ca8cd
·
verified ·
1 Parent(s): e06d2b6

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +27 -0
main.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import LlamaForConditionalGeneration, LlamaTokenizer
3
+
4
+ # Load pre-trained model and tokenizer
5
+ model_name = "meta-ai/llama-3.2-3b-instruct"
6
+ model = LlamaForConditionalGeneration.from_pretrained(model_name)
7
+ tokenizer = LlamaTokenizer.from_pretrained(model_name)
8
+
9
+ def evaluate_password_strength(password):
10
+ # Use the Llama model to evaluate the password strength
11
+ input_text = f"Rate the strength of the password: {password}"
12
+ inputs = tokenizer(input_text, return_tensors="pt")
13
+ output = model.generate(**inputs)
14
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
15
+
16
+ return response
17
+
18
+ demo = gr.Interface(
19
+ evaluate_password_strength,
20
+ gr.Textbox(label="Enter your password"),
21
+ gr.Textbox(label="Password Strength Evaluation"),
22
+ title="Password Strength Evaluator",
23
+ description="Get the AI's evaluation of your password strength.",
24
+ )
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()