Rename untitled3.py to app.py
Browse files- untitled3.py → app.py +0 -24
untitled3.py → app.py
RENAMED
|
@@ -269,7 +269,6 @@ def email_analysis_pipeline(email_text):
|
|
| 269 |
|
| 270 |
## Gradio Interface
|
| 271 |
|
| 272 |
-
!pip install gradio
|
| 273 |
import gradio as gr
|
| 274 |
|
| 275 |
# Create Gradio Interface
|
|
@@ -394,26 +393,3 @@ button:hover {
|
|
| 394 |
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
|
| 395 |
}
|
| 396 |
"""
|
| 397 |
-
|
| 398 |
-
## Original
|
| 399 |
-
|
| 400 |
-
from sklearn.metrics import classification_report
|
| 401 |
-
|
| 402 |
-
# Collect predictions and true labels
|
| 403 |
-
y_true = []
|
| 404 |
-
y_pred = []
|
| 405 |
-
|
| 406 |
-
model.eval()
|
| 407 |
-
with torch.no_grad():
|
| 408 |
-
for batch in val_loader:
|
| 409 |
-
inputs = {key: val.to(device) for key, val in batch.items()}
|
| 410 |
-
labels = inputs.pop("labels").to(device)
|
| 411 |
-
|
| 412 |
-
outputs = model(**inputs)
|
| 413 |
-
predictions = torch.argmax(outputs.logits, dim=1)
|
| 414 |
-
|
| 415 |
-
y_true.extend(labels.cpu().numpy())
|
| 416 |
-
y_pred.extend(predictions.cpu().numpy())
|
| 417 |
-
|
| 418 |
-
# Print detailed classification report
|
| 419 |
-
print(classification_report(y_true, y_pred, target_names=["Ham", "Spam"]))
|
|
|
|
| 269 |
|
| 270 |
## Gradio Interface
|
| 271 |
|
|
|
|
| 272 |
import gradio as gr
|
| 273 |
|
| 274 |
# Create Gradio Interface
|
|
|
|
| 393 |
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
|
| 394 |
}
|
| 395 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|