File size: 2,676 Bytes
140f9f6
d9702de
140f9f6
d9702de
 
140f9f6
 
 
 
d9702de
140f9f6
 
 
3a5d3e5
 
 
 
140f9f6
 
 
 
d9702de
140f9f6
 
 
 
 
 
 
 
 
 
 
 
3a5d3e5
140f9f6
3a5d3e5
140f9f6
3a5d3e5
140f9f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Push ViuMini-Dense-360M model repo to HF.
Usage:
  python push_to_hf.py --repo ViuAI/ViuMini-Dense-360M --dry-run
  python push_to_hf.py --repo ViuAI/ViuMini-Dense-360M --message "init"
"""
import argparse
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]  # ViuMini-Dense-360M/

# HF model repo me kya NAHI jayega (bada raw data model repo me mat push karo)
IGNORE = [
    "__pycache__/*", "*.pyc", "*.pyo", ".git/*", ".ipynb_checkpoints/*",
    "model/checkpoints/*", "checkpoints/*", "*.pt", "*.bin", "*.safetensors",
    "logs/*", "*.jsonl", "*.log",
    "data/raw/*", "data/processed/*", "data/tmp*/*", "*.parquet", "data/*spotcheck*",
]

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--repo", default="ViuAI/ViuMini-Dense-360M", help="HF repo id, e.g. ViuAI/ViuMini-Dense-360M")
    ap.add_argument("--message", default="update")
    ap.add_argument("--dry-run", action="store_true")
    args = ap.parse_args()

    if args.dry_run:
        print(f"[dry-run] would push {ROOT} -> {args.repo}")
        print(f"[dry-run] message: {args.message}")
        print(f"[dry-run] ignore: {IGNORE}")
        for p in sorted(ROOT.rglob("*")):
            if p.is_file() and "__pycache__" not in str(p) and ".git" not in str(p):
                rel = p.relative_to(ROOT)
                rel_s = str(rel).replace("\\", "/")
                if any(rel_s.startswith(p) for p in ["data/raw/", "data/processed", "data/tmp", "logs/", "checkpoints/", "model/checkpoints/"]):
                    continue
                if rel.suffix in (".parquet", ".pt", ".bin", ".safetensors", ".pyc", ".pyo", ".log", ".jsonl"):
                    continue
                if "spotcheck" in rel_s:
                    continue
                print("  +", rel, f"({p.stat().st_size} bytes)")
        print("[dry-run] OK — run without --dry-run to push")
        return

    try:
        from huggingface_hub import HfApi
    except ImportError:
        print("[error] huggingface_hub not installed. pip install huggingface_hub")
        return

    api = HfApi()
    # ensure repo exists (create if needed)
    try:
        api.create_repo(repo_id=args.repo, repo_type="model", exist_ok=True)
        print(f"[hf] repo ensured: {args.repo}")
    except Exception as e:
        print(f"[warn] create_repo: {e}")

    print(f"[hf] uploading {ROOT} -> {args.repo} ...")
    api.upload_folder(
        folder_path=str(ROOT),
        repo_id=args.repo,
        repo_type="model",
        commit_message=args.message,
        ignore_patterns=IGNORE,
    )
    print(f"[ok] pushed to https://huggingface.co/{args.repo}")

if __name__ == "__main__":
    main()