| """ |
| Bundle the skeleton-gif package into a self-contained artifact ready for |
| `huggingface_hub.upload_folder` or `SkeletonGif.from_pretrained` against a |
| relocated directory. |
| |
| What this does: |
| 1. Vendors ../generate.py → ./engine.py so the model dir is fully portable. |
| 2. Writes config.json snapshotting the current engine's label sets. |
| 3. Leaves existing README.md and requirements.txt untouched (edit by hand |
| when needed). |
| |
| Run: |
| python -m skeleton_gif_model.bundle |
| or: |
| cd skeleton_gif_model && python bundle.py |
| """ |
|
|
| from __future__ import annotations |
|
|
| import shutil |
| import sys |
| from pathlib import Path |
|
|
|
|
| def bundle(root: Path | None = None) -> Path: |
| here = Path(__file__).resolve().parent |
| root = root or here.parent |
|
|
| src = root / "generate.py" |
| dst = here / "engine.py" |
| if not src.exists(): |
| raise FileNotFoundError(f"Expected the engine at {src}") |
| shutil.copyfile(src, dst) |
| print(f"[bundle] vendored {src} -> {dst}") |
|
|
| |
| if str(here.parent) not in sys.path: |
| sys.path.insert(0, str(here.parent)) |
| |
| import importlib |
| if "skeleton_gif_model.engine" in sys.modules: |
| importlib.reload(sys.modules["skeleton_gif_model.engine"]) |
| from skeleton_gif_model.modeling import SkeletonGif |
|
|
| model = SkeletonGif() |
| model.save_pretrained(here) |
| print(f"[bundle] wrote {here / 'config.json'}") |
| return here |
|
|
|
|
| if __name__ == "__main__": |
| out = bundle() |
| print(f"[bundle] done. Model dir: {out}") |
|
|