Spaces:
Runtime error
Runtime error
# https://huggingface.co/docs/huggingface_hub/guides/upload | |
# PUSH model to HuggingFace manufy/mnist_model_keras | |
# with custom commit message | |
############################### | |
# 1 - Initial generic imports # | |
############################### | |
from icecream import ic | |
ic("--- Importing generic libraries ---") | |
from dotenv import load_dotenv, find_dotenv | |
import os | |
from datetime import datetime | |
############################################################################### | |
# 2 - Setting up environment variable HUGGINGFACE_TOKEN with write permission # | |
############################################################################### | |
ic("--- Setting HF API token ---") | |
load_dotenv(find_dotenv()) | |
token = os.getenv("HUGGINGFACE_TOKEN") | |
formatted_now = datetime.now().strftime("%d/%m/%Y, %H:%M:%S") | |
ic("--- Importing HF API ---") | |
from huggingface_hub import HfApi, CommitOperationAdd, CommitOperationDelete | |
ic("--- Executing commit with custom message ---") | |
api = HfApi() | |
operations = [ | |
CommitOperationAdd(path_in_repo="saved_model", path_or_fileobj="mnist_model.keras") | |
] | |
api.create_commit( | |
repo_id="manufy/mnist_model_keras", | |
operations=operations, | |
commit_message=f"Updated model at {formatted_now}.", | |
token=token | |
) | |