Spaces:
Sleeping
Sleeping
File size: 521 Bytes
16f0e1e f0e7ec4 234513a f0e7ec4 16f0e1e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from huggingface_hub import hf_hub_download
from joblib import load
from sklearn.pipeline import Pipeline
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1" # Add at top
MODEL_REPO = "adrian7305/email-classifier"
MODEL_FILE = "model.joblib"
def load_model() -> Pipeline:
model_path = hf_hub_download(
repo_id=MODEL_REPO,
filename=MODEL_FILE,
cache_dir="/tmp/.hf_cache"
)
return load(model_path)
def classify_email(model: Pipeline, email: str) -> str:
return str(model.predict([email])[0]) |