| """ | |
| Minimal smoke test / usage demo for the packaged SkeletonGif model. | |
| Run: | |
| python -m skeleton_gif_model.example | |
| """ | |
| from pathlib import Path | |
| from skeleton_gif_model import SkeletonGif | |
| def main() -> None: | |
| here = Path(__file__).resolve().parent | |
| # Load from local dir (same surface as loading from the Hub). | |
| model = SkeletonGif.from_pretrained(here) | |
| print(model) | |
| prompts = [ | |
| "a sad man reading a book in a bedroom", | |
| "happy skeleton playing football on a soccer field", | |
| "tired woman cleaning the living room", | |
| ] | |
| out_dir = here.parent / "outputs" / "hf_demo" | |
| out_dir.mkdir(parents=True, exist_ok=True) | |
| for p in prompts: | |
| result = model(p) | |
| path = out_dir / f"{result.action}-{result.emotion}-{result.scene}.gif" | |
| result.save(path) | |
| print(f"{p!r:70s} -> {result.action}/{result.emotion}/{result.scene} " | |
| f"({len(result.gif_bytes)} bytes) -> {path.name}") | |
| if __name__ == "__main__": | |
| main() | |