File size: 1,272 Bytes
5a67cd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
import os
import subprocess
from huggingface_hub import HfApi

def deploy_endpoint():
    # Initialize HF API
    api = HfApi()
    
    # Your organization name
    org_name = "shubham24"  # Your HF username
    
    # Repository name
    repo_name = "shuka-endpoint"
    repo_id = f"{org_name}/{repo_name}"
    
    # Create repository if it doesn't exist
    try:
        api.create_repo(
            repo_id=repo_id,
            repo_type="model",
            exist_ok=True
        )
    except Exception as e:
        print(f"Error creating repository: {e}")
        return
    
    # Push files to repository
    try:
        api.upload_folder(
            folder_path=".",
            repo_id=repo_id,
            repo_type="model"
        )
        print(f"Successfully uploaded files to {repo_id}")
    except Exception as e:
        print(f"Error uploading files: {e}")
        return
    
    print("\nNext steps:")
    print("1. Go to https://huggingface.co/spaces")
    print("2. Click 'New Space'")
    print("3. Select 'Inference Endpoint'")
    print("4. Choose your repository")
    print("5. Select A10 GPU (24GB)")
    print("6. Set min_replicas=0, max_replicas=3")
    print("7. Click 'Create Space'")

if __name__ == "__main__":
    deploy_endpoint()