ViuMini-Dense-360M / model /scripts /push_to_hf.py
ViuAI's picture
refactor: consolidate pure 32L Dense architecture, purge MoE files, audit hardening
3a5d3e5 verified
Raw History Blame Contribute Delete
2.68 kB
"""
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()