Spaces:
Running
Running
Create deploy.py
Browse files
deploy.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# we import HfApi which is the main class for interacting
|
| 2 |
+
# with the hugging face hub programmatically
|
| 3 |
+
from huggingface_hub import HfApi
|
| 4 |
+
|
| 5 |
+
# we import os to help build file paths
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
# we create an instance of the HfApi class
|
| 9 |
+
# this is the object we use to talk to hugging face
|
| 10 |
+
api = HfApi()
|
| 11 |
+
|
| 12 |
+
# replace this with your actual hugging face username
|
| 13 |
+
HF_USERNAME = "your_username_here"
|
| 14 |
+
|
| 15 |
+
# this is the name your space will have on hugging face
|
| 16 |
+
# the full url will be huggingface.co/spaces/your_username/gatekeeper-model
|
| 17 |
+
SPACE_NAME = "gatekeeper-model"
|
| 18 |
+
|
| 19 |
+
# we combine the username and space name into the full repo id
|
| 20 |
+
# hugging face uses this format: username/space-name
|
| 21 |
+
REPO_ID = f"{HF_USERNAME}/{SPACE_NAME}"
|
| 22 |
+
|
| 23 |
+
# this creates the space repository on hugging face
|
| 24 |
+
# repo_type="space" tells it this is a gradio space not a model or dataset
|
| 25 |
+
# space_sdk="gradio" tells hugging face this space uses gradio
|
| 26 |
+
# private=False makes the space publicly accessible
|
| 27 |
+
# if you want it private set private=True
|
| 28 |
+
api.create_repo(
|
| 29 |
+
repo_id=REPO_ID,
|
| 30 |
+
repo_type="space",
|
| 31 |
+
space_sdk="gradio",
|
| 32 |
+
private=False
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
print(f"Space created at: https://huggingface.co/spaces/{REPO_ID}")
|
| 36 |
+
|
| 37 |
+
# this uploads all the files in the specified local folder to the space
|
| 38 |
+
# folder_path is the path to your local project folder
|
| 39 |
+
# repo_id is the destination space on hugging face
|
| 40 |
+
# repo_type="space" confirms we are uploading to a space
|
| 41 |
+
api.upload_folder(
|
| 42 |
+
folder_path="./gatekeeper-space",
|
| 43 |
+
repo_id=REPO_ID,
|
| 44 |
+
repo_type="space"
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
print(f"Deployment complete")
|
| 48 |
+
print(f"Visit your space at: https://huggingface.co/spaces/{REPO_ID}")
|