gatekeeper_float16 / deploy.py
kmunzwa's picture
Create deploy.py
d97c4e3 verified
# we import HfApi which is the main class for interacting
# with the hugging face hub programmatically
from huggingface_hub import HfApi
# we import os to help build file paths
import os
# we create an instance of the HfApi class
# this is the object we use to talk to hugging face
api = HfApi()
# replace this with your actual hugging face username
HF_USERNAME = "your_username_here"
# this is the name your space will have on hugging face
# the full url will be huggingface.co/spaces/your_username/gatekeeper-model
SPACE_NAME = "gatekeeper-model"
# we combine the username and space name into the full repo id
# hugging face uses this format: username/space-name
REPO_ID = f"{HF_USERNAME}/{SPACE_NAME}"
# this creates the space repository on hugging face
# repo_type="space" tells it this is a gradio space not a model or dataset
# space_sdk="gradio" tells hugging face this space uses gradio
# private=False makes the space publicly accessible
# if you want it private set private=True
api.create_repo(
repo_id=REPO_ID,
repo_type="space",
space_sdk="gradio",
private=False
)
print(f"Space created at: https://huggingface.co/spaces/{REPO_ID}")
# this uploads all the files in the specified local folder to the space
# folder_path is the path to your local project folder
# repo_id is the destination space on hugging face
# repo_type="space" confirms we are uploading to a space
api.upload_folder(
folder_path="./gatekeeper-space",
repo_id=REPO_ID,
repo_type="space"
)
print(f"Deployment complete")
print(f"Visit your space at: https://huggingface.co/spaces/{REPO_ID}")