e-commerce / backend /upload_model.py
VincentA2K's picture
Product Recommendation RestAPI
480e694
raw
history blame contribute delete
596 Bytes
import shutil
from huggingface_hub import HfApi
# Hugging Face setup
HF_USERNAME = "your-hf-username"
REPO_NAME = f"{HF_USERNAME}/product-recommendation"
api = HfApi()
# Create Hugging Face repo (if not exists)
api.create_repo(REPO_NAME, exist_ok=True)
# Copy embeddings to upload
shutil.copy("../models/product_embeddings.pkl", "product_embeddings.pkl")
# Upload to Hugging Face
api.upload_file(
path_or_fileobj="product_embeddings.pkl",
path_in_repo="product_embeddings.pkl",
repo_id=REPO_NAME
)
print(f"✅ Model uploaded to Hugging Face: https://huggingface.co/{REPO_NAME}")