File size: 1,992 Bytes
efa0ffc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
"""
Deploy Rubik's Cube Recognition to Hugging Face Spaces
"""

import os
from huggingface_hub import HfApi, Repository


def deploy_to_huggingface():
    """Deploy the project to Hugging Face Spaces"""

    # Set your token

    # Initialize HF API
    api = HfApi()

    # Repository details
    repo_id = "itsyuimorii/rubiks-cube-recognition"
    repo_type = "space"

    print(f"Deploying to: https://huggingface.co/spaces/{repo_id}")

    try:
        # Create repository if it doesn't exist
        api.create_repo(
            repo_id=repo_id,
            token=token,
            repo_type=repo_type,
            exist_ok=True
        )
        print("βœ… Repository created/verified")

        # Upload files
        files_to_upload = [
            "README.md",
            "app.py",
            "requirements.txt",
            "app_simple.py"
        ]

        for file_path in files_to_upload:
            if os.path.exists(file_path):
                print(f"πŸ“€ Uploading {file_path}...")
                api.upload_file(
                    path_or_fileobj=file_path,
                    path_in_repo=file_path,
                    repo_id=repo_id,
                    repo_type=repo_type,
                    token=token
                )
                print(f"βœ… {file_path} uploaded successfully")
            else:
                print(f"⚠️ {file_path} not found, skipping...")

        print("\nπŸŽ‰ Deployment completed successfully!")
        print(f"🌐 Visit your Space: https://huggingface.co/spaces/{repo_id}")

    except Exception as e:
        print(f"❌ Error during deployment: {e}")
        return False

    return True


if __name__ == "__main__":
    # Install required package if not already installed
    try:
        import huggingface_hub
    except ImportError:
        print("Installing huggingface_hub...")
        os.system("pip install huggingface_hub")
        import huggingface_hub

    deploy_to_huggingface()