File size: 1,282 Bytes
1fdc612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()