File size: 1,200 Bytes
16e21ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Upload fused ControlAI model directly from local disk to Hugging Face Model Hub."""

import os
import sys
from pathlib import Path
from huggingface_hub import HfApi

PROJECT_ROOT = Path(__file__).resolve().parent.parent
MODEL_DIR = PROJECT_ROOT / "models" / "controlai_fused"
REPO_ID = "atakankahya/ControlAI-Agent"

def main():
    if not MODEL_DIR.exists():
        print(f"Error: Model directory not found at {MODEL_DIR}")
        sys.exit(1)

    token = os.environ.get("HF_TOKEN")
    if not token:
        # Prompt user or read from cache
        from huggingface_hub import get_token
        token = get_token()

    if not token:
        print("Error: Hugging Face token not found. Please provide HF_TOKEN environment variable or login via huggingface_hub.")
        sys.exit(1)

    print(f"Uploading local fused model from {MODEL_DIR} (2.26 GB) to https://huggingface.co/{REPO_ID}...")
    api = HfApi(token=token)
    api.upload_folder(
        folder_path=str(MODEL_DIR),
        repo_id=REPO_ID,
        repo_type="model",
    )
    print("\nUpload complete! Your fine-tuned model is now live on Hugging Face Model Hub.")

if __name__ == "__main__":
    main()