""" eden_upload_fast.py – Uploads READMEs, CSVs, and .py scripts to Hugging Face. No .pth weights (those are uploaded separately due to size). """ from huggingface_hub import HfApi, create_repo, upload_file import os, glob TOKEN = os.environ.get("HF_TOKEN", "") USER = "Shanmuk4622" BASE = os.path.dirname(os.path.abspath(__file__)) api = HfApi(token=TOKEN) print(f"Logged in as: {api.whoami()['name']}\n") # ── helpers ──────────────────────────────────────────────────────────────────── def safe_upload(local_path, repo_id, repo_filename): try: upload_file( path_or_fileobj=local_path, path_in_repo=repo_filename, repo_id=repo_id, token=TOKEN, repo_type="model", ) print(f" ✓ {repo_filename} → {repo_id}") except Exception as e: print(f" ✗ {repo_filename} → {repo_id} | {e}") def parse_arch_ds(fn): fn = fn.lower().replace("\\", "/") ds = "unknown" arch = "unknown" if "cifar100" in fn: ds = "CIFAR-100" elif "cifar10" in fn: ds = "CIFAR-10" elif "imagenet" in fn: ds = "Custom-ImageNet300" if "efficientnet" in fn: arch = "EfficientNetV2" elif "convnext" in fn: arch = "ConvNeXtV2" elif "mobilevit" in fn: arch = "MobileViTv3" elif "resnet50" in fn: arch = "ResNet50" elif "resnet18" in fn: arch = "ResNet18" elif "vgg16" in fn: arch = "VGG16" elif "alexnet" in fn: arch = "AlexNet" elif "inception" in fn: arch = "InceptionV3" elif "densenet" in fn: arch = "DenseNet121" elif "unet" in fn: arch = "UNet" return arch, ds # ── STEP 1 : Core-Scripts repo ───────────────────────────────────────────────── print("="*60) print("STEP 1 — EDEN-Core-Scripts (README + .py scripts)") print("="*60) core_repo = f"{USER}/EDEN-Core-Scripts" create_repo(core_repo, token=TOKEN, repo_type="model", exist_ok=True, private=False) # README safe_upload( os.path.join(BASE, "hf_readmes", "EDEN-Core-Scripts_README.md"), core_repo, "README.md" ) # All algorithm .py scripts for py in sorted(glob.glob(os.path.join(BASE, "**", "*.py"), recursive=True)): rel = os.path.relpath(py, BASE) if any(k in rel for k in ["Algo_", "eden_", "mobilevit_model"]): safe_upload(py, core_repo, rel.replace(os.sep, "/")) # ── STEP 2 : Per-model READMEs ──────────────────────────────────────────────── print("\n" + "="*60) print("STEP 2 — Per-model repo READMEs") print("="*60) for rf in sorted(glob.glob(os.path.join(BASE, "hf_readmes", "EDEN-*_README.md"))): repo_name = os.path.basename(rf).replace("_README.md", "") repo_id = f"{USER}/{repo_name}" create_repo(repo_id, token=TOKEN, repo_type="model", exist_ok=True, private=False) safe_upload(rf, repo_id, "README.md") # ── STEP 3 : CSV training logs ──────────────────────────────────────────────── print("\n" + "="*60) print("STEP 3 — CSV training logs") print("="*60) for csv in sorted(glob.glob(os.path.join(BASE, "**", "*.csv"), recursive=True)): # skip the aggregated helper CSVs if any(skip in csv for skip in ["green_ai_", "experiment_summary", "repository"]): continue arch, ds = parse_arch_ds(csv) if arch == "unknown" or ds == "unknown": continue repo_id = f"{USER}/EDEN-{arch}-{ds.replace(' ', '-')}" safe_upload(csv, repo_id, os.path.basename(csv)) print("\n" + "="*60) print("ALL DONE — Check https://huggingface.co/Shanmuk4622") print("="*60)