Update app.py
Browse files
app.py
CHANGED
|
@@ -156,38 +156,42 @@ def generate_performance_metrics():
|
|
| 156 |
def create_interface():
|
| 157 |
performance_metrics = generate_performance_metrics()
|
| 158 |
with gr.Blocks() as interface:
|
| 159 |
-
gr.
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
# Email Text Results and Analysis
|
| 167 |
-
result_output = gr.Textbox(label="Classification Result")
|
| 168 |
-
confidence_output = gr.Textbox(label="Confidence Score", interactive=False)
|
| 169 |
-
|
| 170 |
-
analyze_button = gr.Button("Analyze Email")
|
| 171 |
-
|
| 172 |
-
def email_analysis_pipeline(email_text):
|
| 173 |
-
results = classify_email(email_text)
|
| 174 |
-
return (
|
| 175 |
-
results["result"],
|
| 176 |
-
results["confidence"]
|
| 177 |
)
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
gr.
|
| 186 |
-
with gr.Row():
|
| 187 |
-
gr.Textbox(value=performance_metrics["accuracy"], label="Accuracy", interactive=False)
|
| 188 |
-
gr.Textbox(value=performance_metrics["precision"], label="Precision", interactive=False)
|
| 189 |
-
gr.Textbox(value=performance_metrics["recall"], label="Recall", interactive=False)
|
| 190 |
-
gr.Textbox(value=performance_metrics["f1_score"], label="F1 Score", interactive=False)
|
| 191 |
|
| 192 |
return interface
|
| 193 |
|
|
|
|
| 156 |
def create_interface():
|
| 157 |
performance_metrics = generate_performance_metrics()
|
| 158 |
with gr.Blocks() as interface:
|
| 159 |
+
with gr.Tab("Demo")
|
| 160 |
+
gr.Markdown("Spam and Phishing Email Detection")
|
| 161 |
+
|
| 162 |
+
# Email Text Input
|
| 163 |
+
email_input = gr.Textbox(
|
| 164 |
+
lines=8, placeholder="Type or paste your email content here...", label="Email Content"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
)
|
| 166 |
+
|
| 167 |
+
# Email Text Results and Analysis
|
| 168 |
+
result_output = gr.Textbox(label="Classification Result")
|
| 169 |
+
confidence_output = gr.Textbox(label="Confidence Score", interactive=False)
|
| 170 |
+
|
| 171 |
+
analyze_button = gr.Button("Analyze Email")
|
| 172 |
+
|
| 173 |
+
def email_analysis_pipeline(email_text):
|
| 174 |
+
results = classify_email(email_text)
|
| 175 |
+
return (
|
| 176 |
+
results["result"],
|
| 177 |
+
results["confidence"]
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
analyze_button.click(
|
| 181 |
+
fn=classify_email,
|
| 182 |
+
inputs=email_input,
|
| 183 |
+
outputs=[result_output, confidence_output]
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
with gr.Tab("Analysis")
|
| 187 |
+
gr.Markdown("## 📊 Model Performance Analytics")
|
| 188 |
+
with gr.Row():
|
| 189 |
+
gr.Textbox(value=performance_metrics["accuracy"], label="Accuracy", interactive=False)
|
| 190 |
+
gr.Textbox(value=performance_metrics["precision"], label="Precision", interactive=False)
|
| 191 |
+
gr.Textbox(value=performance_metrics["recall"], label="Recall", interactive=False)
|
| 192 |
+
gr.Textbox(value=performance_metrics["f1_score"], label="F1 Score", interactive=False)
|
| 193 |
|
| 194 |
+
with gr.Tab("Background")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
return interface
|
| 197 |
|