blizet commited on
Commit
9c1b47f
·
verified ·
1 Parent(s): 138a5bb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import gradio as gr
3
+
4
+ # Load the model and tokenizer from Hugging Face Hub
5
+ model_name = "blizet/Llama-Phishing-Finetune"
6
+
7
+ # Load model and tokenizer
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+ model = AutoModelForCausalLM.from_pretrained(model_name)
10
+
11
+ # Define a function to generate responses
12
+ def analyze_email(email):
13
+ prompt = f"""
14
+ Analyze the email with the following criteria:
15
+ ...
16
+ Email: {email}
17
+ """
18
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
19
+ outputs = model.generate(**inputs, max_new_tokens=150)
20
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
21
+
22
+ # Gradio interface
23
+ demo = gr.Interface(
24
+ fn=analyze_email,
25
+ inputs="textbox",
26
+ outputs="textbox",
27
+ title="Phishing Email Analyzer",
28
+ description="Enter an email for analysis."
29
+ )
30
+
31
+ # Launch the app
32
+ demo.launch()