local-inference / create_space.py
ButterM40's picture
Add Hugging Face Spaces deployment files
1fdc612
raw
history blame
1.28 kB
from huggingface_hub import HfApi, login
import sys
def create_space():
# Get token from user
token = input("Enter your Hugging Face access token (from https://huggingface.co/settings/tokens): ")
# Login with token
login(token=token)
api = HfApi()
# Get username
username = input("Enter your Hugging Face username: ")
space_name = "local-inference"
space_id = f"{username}/{space_name}"
print(f"Creating Space: {space_id}")
try:
api.create_repo(
repo_id=space_id,
repo_type="space",
space_sdk="docker",
)
print(f"\nSpace created successfully!")
print(f"Remote URL: https://huggingface.co/spaces/{space_id}")
print("\nNext steps:")
print("1. Initialize git in this directory (if not already done)")
print("2. Add the remote:")
print(f" git remote add origin https://huggingface.co/spaces/{space_id}")
print("3. Push your code:")
print(" git add .")
print(' git commit -m "Initial commit"')
print(" git push -u origin main")
except Exception as e:
print(f"Error creating space: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
create_space()