fsi-anomaly / hf_upload.py
FerrellSyntheticIntelligence's picture
backup all: 100 files (batch)
d83b47a verified
Raw
History Blame Contribute Delete
1.59 kB
"""Publish hf_repo to Hugging Face.
1. Login: huggingface-cli login (or set HF_TOKEN)
2. Run: .venv/bin/python hf_upload.py --repo YOUR_ORG/tiny-liquid-analyst
Creates the repo if missing, uploads every file in hf_repo/, and prints the
model page URL. Requires huggingface_hub (installed).
"""
import argparse
import sys
from pathlib import Path
from huggingface_hub import HfApi
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--repo", default="YOUR_ORG/tiny-liquid-analyst",
help="HF repo id, e.g. yourname/tiny-liquid-analyst")
ap.add_argument("--dir", default="hf_repo")
ap.add_argument("--private", action="store_true", help="create as private repo")
args = ap.parse_args()
if args.repo.startswith("YOUR_ORG"):
sys.exit("set --repo to your HF repo id (e.g. yourname/tiny-liquid-analyst)")
api = HfApi()
try:
api.repo_info(args.repo)
print(f"repo exists: {args.repo}")
except Exception:
api.create_repo(args.repo, private=args.private, repo_type="model")
print(f"created repo: {args.repo}")
files = sorted(Path(args.dir).rglob("*"))
files = [f for f in files if f.is_file() and f.name not in (".DS_Store",)]
paths = [str(f) for f in files]
api.upload_folder(folder_path=args.dir, repo_id=args.repo, repo_type="model")
print(f"uploaded {len(paths)} files -> https://huggingface.co/{args.repo}")
print("next: edit the model card link in hf_repo/README.md and re-upload, or set it via the web UI.")
if __name__ == "__main__":
main()