Download backup.py from FannyFa/FannyFa-Model-V1: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/FannyFa/FannyFa-Model-V1/resolve/main/backup.py
- Command line
-
hf download hf://FannyFa/FannyFa-Model-V1/backup.py
-
curl -L -o backup.py https://huggingface.co/FannyFa/FannyFa-Model-V1/resolve/main/backup.py
1.51 kB
| import shutil | |
| from pathlib import Path | |
| import json | |
| # Path ke backup yang ASLI (nested) | |
| src = Path("/content/drive/MyDrive/colab_backup/project_latest/project_20260910_201145") | |
| # --- 1. Restore /content/models --- | |
| src_models = src / "models" | |
| if src_models.exists(): | |
| if Path("/content/models").exists(): | |
| shutil.rmtree("/content/models") | |
| shutil.copytree(src_models, "/content/models") | |
| print("✓ /content/models di-restore:") | |
| for m in Path("/content/models").iterdir(): | |
| size = sum(f.stat().st_size for f in m.rglob("*") if f.is_file()) | |
| print(f" - {m.name} ({size/(1024*1024):.1f} MB)") | |
| else: | |
| print(f"✗ {src_models} tidak ada") | |
| # --- 2. Restore /content/config.json --- | |
| src_cfg = src / "config.json" | |
| if src_cfg.exists(): | |
| shutil.copy2(src_cfg, "/content/config.json") | |
| print("\n✓ /content/config.json di-restore") | |
| with open("/content/config.json") as f: | |
| cfg = json.load(f) | |
| print(f" Models: {list(cfg.get('models', {}).keys())}") | |
| print(f" Current: {cfg.get('current_model')}") | |
| else: | |
| print(f"\n✗ {src_cfg} tidak ada") | |
| # --- 3. Restore dataset besar kalau ada --- | |
| src_data = src / "data" | |
| if src_data.exists(): | |
| for f in src_data.iterdir(): | |
| if f.is_file() and f.stat().st_size > 100000: | |
| dest = Path("/content/data") / f.name | |
| dest.parent.mkdir(parents=True, exist_ok=True) | |
| shutil.copy2(f, dest) | |
| print(f"✓ Dataset: {f.name} ({f.stat().st_size/(1024*1024):.2f} MB)") |