File size: 1,143 Bytes
a4bd2c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Upload DeepFormants-onnx artifacts to a private HF model repo.

Token: pass via env HF_TOKEN, or hard-coded fallback for local one-shot use.
Repo: FredrikKarlssonSpeech/DeepFormants (private).
"""
import os
import sys
from pathlib import Path
from huggingface_hub import HfApi, create_repo

ROOT = Path(__file__).resolve().parents[1]
REPO_ID = "FredrikKarlssonSpeech/DeepFormants"

TOKEN = os.environ.get("HF_TOKEN")
if not TOKEN:
    print("ERROR: set HF_TOKEN env var before running.", file=sys.stderr)
    sys.exit(2)


def main():
    api = HfApi(token=TOKEN)

    create_repo(
        REPO_ID, token=TOKEN, repo_type="model",
        private=True, exist_ok=True,
    )
    print(f"Repo ready: {REPO_ID} (private)")

    api.upload_folder(
        folder_path=ROOT.as_posix(),
        repo_id=REPO_ID,
        repo_type="model",
        token=TOKEN,
        commit_message="Upload DeepFormants ONNX (fp32/fp16/int8) for LPC estimator + LSTM tracker",
        ignore_patterns=["scripts/__pycache__/*", "*.pyc", ".DS_Store"],
    )
    print(f"Uploaded {ROOT} -> https://huggingface.co/{REPO_ID}")


if __name__ == "__main__":
    main()