Spaces:
Sleeping
Sleeping
File size: 623 Bytes
fdc91d2 e2047f6 fdc91d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import os
import joblib
import urllib.request
# ✅ Direct raw GitHub link (must return a real .joblib file)
MODEL_URL = "https://raw.githubusercontent.com/Youranalyst-coder/twitter-sentiment-analysis/main/artifacts/sentiment_pipeline.joblib"
MODEL_PATH = "artifacts/sentiment_pipeline.joblib"
def get_model():
"""Download and cache the model if not available."""
os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True)
if not os.path.exists(MODEL_PATH):
print("Downloading model from remote repository...")
urllib.request.urlretrieve(MODEL_URL, MODEL_PATH)
return joblib.load(MODEL_PATH)
|