| """ |
| 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") |
|
|
| |
| 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 |
|
|
| |
| 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) |
|
|
| |
| safe_upload( |
| os.path.join(BASE, "hf_readmes", "EDEN-Core-Scripts_README.md"), |
| core_repo, "README.md" |
| ) |
|
|
| |
| 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, "/")) |
|
|
| |
| 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") |
|
|
| |
| print("\n" + "="*60) |
| print("STEP 3 β CSV training logs") |
| print("="*60) |
|
|
| for csv in sorted(glob.glob(os.path.join(BASE, "**", "*.csv"), recursive=True)): |
| |
| 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) |
|
|